Commit b312644a authored by h.joshi@samsung.com's avatar h.joshi@samsung.com

Fix handling of Ligature when letter-spacing is present.

Blink is applying ligature feature when letter spacing is specified which is not correct as per the CSS
specification [1].

With this patch ligature is not applied when letter spacing is specified in CSS.

BUG=382381
TEST=fast/text/font-ligature-letter-spacing.html

1: http://dev.w3.org/csswg/css-text-3/#letter-spacing-property

Review URL: https://codereview.chromium.org/325673002

git-svn-id: svn://svn.chromium.org/blink/trunk@176539 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent a228db4f
CACACACA
CACACACA
This is a testharness.js-based test.
PASS Ligature expected not to be applied due to letter spacing.
Harness: the test ran to completion.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Letter spacing and Ligature</title>
<style type="text/css">
@font-face {
font-family: megalopolis;
src: url(../../third_party/MEgalopolis/MEgalopolisExtra.woff) format("woff");
}
.dligDiv {
-moz-font-feature-settings:"frac" 1, "dlig" 1;
-moz-font-feature-settings:"frac=1, dlig=1";
-ms-font-feature-settings:"frac" 1, "dlig" 1;
-o-font-feature-settings:"frac" 1, "dlig" 1;
-webkit-font-feature-settings:"frac" 1, "dlig" 1;
font-feature-settings:"frac" 1, "dlig" 1;
}
.common {
font-size: 24px;
line-height: 100%;
padding: 0px;
letter-spacing:20px;
font-family: megalopolis;
}
p { font-family: serif; font-style: italic; }
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
setup({ explicit_done: true });
function testLetterSpaceAndLigature() {
var elementWidthWithLigatureAndLetterSpacing = document.getElementsByClassName("dligSpan")[0].getBoundingClientRect().width;
var elementWidthWithLetterSpacing = document.getElementsByClassName("letterSpace")[0].getBoundingClientRect().width;
test(function() {
assert_equals(elementWidthWithLigatureAndLetterSpacing, elementWidthWithLetterSpacing, "Ligature not applied due to letter spacing.");
}, "Ligature expected not to be applied due to letter spacing.");
done();
}
</script>
</head>
<body onload="testLetterSpaceAndLigature();">
<div class="dligDiv common">
<span class="dligSpan">CACACACA</span>
</div>
<div class="common">
<span class="letterSpace">CACACACA</span>
</div>
</body>
</html>
......@@ -250,7 +250,7 @@ CodePath Font::codePath(const TextRun& run) const
return SimplePath;
#endif
if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings()->size() > 0)
if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings()->size() > 0 && m_fontDescription.letterSpacing() == 0)
return ComplexPath;
if (run.length() > 1 && !WidthIterator::supportsTypesettingFeatures(*this))
......
......@@ -182,21 +182,27 @@ void FontDescription::updateTypesettingFeatures() const
break;
}
switch (commonLigaturesState()) {
case FontDescription::DisabledLigaturesState:
m_typesettingFeatures &= ~Ligatures;
break;
case FontDescription::EnabledLigaturesState:
m_typesettingFeatures |= Ligatures;
break;
case FontDescription::NormalLigaturesState:
break;
}
if (discretionaryLigaturesState() == FontDescription::EnabledLigaturesState
|| historicalLigaturesState() == FontDescription::EnabledLigaturesState
|| contextualLigaturesState() == FontDescription::EnabledLigaturesState) {
m_typesettingFeatures |= WebCore::Ligatures;
// As per CSS (http://dev.w3.org/csswg/css-text-3/#letter-spacing-property),
// When the effective letter-spacing between two characters is not zero (due to
// either justification or non-zero computed letter-spacing), user agents should
// not apply optional ligatures.
if (m_letterSpacing == 0) {
switch (commonLigaturesState()) {
case FontDescription::DisabledLigaturesState:
m_typesettingFeatures &= ~Ligatures;
break;
case FontDescription::EnabledLigaturesState:
m_typesettingFeatures |= Ligatures;
break;
case FontDescription::NormalLigaturesState:
break;
}
if (discretionaryLigaturesState() == FontDescription::EnabledLigaturesState
|| historicalLigaturesState() == FontDescription::EnabledLigaturesState
|| contextualLigaturesState() == FontDescription::EnabledLigaturesState) {
m_typesettingFeatures |= WebCore::Ligatures;
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment