WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-205003-20191209172833.patch (text/plain), 8.24 KB, created by
Fujii Hironori
on 2019-12-09 00:28:34 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2019-12-09 00:28:34 PST
Size:
8.24 KB
patch
obsolete
>Subversion Revision: 253281 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 90a5cd7e694a0bfd7ea71236cd332189cb0dc205..c7fd74bbf4901f937f62522d781f73c3029c823b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2019-12-09 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [WinCairo] Add support of Unicode surrogate pair for simple texts >+ https://bugs.webkit.org/show_bug.cgi?id=205003 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ FontCache::systemFallbackForCharacters of Windows port was working >+ only for BMP because it's using GetFontUnicodeRanges API which >+ supports only BMP. Use GetCharacterPlacement API to get glyphs for >+ non-BMP. >+ >+ GlyphPage::fill of WinCairo port was working only for BMP because >+ it's using GetGlyphIndices API which supports only BMP. Use >+ GetCharacterPlacement API to get glyphs for non-BMP. >+ >+ This change can be tested by pixel tests, but WinCairo port >+ doesn't include -expected.png files yet. Tested manually. >+ >+ * platform/graphics/win/FontCacheWin.cpp: >+ (WebCore::currentFontContainsCharacterNonBMP): Added. >+ (WebCore::currentFontContainsCharacter): Changed to take a string >+ instead of a 16bit character. >+ (WebCore::FontCache::systemFallbackForCharacters): >+ * platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp: >+ (WebCore::GlyphPage::fill): Use GetCharacterPlacement for non-BMP. >+ > 2019-12-08 Ryosuke Niwa <rniwa@webkit.org> > > There should be one MicrotaskQueue per EventLoop >diff --git a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp >index 0a0dc12689c3959c9b34a380bad344b4ef9b6eae..68d48e876495a8267e758973f1de5abc2e1815f8 100644 >--- a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp >+++ b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp >@@ -183,8 +183,36 @@ static const Vector<DWORD, 4>& getCJKCodePageMasks() > return codePageMasks; > } > >-static bool currentFontContainsCharacter(HDC hdc, UChar character) >+static bool currentFontContainsCharacterNonBMP(HDC hdc, const UChar* str) > { >+ ASSERT(U_IS_LEAD(str[0]) && U_IS_TRAIL(str[1])); >+ >+ SCRIPT_CACHE sc = { }; >+ SCRIPT_FONTPROPERTIES fp = { }; >+ fp.cBytes = sizeof fp; >+ ScriptGetFontProperties(hdc, &sc, &fp); >+ ScriptFreeCache(&sc); >+ >+ wchar_t glyphs[2] = { }; >+ GCP_RESULTS gcpResults = { }; >+ gcpResults.lStructSize = sizeof gcpResults; >+ gcpResults.nGlyphs = 2; >+ gcpResults.lpGlyphs = glyphs; >+ GetCharacterPlacement(hdc, wcharFrom(str), 2, 0, &gcpResults, GCP_GLYPHSHAPE); >+ >+ if (gcpResults.nGlyphs != 1) >+ return false; >+ auto glyph = glyphs[0]; >+ return !(glyph == fp.wgBlank || glyph == fp.wgInvalid || glyph == fp.wgDefault); >+} >+ >+static bool currentFontContainsCharacter(HDC hdc, const UChar* str, size_t length) >+{ >+ ASSERT(length <= 2); >+ if (length == 2) >+ return currentFontContainsCharacterNonBMP(hdc, str); >+ UChar character = str[0]; >+ > static Vector<char, 512> glyphsetBuffer; > glyphsetBuffer.resize(GetFontUnicodeRanges(hdc, 0)); > GLYPHSET* glyphset = reinterpret_cast<GLYPHSET*>(glyphsetBuffer.data()); >@@ -213,14 +241,15 @@ static HFONT createMLangFont(IMLangFontLinkType* langFontLink, HDC hdc, DWORD co > > RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, IsForPlatformFont, PreferColoredFont, const UChar* characters, unsigned length) > { >- UChar character = characters[0]; > RefPtr<Font> fontData; > HWndDC hdc(0); > HFONT primaryFont = originalFontData->platformData().hfont(); > HGDIOBJ oldFont = SelectObject(hdc, primaryFont); > HFONT hfont = 0; >+ IMLangFontLinkType* langFontLink = getFontLinkInterface(); > >- if (IMLangFontLinkType* langFontLink = getFontLinkInterface()) { >+ if (length == 1 && langFontLink) { >+ UChar character = characters[0]; > // Try MLang font linking first. > DWORD codePages = 0; > if (SUCCEEDED(langFontLink->GetCharCodePages(character, &codePages))) { >@@ -236,7 +265,7 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr > // We asked about a code page that is not one of the code pages > // returned by MLang, so the font might not contain the character. > SelectObject(hdc, hfont); >- if (!currentFontContainsCharacter(hdc, character)) { >+ if (!currentFontContainsCharacter(hdc, characters, length)) { > DeleteObject(hfont); > hfont = 0; > } >@@ -287,7 +316,7 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr > GetTextFace(hdc, LF_FACESIZE, name); > familyName = String(name); > >- if (containsCharacter || currentFontContainsCharacter(hdc, character)) >+ if (containsCharacter || currentFontContainsCharacter(hdc, characters, length)) > break; > > if (!linkedFonts) >diff --git a/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp b/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp >index 38caa8b9d9b2cdb521fb53c97edd8d6045c21293..9fb415a5f48f3ce17cd24f84844d3a75eafabae1 100644 >--- a/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp >+++ b/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp >@@ -37,10 +37,7 @@ namespace WebCore { > > bool GlyphPage::fill(UChar* buffer, unsigned bufferLength) > { >- // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs. >- // We won't support this for now. >- if (bufferLength > GlyphPage::size) >- return false; >+ ASSERT(bufferLength == GlyphPage::size || bufferLength == 2 * GlyphPage::size); > > const Font& font = this->font(); > bool haveGlyphs = false; >@@ -49,17 +46,45 @@ bool GlyphPage::fill(UChar* buffer, unsigned bufferLength) > SaveDC(dc); > SelectObject(dc, font.platformData().hfont()); > >- WORD localGlyphBuffer[GlyphPage::size * 2]; >- DWORD result = GetGlyphIndices(dc, wcharFrom(buffer), bufferLength, localGlyphBuffer, GGI_MARK_NONEXISTING_GLYPHS); >- bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength; >- if (success) { >+ if (bufferLength == GlyphPage::size) { >+ WORD localGlyphBuffer[GlyphPage::size * 2]; >+ DWORD result = GetGlyphIndices(dc, wcharFrom(buffer), bufferLength, localGlyphBuffer, GGI_MARK_NONEXISTING_GLYPHS); >+ bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength; >+ >+ if (success) { >+ for (unsigned i = 0; i < GlyphPage::size; i++) { >+ Glyph glyph = localGlyphBuffer[i]; >+ if (glyph == 0xffff) >+ setGlyphForIndex(i, 0); >+ else { >+ setGlyphForIndex(i, glyph); >+ haveGlyphs = true; >+ } >+ } >+ } >+ } else { >+ SCRIPT_CACHE sc = { }; >+ SCRIPT_FONTPROPERTIES fp = { }; >+ fp.cBytes = sizeof fp; >+ ScriptGetFontProperties(dc, &sc, &fp); >+ ScriptFreeCache(&sc); >+ > for (unsigned i = 0; i < GlyphPage::size; i++) { >- Glyph glyph = localGlyphBuffer[i]; >- if (glyph == 0xffff) >- setGlyphForIndex(i, 0); >- else { >- setGlyphForIndex(i, glyph); >- haveGlyphs = true; >+ wchar_t glyphs[2] = { }; >+ GCP_RESULTS gcpResults = { }; >+ gcpResults.lStructSize = sizeof gcpResults; >+ gcpResults.nGlyphs = 2; >+ gcpResults.lpGlyphs = glyphs; >+ GetCharacterPlacement(dc, wcharFrom(buffer) + i * 2, 2, 0, &gcpResults, GCP_GLYPHSHAPE); >+ bool success = 1 == gcpResults.nGlyphs; >+ if (success) { >+ auto glyph = glyphs[0]; >+ if (glyph == fp.wgBlank || glyph == fp.wgInvalid || glyph == fp.wgDefault) >+ setGlyphForIndex(i, 0); >+ else { >+ setGlyphForIndex(i, glyph); >+ haveGlyphs = true; >+ } > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 205003
:
385134
| 385137