Commit 6fc06205 authored by eae@chromium.org's avatar eae@chromium.org

Implement support for CSS font-stretch on Windows

Implement support for the CSS font-stretch property on platforms using
SkFontMgr. This allows the width/stretch of a given font to be specified
and matches the IE and Firefox implementations.

Currently SkFontMgr is only used on Windows however as other platforms
migrate to SkFontMgr they'll get this support for free.

Entry in Chromium Dashboard:
  http://www.chromestatus.com/admin/features/edit/4598830058176512

Intent to Implement and Ship:
  https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/N24I2zJemvI/ZClPu585uAsJ
  
TEST=fast/text/font-stretch.html
BUG=331119
R=dglazkov@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@180305 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 22fb33c9
......@@ -987,6 +987,9 @@ crbug.com/386567 virtual/regionbasedmulticol/fast/multicol/vertical-rl/rule-styl
crbug.com/386567 virtual/regionbasedmulticol/fast/multicol/vertical-rl/rules-with-border-before.html [ Skip ]
crbug.com/386567 virtual/regionbasedmulticol/fast/multicol/vertical-rl/unsplittable-inline-block.html [ Skip ]
Bug(eae) fast/text/font-stretch.html [ NeedsRebaseline ]
Bug(eae) virtual/antialiasedtext/fast/text/font-stretch.html [ NeedsRebaseline ]
# Fails on Mac in region based multicol implementation.
crbug.com/391223 [ Mac ] virtual/regionbasedmulticol/fast/multicol/multicol-with-child-renderLayer-for-input.html [ ImageOnlyFailure ]
......
<!DOCTYPE html>
<html>
<head>
<title>Tests support for font-stretch</title>
<style>
p { font-size: 14px; margin: 0; }
h1 { font-size: 20px; margin: 8px 0 2px 0; }
h2 { font-size: 16px; margin: 8px 0 2px 0; }
.segoe { font-family: 'Segoe UI'; }
.arial { font-family: Arial; }
p > span { display: inline-block; width: 30ex; }
</style>
</head>
<body>
<h1>Tests support for font-stretch</h1>
<p>
Tests that CSS font-stretch is supported.
</p>
<section class="segoe">
<h2>Segoe UI</h2>
<p style="font-stretch: ultra-condensed"><span>font-stretch: ultra-condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: extra-condensed"><span>font-stretch: extra-condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: condensed"><span>font-stretch: condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: semi-condensed"><span>font-stretch: semi-condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: normal"><span>font-stretch: normal</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: semi-expanded"><span>font-stretch: semi-expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: expanded"><span>font-stretch: expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: extra-expanded"><span>font-stretch: extra-expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: ultra-expanded"><span>font-stretch: ultra-expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
</section>
<section class="arial">
<h2>Arial</h2>
<p style="font-stretch: ultra-condensed"><span>font-stretch: ultra-condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: extra-condensed"><span>font-stretch: extra-condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: condensed"><span>font-stretch: condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: semi-condensed"><span>font-stretch: semi-condensed</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: normal"><span>font-stretch: normal</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: semi-expanded"><span>font-stretch: semi-expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: expanded"><span>font-stretch: expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: extra-expanded"><span>font-stretch: extra-expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
<p style="font-stretch: ultra-expanded"><span>font-stretch: ultra-expanded</span> - Just poets wax boldly as kings and queens march over fuzz.</p>
</section>
</body>
</html>
......@@ -167,13 +167,20 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
#if OS(WIN)
static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
{
int width = SkFontStyle::kNormal_Width;
int width = static_cast<int>(fontDescription.stretch());
int weight = (fontDescription.weight() - FontWeight100 + 1) * 100;
SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic
? SkFontStyle::kItalic_Slant
: SkFontStyle::kUpright_Slant;
return SkFontStyle(weight, width, slant);
}
COMPILE_ASSERT(FontStretchUltraCondensed == SkFontStyle::kUltraCondensed_Width,
FontStretchUltraCondensedMapsTokUltraCondensed_Width);
COMPILE_ASSERT(FontStretchNormal == SkFontStyle::kNormal_Width,
FontStretchNormalMapsTokNormal_Width);
COMPILE_ASSERT(FontStretchUltraExpanded == SkFontStyle::kUltaExpanded_Width,
FontStretchUltraExpandedMapsTokUltaExpanded_Width);
#endif
PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name)
......
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