Commit 7a578776 authored by eae@chromium.org's avatar eae@chromium.org

Implement support for numeric font-weights on Windows

Implement support for numeric font-weights (i.e. 100..900) on platforms
using SkFontMgr by switching to the new matchFamilyStyle API instead of
the old legacyCreateTypeface one.

Currently SkFontMgr is only used on Windows.

R=dglazkov@chromium.org
BUG=394692
TEST=fast/text/font-weight.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@180279 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2b17ad0c
......@@ -445,6 +445,9 @@ crbug.com/271243 [ Win ] http/tests/misc/acid3.html [ Failure ]
crbug.com/278497 [ Mac Win ] http/tests/security/contentSecurityPolicy/1.1/plugintypes-invalid.html [ Failure Pass ]
crbug.com/394692 fast/text/font-weight.html [ NeedsRebaseline ]
crbug.com/394692 virtual/antialiasedtext/fast/text/font-weight.html [ NeedsRebaseline ]
crbug.com/280342 [ Linux Win ] http/tests/media/progress-events-generated-correctly.html [ Failure Pass ]
crbug.com/282081 [ Debug ] http/tests/security/contentSecurityPolicy/report-only-from-header.php [ Crash Pass ]
crbug.com/282081 [ Win Release ] http/tests/security/contentSecurityPolicy/report-only-from-header.php [ Pass Timeout ]
......@@ -685,6 +688,34 @@ crbug.com/345649 fast/repaint/delete-into-nested-block.html [ Pass Failure ]
crbug.com/345648 fast/repaint/selection-gap-overflow-scroll.html [ Pass Failure ]
crbug.com/345646 fast/repaint/selection-after-remove.html [ Pass Failure ]
crbug.com/394692 css1/font_properties/font.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_position-table-row-group.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_position-table-column-group.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table-column.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_position-table-row.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table-row.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_position-table-cell.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_layers-show.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_position-table-column.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_fixed-bg.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table-row-group.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table-column-group.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_layers-hide.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table-cell.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla_expected_failures/marvin/backgr_border-table-quirks.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_position-table.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_simple-table.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_simple-table-cell.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_simple-table-column-group.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_simple-table-column.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_simple-table-row.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_layers-opacity.html [ NeedsRebaseline ]
crbug.com/394692 tables/mozilla/marvin/backgr_simple-table-row-group.html [ NeedsRebaseline ]
crbug.com/394692 fast/css/invalidation-errors-2.html [ NeedsRebaseline ]
crbug.com/394692 fast/css/invalidation-errors.html [ NeedsRebaseline ]
crbug.com/394692 css2.1/t1508-c527-font-04-b.html [ NeedsRebaseline ]
crbug.com/345767 fast/repaint/selection-gap-overflow-scroll-2.html [ Pass Failure ]
crbug.com/334152 w3c/web-platform-tests/shadow-dom/elements-and-dom-objects/the-shadow-html-element/test-001.html [ Failure ]
......
<!DOCTYPE html>
<html>
<head>
<title>Tests support for font-weight</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; }
</style>
</head>
<body>
<h1>Tests support for font-weight</h1>
<p>
Tests that CSS font-weight with numeric values is supported.
</p>
<section class="segoe">
<h2>Segoe UI</h2>
<p style="font-weight: 100">font-weight: 100 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 200">font-weight: 200 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 300">font-weight: 300 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 400">font-weight: 400 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 500">font-weight: 500 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 600">font-weight: 600 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 700">font-weight: 700 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 800">font-weight: 800 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 900">font-weight: 900 - Fix problem quickly with galvanized jets.</p>
</section>
<section class="arial">
<h2>Arial</h2>
<p style="font-weight: 100">font-weight: 100 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 200">font-weight: 200 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 300">font-weight: 300 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 400">font-weight: 400 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 500">font-weight: 500 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 600">font-weight: 600 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 700">font-weight: 700 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 800">font-weight: 800 - Fix problem quickly with galvanized jets.</p>
<p style="font-weight: 900">font-weight: 900 - Fix problem quickly with galvanized jets.</p>
</section>
</body>
</html>
......@@ -164,6 +164,18 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
}
#if OS(WIN)
static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
{
int width = SkFontStyle::kNormal_Width;
int weight = (fontDescription.weight() - FontWeight100 + 1) * 100;
SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic
? SkFontStyle::kItalic_Slant
: SkFontStyle::kUpright_Slant;
return SkFontStyle(weight, width, slant);
}
#endif
PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name)
{
#if !OS(WIN) && !OS(ANDROID)
......@@ -201,16 +213,22 @@ PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc
#if OS(WIN)
if (s_sideloadedFonts) {
HashMap<String, SkTypeface*>::iterator sideloadedFont = s_sideloadedFonts->find(name.data());
if (sideloadedFont != s_sideloadedFonts->end()) {
HashMap<String, SkTypeface*>::iterator sideloadedFont =
s_sideloadedFonts->find(name.data());
if (sideloadedFont != s_sideloadedFonts->end())
return adoptRef(sideloadedFont->value);
}
}
// FIXME: Use SkFontStyle and matchFamilyStyle instead of legacyCreateTypeface.
if (m_fontManager)
return adoptRef(m_fontManager->legacyCreateTypeface(name.data(), style));
if (m_fontManager) {
return adoptRef(useDirectWrite()
? m_fontManager->matchFamilyStyle(name.data(), fontStyle(fontDescription))
: m_fontManager->legacyCreateTypeface(name.data(), style)
);
}
#endif
// FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of
// CreateFromName on all platforms.
return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypeface::Style>(style)));
}
......
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