Commit 2e497632 authored by Jonah Chin's avatar Jonah Chin Committed by Commit Bot

Reland: Remove rounding to allow finer font weight granularity.

Patch that fixes the win7 error that happened in previous CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1496534

Should complete this revert first:
https://chromium-review.googlesource.com/c/chromium/src/+/1538811

This is necessary in Windows since some fonts are not
limited to weights that are multiples of 100.

Eg. Segoe UI with a weight of 350 should match the
semilight font as opposed to the regular one.

Bug: 944301
Change-Id: I59e30d05be13bbfdc0bc06b82f2656f25ede525f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1538890
Commit-Queue: Jonah Chin <jochin@microsoft.com>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644399}
parent 7c4a2d84
......@@ -365,8 +365,8 @@ SkFontStyle FontDescription::SkiaFontStyle() const {
}
int skia_weight = SkFontStyle::kNormal_Weight;
if (Weight() >= 100 && Weight() <= 1000)
skia_weight = static_cast<int>(roundf(Weight() / 100) * 100);
if (Weight() >= MinWeightValue() && Weight() <= MaxWeightValue())
skia_weight = static_cast<int>(Weight());
return SkFontStyle(skia_weight, skia_width, slant);
}
......
......@@ -145,6 +145,10 @@ fast/harness/results.html [ WontFix ]
# Linux layout tests do not have a Myanmar fallback font.
[ Linux ] inspector-protocol/layout-fonts/fallback-myanmar.js [ WontFix ]
# Segoe UI matching is only relevant on Windows
[ Mac ] inspector-protocol/layout-fonts/font-weight-granularity-matching.js [ WontFix ]
[ Linux ] inspector-protocol/layout-fonts/font-weight-granularity-matching.js [ WontFix ]
# Tests in media/stable are only supposed to be run as virtual test (see virtual/stable/media).
media/stable [ WontFix ]
......
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<style>
.test {
font-family: Segoe UI;
font-size: 20pt;
}
#regular-weight {
font-weight: 400;
}
#semilight-weight {
font-weight: 350;
}
</style>
<div class="test">
<div id="regular-weight">Text should be in the regular Segoe UI font.</div>
<div id="semilight-weight">Text should be Segoe UI Semilight on Win10+, else Segoe UI Light.</div>
</div>
</html>
`);
var session = await page.createSession();
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.completeTest();
})
Text should be in the regular Segoe UI font.
#regular-weight:
"Segoe UI" : 44
Text should be Segoe UI Semilight on Win10+, else Segoe UI Light.
#semilight-weight:
"Segoe UI Semilight" : 65
Text should be in the regular Segoe UI font.
#regular-weight:
"Segoe UI" : 44
Text should be Segoe UI Semilight on Win10+, else Segoe UI Light.
#semilight-weight:
"Segoe UI Light" : 65
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