Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp

Issue 74413002: Make -webkit-font-kerning actually work. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address behdad's comments and add vkrn Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/text/font-kerning-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
6 * met: 7 * met:
7 * 8 *
8 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 11 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer 12 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 13 * in the documentation and/or other materials provided with the
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 void HarfBuzzShaper::setFontFeatures() 502 void HarfBuzzShaper::setFontFeatures()
502 { 503 {
503 const FontDescription& description = m_font->fontDescription(); 504 const FontDescription& description = m_font->fontDescription();
504 if (description.orientation() == Vertical) { 505 if (description.orientation() == Vertical) {
505 static hb_feature_t vert = { HarfBuzzFace::vertTag, 1, 0, static_cast<un signed>(-1) }; 506 static hb_feature_t vert = { HarfBuzzFace::vertTag, 1, 0, static_cast<un signed>(-1) };
506 static hb_feature_t vrt2 = { HarfBuzzFace::vrt2Tag, 1, 0, static_cast<un signed>(-1) }; 507 static hb_feature_t vrt2 = { HarfBuzzFace::vrt2Tag, 1, 0, static_cast<un signed>(-1) };
507 m_features.append(vert); 508 m_features.append(vert);
508 m_features.append(vrt2); 509 m_features.append(vrt2);
509 } 510 }
510 511
512 static hb_feature_t noKern = { HB_TAG('k', 'e', 'r', 'n'), 0, 0, static_cast <unsigned>(-1) };
513 static hb_feature_t noVkrn = { HB_TAG('v', 'k', 'r', 'n'), 0, 0, static_cast <unsigned>(-1) };
514 switch (description.kerning()) {
515 case FontDescription::NormalKerning:
516 // kern/vkrn are enabled by default
517 break;
518 case FontDescription::NoneKerning:
519 m_features.append(description.orientation() == Vertical ? noVkrn : noKer n);
520 break;
521 case FontDescription::AutoKerning:
522 break;
523 }
524
511 FontFeatureSettings* settings = description.featureSettings(); 525 FontFeatureSettings* settings = description.featureSettings();
512 if (!settings) 526 if (!settings)
513 return; 527 return;
514 528
515 unsigned numFeatures = settings->size(); 529 unsigned numFeatures = settings->size();
516 for (unsigned i = 0; i < numFeatures; ++i) { 530 for (unsigned i = 0; i < numFeatures; ++i) {
517 hb_feature_t feature; 531 hb_feature_t feature;
518 String tag = settings->at(i).tag(); 532 String tag = settings->at(i).tag();
519 feature.tag = HB_TAG(tag[0], tag[1], tag[2], tag[3]); 533 feature.tag = HB_TAG(tag[0], tag[1], tag[2], tag[3]);
520 feature.value = settings->at(i).value(); 534 feature.value = settings->at(i).value();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 if (!foundToX) 888 if (!foundToX)
875 toX = m_run.rtl() ? 0 : m_totalWidth; 889 toX = m_run.rtl() ? 0 : m_totalWidth;
876 890
877 // Using floorf() and roundf() as the same as mac port. 891 // Using floorf() and roundf() as the same as mac port.
878 if (fromX < toX) 892 if (fromX < toX)
879 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from X), height); 893 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from X), height);
880 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he ight); 894 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he ight);
881 } 895 }
882 896
883 } // namespace WebCore 897 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/font-kerning-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698