- Revision
- 191378
- Author
- fred.w...@free.fr
- Date
- 2015-10-21 00:05:21 -0700 (Wed, 21 Oct 2015)
Log Message
[FreeType] Add support for the USE_TYPO_METRICS flag
https://bugs.webkit.org/show_bug.cgi?id=150340
Reviewed by Martin Robinson.
Source/WebCore:
Test: fonts/use-typo-metrics-1.html
Make the FreeType backend use the typo metrics when the OS/2 USE_TYPO_METRICS flag is set.
Similar work should be done for other backends, see bug 131839.
* platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that's the case.
LayoutTests:
Add a test to verify that the line height of a font is calculated from the typo metrics when the OS/2 USE_TYPO_METRICS flag is set. Currently, the test only passes with the FreeType backend.
* fonts/lineheight5000-typolineheight2300.woff: Added.
* fonts/use-typo-metrics-1-expected.html: Added.
* fonts/use-typo-metrics-1.html: Added.
* platform/mac/TestExpectations: Mark as failing.
* platform/win/TestExpectations: Mark as failing.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (191377 => 191378)
--- trunk/LayoutTests/ChangeLog 2015-10-21 06:41:13 UTC (rev 191377)
+++ trunk/LayoutTests/ChangeLog 2015-10-21 07:05:21 UTC (rev 191378)
@@ -1,3 +1,18 @@
+2015-10-21 Frederic Wang <fred.w...@free.fr>
+
+ [FreeType] Add support for the USE_TYPO_METRICS flag
+ https://bugs.webkit.org/show_bug.cgi?id=150340
+
+ Reviewed by Martin Robinson.
+
+ Add a test to verify that the line height of a font is calculated from the typo metrics when the OS/2 USE_TYPO_METRICS flag is set. Currently, the test only passes with the FreeType backend.
+
+ * fonts/lineheight5000-typolineheight2300.woff: Added.
+ * fonts/use-typo-metrics-1-expected.html: Added.
+ * fonts/use-typo-metrics-1.html: Added.
+ * platform/mac/TestExpectations: Mark as failing.
+ * platform/win/TestExpectations: Mark as failing.
+
2015-10-20 Ryan Haddad <ryanhad...@apple.com>
Marking http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple.html as flaky on Yosemite
Added: trunk/LayoutTests/fonts/lineheight5000-typolineheight2300.woff (0 => 191378)
--- trunk/LayoutTests/fonts/lineheight5000-typolineheight2300.woff (rev 0)
+++ trunk/LayoutTests/fonts/lineheight5000-typolineheight2300.woff 2015-10-21 07:05:21 UTC (rev 191378)
@@ -0,0 +1,17 @@
+wOFFOTTOT
+CFF \xF4\xDF(\x89\xC9 6FFTM\xD4v\xC5\x86OS/2\xF0D`!\xD5'cmap4EJ\x93\xA9head|06\x8Dh\xB7hhea\xAC$+\xAD+\xAFhmtx\xC8
+
+\xD0maxp\xD4Pname\xDC]\xE4\xE7}\xAB\xE0post< \xFF\x863x\x9Ccd`aa`ddTO\xCB\xCF+\xD1\xCD\xC9\xCCK\xCDH\xCDL\xCF(1500\xD0-\xA9,\xC8G002102\xE8\xFD\xE0g\xF8!\xCD\xF8C\x86\xE9\x87,\xF3 \x96\xC6\xEE\xDF1\xBFj~na\x95ax\xC8/\xC3\xC0 \xC3\xF0LP\x86\x81O\x86QJ\x88\x81\xA4G\x8D\xC1\x87\xA1\xC89\xBF\xA0\xB2d\x96\x82F\xB2\xA6\x82\x91\x81\xA1\xA9\x82obI\x86\xAF\x8F\x82cqq~rfbIf~q.!ҽ@\xC0\xC8`\xC0\xC0\xCCȨ\xA4\xAC\xF7\x87\xEB^ƽ{n\xD9˼W\xEC\x97ď\x95\xFF$\xD8\xF6\xFE)\xFD\xE1\xFAs\xCBWv>\xBE\xDF1,\xBFj~\xD5\xFC\xABa\xE7\xFBU#\xD2-Z>\xFF\xE7\x96n\xB6n.\x8Elc[x\x9Cc```d\x82Kvo\xB8\xC1\xB4\xB3\xD0^+?\x8E\xD1x\x9Cc`a~\xC18\x81\x81\x95\x81\x81\xA9\x8BiC\x84f|\xC0`\xC8\xC8e`\xE5d\x80Ft\xD0\xC0\xA0\xC0\xE0Ϭ\xF0߂U\x84\xF3\xE7\x84fd:\xFD
+-x\x9Cc```f\x80`Fp\xF2\xC1|+ \xCD\xA4\x98\xFC\xFF\xFF\xF2\xC1\xF4\xFF\x87\xFF7C\xD5#\x82\x83\x92GL\xA4)x 9x\x9Cc`d``⠖7\xF1\xFC6_\xB8\x99_E.9\xEDE\xD0\xFF-\x98_0+\xB9L Q3\xA2
+\x89x\x9Cc`d`\xE0<\xC2y\x84\x81\x81\xF9\x98dd@LX\xE2u\xE8\xE8Px\x9CŒ?N\xC30ş\xD3?\xB0\xB2\x99\x81\xAAJ\xE5\xA4\xCAҭT\xEAP%k\xF7\xAAJ\x93HU\%^rF\x8E\x828\x823p+^C\x87J\x8D\x95\xF8g\xE7\xBD\xEF\xB3?\xC05^!\xD0=\x88\x8C\xF0\xEE\xD8ýxt\xDC\xC3R|:\xEEc\xE4e\x8E\xB8\xF5\xDE1\xEA\xDDP)\xFAW\xAD\xAD\xABe\xC1\xE8\x95cO\xF8r\xDCóH\xF7{w\x8E\x90ދ\xE3!\xE7?\xB0\x84\xC6+\xA3Ȑ\xC3@b\x8C&\xECC(\x88H \xB6\xFC\x93\xB3\x8F9Z\xA0f\xD3Tv\xBE \x97\xC0R\x9B\xAA\xC8r#ǻ\x89U\xC9dk\xF2$\x96\x8B\xBAֻbk
+M\xD9ު+|\xE8,\x912n\xFA\x9B=bζ\xF9\xE4\x86+\xD3\xFF\xAAB̬
+{]\xFFP\x94i\x9E\xB6\x99#\xA5\x94o\x9A\xA3\xFE\x9B
+g\x8A\xBA3\xA4:!\xCB\xCAm\xAD\xED+\xFAS[\xC4)\xDDs\xBE\xE7\xDCz1\xE0\xC8\xE7\xB7u\xFDV,\xCAJWY*é\x92syZ\x91(f~\xA0\xFC\xF6\xE4.tL\x9A+ޭ\xEEFIkl\xBB-c\x93V5o\x91T*\x982\x88\xBC\xCC:\xBF{\xBFfx\x9Cc`f\x83\xFF\xCDF@\x8A\x91+(U\xB9
\ No newline at end of file
Added: trunk/LayoutTests/fonts/use-typo-metrics-1-expected.html (0 => 191378)
--- trunk/LayoutTests/fonts/use-typo-metrics-1-expected.html (rev 0)
+++ trunk/LayoutTests/fonts/use-typo-metrics-1-expected.html 2015-10-21 07:05:21 UTC (rev 191378)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<meta charset="utf-8"/>
+<title>Open Font Format: USE_TYPO_METRICS (reference)</title>
+<style>
+ #green {
+ position: absolute;
+ background: green;
+ left: 10px;
+ width: 230px;
+ height: 230px;
+ }
+</style>
+<body>
+ <p>Test passes if there is a green square and no red.</p>
+
+ <div>
+ <div id="green"></div>
+ </div>
+</body>
Property changes on: trunk/LayoutTests/fonts/use-typo-metrics-1-expected.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:eol-style
Added: trunk/LayoutTests/fonts/use-typo-metrics-1.html (0 => 191378)
--- trunk/LayoutTests/fonts/use-typo-metrics-1.html (rev 0)
+++ trunk/LayoutTests/fonts/use-typo-metrics-1.html 2015-10-21 07:05:21 UTC (rev 191378)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<meta charset="utf-8"/>
+<title>Open Font Format: USE_TYPO_METRICS</title>
+<link rel="help" href=""
+<link rel="match" href=""
+<style>
+ @font-face {
+ font-family: TestFont;
+ src: url("lineheight5000-typolineheight2300.woff");
+ }
+ .green {
+ position: absolute;
+ background: green;
+ width: 115px;
+ }
+ .red {
+ position: absolute;
+ background: red;
+ width: 115px;
+ }
+ .forceHeight {
+ height: 230px;
+ }
+ .leftSide {
+ left: 10px;
+ }
+ .rightSide {
+ left: 125px;
+ }
+ span {
+ /* em=1000, lineHeight=5000, typoLineHeight=2300 and font-size=100px
+ implies typoLineHeightPx = 230px < 500px = lineHeightPx */
+ font-family: TestFont;
+ font-size: 100px;
+ color: transparent;
+ }
+</style>
+<body>
+ <p>Test passes if there is a green square and no red.</p>
+
+ <div>
+ <!-- Left side verifies that typoLineHeightPx <= 230px -->
+ <div class="leftSide red"><span>O</span></div>
+ <div class="leftSide green forceHeight"></div>
+
+ <!-- Right side verifies that typoLineHeightPx => 230px -->
+ <div class="rightSide red forceHeight"></div>
+ <div class="rightSide green"><span>O</span></div>
+ </div>
+</body>
Property changes on: trunk/LayoutTests/fonts/use-typo-metrics-1.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:eol-style
Modified: trunk/LayoutTests/platform/mac/TestExpectations (191377 => 191378)
--- trunk/LayoutTests/platform/mac/TestExpectations 2015-10-21 06:41:13 UTC (rev 191377)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2015-10-21 07:05:21 UTC (rev 191378)
@@ -1348,3 +1348,6 @@
# Imported Blink tests which have not been investigated.
imported/blink/compositing/video/video-controls-layer-creation-squashing.html [ Pass ImageOnlyFailure ]
+
+# USE_TYPO_METRICS is not implemented on mac.
+webkit.org/b/131839 fonts/use-typo-metrics-1.html [ Failure ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (191377 => 191378)
--- trunk/LayoutTests/platform/win/TestExpectations 2015-10-21 06:41:13 UTC (rev 191377)
+++ trunk/LayoutTests/platform/win/TestExpectations 2015-10-21 07:05:21 UTC (rev 191378)
@@ -3263,4 +3263,7 @@
webkit.org/b/150040 js/dom/dfg-custom-getter.html [ Failure ]
# The following tests are not relevant on the Windows platform:
-fast/forms/hidpi-textfield-background-bleeding.html [ Skip ]
\ No newline at end of file
+fast/forms/hidpi-textfield-background-bleeding.html [ Skip ]
+
+# USE_TYPO_METRICS is not implemented on the Windows platform
+webkit.org/b/131839 fonts/use-typo-metrics-1.html [ Failure ]
Modified: trunk/Source/WebCore/ChangeLog (191377 => 191378)
--- trunk/Source/WebCore/ChangeLog 2015-10-21 06:41:13 UTC (rev 191377)
+++ trunk/Source/WebCore/ChangeLog 2015-10-21 07:05:21 UTC (rev 191378)
@@ -1,3 +1,18 @@
+2015-10-21 Frederic Wang <fred.w...@free.fr>
+
+ [FreeType] Add support for the USE_TYPO_METRICS flag
+ https://bugs.webkit.org/show_bug.cgi?id=150340
+
+ Reviewed by Martin Robinson.
+
+ Test: fonts/use-typo-metrics-1.html
+
+ Make the FreeType backend use the typo metrics when the OS/2 USE_TYPO_METRICS flag is set.
+ Similar work should be done for other backends, see bug 131839.
+
+ * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+ (WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that's the case.
+
2015-10-20 Hunseop Jeong <hs85.je...@samsung.com>
Replace 0 and NULL with nullptr in WebCore/loader.
Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (191377 => 191378)
--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2015-10-21 06:41:13 UTC (rev 191377)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2015-10-21 07:05:21 UTC (rev 191378)
@@ -65,6 +65,21 @@
float capHeight = narrowPrecisionToFloat(fontExtents.height);
float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent);
+ // If the USE_TYPO_METRICS flag is set in the OS/2 table then we use typo metrics instead.
+ FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
+ if (TT_OS2* OS2Table = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2))) {
+ const FT_Short kUseTypoMetricsMask = 1 << 7;
+ if (OS2Table->fsSelection & kUseTypoMetricsMask) {
+ // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
+ // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
+ double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
+ ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
+ descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
+ lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
+ }
+ }
+ cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
+
m_fontMetrics.setAscent(ascent);
m_fontMetrics.setDescent(descent);
m_fontMetrics.setCapHeight(capHeight);