Chromium Code Reviews| Index: Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp |
| diff --git a/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp b/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp |
| index e297fe4e220e688875b5bb8cfee54752ed2e37c0..f2e17b803a0a38c1a3961dd21d6be5ff90d851c1 100644 |
| --- a/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp |
| +++ b/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp |
| @@ -1,5 +1,6 @@ |
| /* |
| * Copyright (c) 2012 Google Inc. All rights reserved. |
| + * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions are |
| @@ -49,6 +50,12 @@ |
| namespace WebCore { |
| +const hb_tag_t cligTag = HB_TAG('c', 'l', 'i', 'g'); |
| +const hb_tag_t dligTag = HB_TAG('d', 'l', 'i', 'g'); |
| +const hb_tag_t hligTag = HB_TAG('h', 'l', 'i', 'g'); |
| +const hb_tag_t kernTag = HB_TAG('k', 'e', 'r', 'n'); |
| +const hb_tag_t ligaTag = HB_TAG('l', 'i', 'g', 'a'); |
| + |
| template<typename T> |
| class HarfBuzzScopedPtr { |
| public: |
| @@ -508,6 +515,71 @@ void HarfBuzzShaper::setFontFeatures() |
| m_features.append(vrt2); |
| } |
| + static hb_feature_t kern = { kernTag, 1, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t noKern = { kernTag, 0, 0, static_cast<unsigned>(-1) }; |
| + if (!(m_font->typesettingFeatures() & Kerning)) { |
| + m_features.append(noKern); |
| + } else { |
| + switch (description.kerning()) { |
| + case FontDescription::NormalKerning: |
| + m_features.append(kern); |
| + break; |
| + case FontDescription::NoneKerning: |
| + m_features.append(noKern); |
| + break; |
| + case FontDescription::AutoKerning: |
| + break; |
| + } |
| + } |
| + |
| + static hb_feature_t liga = { ligaTag, 1, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t noLiga = { ligaTag, 0, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t clig = { cligTag, 1, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t noClig = { cligTag, 0, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t dlig = { dligTag, 1, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t noDlig = { dligTag, 0, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t hlig = { hligTag, 1, 0, static_cast<unsigned>(-1) }; |
| + static hb_feature_t noHlig = { hligTag, 0, 0, static_cast<unsigned>(-1) }; |
| + if (!(m_font->typesettingFeatures() & Ligatures)) { |
| + m_features.append(noLiga); |
| + m_features.append(noClig); |
| + m_features.append(noDlig); |
| + m_features.append(noHlig); |
| + } else { |
| + switch (description.commonLigaturesState()) { |
| + case FontDescription::DisabledLigaturesState: |
| + m_features.append(noLiga); |
| + m_features.append(noClig); |
| + break; |
| + case FontDescription::EnabledLigaturesState: |
| + m_features.append(liga); |
|
behdad_google
2013/11/15 16:26:35
Don't append features that are enabled by default.
|
| + m_features.append(clig); |
| + break; |
| + case FontDescription::NormalLigaturesState: |
| + break; |
| + } |
| + switch (description.discretionaryLigaturesState()) { |
| + case FontDescription::DisabledLigaturesState: |
| + m_features.append(noDlig); |
| + break; |
| + case FontDescription::EnabledLigaturesState: |
| + m_features.append(dlig); |
| + break; |
| + case FontDescription::NormalLigaturesState: |
| + break; |
| + } |
| + switch (description.historicalLigaturesState()) { |
| + case FontDescription::DisabledLigaturesState: |
| + m_features.append(noHlig); |
| + break; |
| + case FontDescription::EnabledLigaturesState: |
| + m_features.append(hlig); |
| + break; |
| + case FontDescription::NormalLigaturesState: |
| + break; |
| + } |
| + } |
| + |
| FontFeatureSettings* settings = description.featureSettings(); |
| if (!settings) |
| return; |
| @@ -687,7 +759,7 @@ bool HarfBuzzShaper::shapeHarfBuzzRuns(bool shouldSetDirection) |
| if (m_font->fontDescription().orientation() == Vertical) |
| face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get()); |
| - HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_destroy); |
| + HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(m_font->typesettingFeatures()), hb_font_destroy); |
| hb_shape(harfBuzzFont.get(), harfBuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size()); |
| currentRun->applyShapeResult(harfBuzzBuffer.get()); |