https://bugs.webkit.org/show_bug.cgi?id=150451
Reviewed by Darin Adler.
Source/WebCore:
Make the Windows backend use the typo metrics when the OS/2 USE_TYPO_METRICS flag is set.
No new tests because this is already tested by fonts/use-typo-metrics-1.html
* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::Font::platformInit):
* platform/graphics/win/SimpleFontDataCairoWin.cpp:
(WebCore::Font::platformInit):
* platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::Font::initGDIFont):
LayoutTests:
Remove failure expectation for fonts/use-typo-metrics-1.html on Windows.
* platform/win/TestExpectations:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191893
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-11-02 Frederic Wang <fred.wang@free.fr>
+
+ [Win] Add support for the USE_TYPO_METRICS flag
+ https://bugs.webkit.org/show_bug.cgi?id=150451
+
+ Reviewed by Darin Adler.
+
+ Remove failure expectation for fonts/use-typo-metrics-1.html on Windows.
+
+ * platform/win/TestExpectations:
+
2015-11-02 Ryan Haddad <ryanhaddad@apple.com>
Marking the following tests as flaky on win
# The following tests are not relevant on the Windows platform:
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 [ ImageOnlyFailure ]
-
# [Win] Newly imported W3C XMLHttpRequest tests failing
webkit.org/b/150594 imported/w3c/web-platform-tests/XMLHttpRequest/send-conditional.htm [ Pass Failure ]
webkit.org/b/150594 imported/w3c/web-platform-tests/XMLHttpRequest/send-data-unexpected-tostring.htm [ Pass Failure ]
+2015-11-02 Frederic Wang <fred.wang@free.fr>
+
+ [Win] Add support for the USE_TYPO_METRICS flag
+ https://bugs.webkit.org/show_bug.cgi?id=150451
+
+ Reviewed by Darin Adler.
+
+ Make the Windows backend use the typo metrics when the OS/2 USE_TYPO_METRICS flag is set.
+
+ No new tests because this is already tested by fonts/use-typo-metrics-1.html
+
+ * platform/graphics/win/SimpleFontDataCGWin.cpp:
+ (WebCore::Font::platformInit):
+ * platform/graphics/win/SimpleFontDataCairoWin.cpp:
+ (WebCore::Font::platformInit):
+ * platform/graphics/win/SimpleFontDataWin.cpp:
+ (WebCore::Font::initGDIFont):
+
2015-11-02 Hyunduk Kim <hyunduk.kim@samsung.com>
Enable MediaSource::isTypeSupported() to handle the upper-cased MIME type & Codec
#include "FontDescription.h"
#include "GlyphPage.h"
#include "HWndDC.h"
+#include "OpenTypeTypes.h"
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#include <mlang.h>
int iDescent = CGFontGetDescent(font);
int iLineGap = CGFontGetLeading(font);
int iCapHeight = CGFontGetCapHeight(font);
+
+ // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
+ // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font."
+ if (CFDataRef os2Table = CGFontCopyTableForTag(m_platformData.cgFont(), 'OS/2')) {
+ // For the structure of the OS/2 table, see
+ // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html
+ const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1;
+ const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2;
+ const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2;
+ const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2;
+ if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) {
+ const UInt8* os2Data = CFDataGetBytePtr(os2Table);
+ const unsigned short useTypoMetricsMask = 1 << 7;
+ if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) {
+ iAscent = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset));
+ iDescent = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset));
+ iLineGap = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset));
+ }
+ }
+ CFRelease(os2Table);
+ }
+
unsigned unitsPerEm = CGFontGetUnitsPerEm(font);
float pointSize = m_platformData.size();
float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
cairo_win32_scaled_font_select_font(scaledFont, dc);
- TEXTMETRIC textMetrics;
- GetTextMetrics(dc, &textMetrics);
- float ascent = textMetrics.tmAscent * metricsMultiplier;
- float descent = textMetrics.tmDescent * metricsMultiplier;
+ OUTLINETEXTMETRIC metrics;
+ GetOutlineTextMetrics(dc, sizeof(metrics), &metrics);
+ TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
+ float ascent, descent, lineGap;
+ // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
+ // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font."
+ const UINT useTypoMetricsMask = 1 << 7;
+ if (metrics.otmfsSelection & useTypoMetricsMask) {
+ ascent = metrics.otmAscent * metricsMultiplier;
+ descent = metrics.otmDescent * metricsMultiplier;
+ lineGap = metrics.otmLineGap * metricsMultiplier;
+ } else {
+ ascent = textMetrics.tmAscent * metricsMultiplier;
+ descent = textMetrics.tmDescent * metricsMultiplier;
+ lineGap = textMetrics.tmExternalLeading * metricsMultiplier;
+ }
float xHeight = ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
- float lineGap = textMetrics.tmExternalLeading * metricsMultiplier;
int faceLength = ::GetTextFace(dc, 0, 0);
Vector<WCHAR> faceName(faceLength);
OUTLINETEXTMETRIC metrics;
GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
- float ascent = textMetrics.tmAscent;
- float descent = textMetrics.tmDescent;
- float lineGap = textMetrics.tmExternalLeading;
+ float ascent, descent, lineGap;
+ // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
+ // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font."
+ const UINT useTypoMetricsMask = 1 << 7;
+ if (metrics.otmfsSelection & useTypoMetricsMask) {
+ ascent = metrics.otmAscent;
+ descent = metrics.otmDescent;
+ lineGap = metrics.otmLineGap;
+ } else {
+ ascent = textMetrics.tmAscent;
+ descent = textMetrics.tmDescent;
+ lineGap = textMetrics.tmExternalLeading;
+ }
m_fontMetrics.setAscent(ascent);
m_fontMetrics.setDescent(descent);
m_fontMetrics.setLineGap(lineGap);