Changeset 251900 in webkit
- Timestamp:
- Oct 31, 2019 5:53:49 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251896 r251900 1 2019-10-31 Brent Fulgham <bfulgham@apple.com> 2 3 [FTW] Adopt DirectWrite in place of Uniscribe 4 https://bugs.webkit.org/show_bug.cgi?id=203548 5 <rdar://problem/56695130> 6 7 Reviewed by Fujii Hironori. 8 9 This patch switches from the Uniscribe text controller to a 10 DirectWrite based ComplexTextController. 11 12 * PlatformFTW.cmake: 13 * platform/graphics/ComplexTextController.cpp: 14 (WebCore::ComplexTextController::ComplexTextController): Treat Windows 15 like any other ComplexTextController platform. 16 * platform/graphics/Font.cpp: 17 (WebCore::Font::platformGlyphInit): Add hack for DirectWrite 18 zero-width space handling. 19 * platform/graphics/FontCascade.cpp: 20 (WebCore::FontCascade::widthOfTextRange const): Don't use Uniscribe. 21 * platform/graphics/FontPlatformData.h: 22 (WebCore::FontPlatformData::dwFontCollection const): 23 (WebCore::FontPlatformData::faceName const): 24 * platform/graphics/win/ComplexTextControllerDirectWrite.cpp: 25 (WebCore::shape): Added, 26 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): 27 Added. 28 * platform/graphics/win/DirectWriteUtilities.cpp: 29 (WebCore::DirectWrite::createWithPlatformFont): Modify to return a 30 pair of font and font collection. 31 (WebCore::DirectWrite::fontWeight): Added stub. 32 (WebCore::DirectWrite::fontStyle): Ditto. 33 (WebCore::DirectWrite::fontStretch): Ditto. 34 * platform/graphics/win/DirectWriteUtilities.h: 35 * platform/graphics/win/FontCustomPlatformData.cpp: 36 (WebCore::FontCustomPlatformData::fontPlatformData): Add more 37 information to help DirectWrite handle font styles. 38 * platform/graphics/win/FontPlatformDataDirect2D.cpp: 39 (WebCore::FontPlatformData::platformDataInit): 40 (WebCore::FontPlatformData::FontPlatformData): 41 (WebCore::FontPlatformData::createFallbackFont): Deleted. 42 * platform/graphics/win/FontWin.cpp: 43 * platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp: 44 (WebCore::GlyphPage::fill): Update to handle multiple runs in a 45 given string. 46 * platform/graphics/win/TextAnalyzerHelper.cpp: 47 (WebCore::TextAnalyzerHelper::TextAnalyzerHelper): Update to handle 48 analysis of strings with multiple runs. 49 (WebCore::TextAnalyzerHelper::SetScriptAnalysis): Ditto. 50 * platform/graphics/win/TextAnalyzerHelper.h: 51 1 52 2019-10-31 Tim Horton <timothy_horton@apple.com> 2 53 -
trunk/Source/WebCore/PlatformFTW.cmake
r251221 r251900 102 102 platform/graphics/win/TransformationMatrixDirect2D.cpp 103 103 platform/graphics/win/TransformationMatrixWin.cpp 104 platform/graphics/win/UniscribeController.cpp105 104 106 105 platform/network/win/CurlSSLHandleWin.cpp -
trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp
r248846 r251900 1 1 /* 2 * Copyright (C) 2007 , 2008, 2009, 2010, 2011Apple Inc. All rights reserved.2 * Copyright (C) 2007-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 44 44 namespace WebCore { 45 45 46 #if PLATFORM(WIN) 46 #if PLATFORM(WIN) && !USE(DIRECT2D) 47 47 48 48 class TextLayout { … … 62 62 ASSERT_NOT_REACHED(); 63 63 return 0; 64 } 65 66 void ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned, unsigned, const Font*) 67 { 68 ASSERT_NOT_REACHED(); 64 69 } 65 70 … … 147 152 , m_forTextEmphasis(forTextEmphasis) 148 153 { 149 #if PLATFORM(WIN)150 ASSERT_NOT_REACHED();151 #endif152 153 154 computeExpansionOpportunity(); 154 155 -
trunk/Source/WebCore/platform/graphics/Font.cpp
r248846 r251900 120 120 if (glyphPageSpace) 121 121 m_spaceGlyph = glyphPageSpace->glyphDataForCharacter(space).glyph; 122 float width = widthForGlyph(m_spaceGlyph);123 m_spaceWidth = width;124 122 if (glyphPageCharacterZero) 125 123 m_zeroGlyph = glyphPageCharacterZero->glyphDataForCharacter('0').glyph; 126 m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph));127 determinePitch();128 m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);129 124 130 125 // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE. … … 133 128 if (m_zeroWidthSpaceGlyph == m_spaceGlyph) 134 129 m_zeroWidthSpaceGlyph = 0; 130 131 float width = widthForGlyph(m_spaceGlyph); 132 m_spaceWidth = width; 133 m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph)); 134 determinePitch(); 135 m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width); 135 136 } 136 137 -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r248846 r251900 42 42 #include <wtf/text/StringBuilder.h> 43 43 44 #if PLATFORM(WIN) 44 #if PLATFORM(WIN) && !USE(DIRECT2D) 45 45 #include "UniscribeController.h" 46 46 #endif … … 351 351 auto codePathToUse = codePath(run); 352 352 if (codePathToUse == Complex) { 353 #if PLATFORM(WIN) 353 #if PLATFORM(WIN) && !USE(DIRECT2D) 354 354 UniscribeController it(this, run); 355 355 it.advance(from); … … 1398 1398 } 1399 1399 1400 #if !PLATFORM(WIN) 1400 #if !PLATFORM(WIN) || USE(DIRECT2D) 1401 1401 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const 1402 1402 { … … 1546 1546 } 1547 1547 1548 #if !PLATFORM(WIN) 1548 #if !PLATFORM(WIN) || USE(DIRECT2D) 1549 1549 float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 1550 1550 { … … 1579 1579 } 1580 1580 1581 #if !PLATFORM(WIN) 1581 #if !PLATFORM(WIN) || USE(DIRECT2D) 1582 1582 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const 1583 1583 { … … 1639 1639 } 1640 1640 1641 #if !PLATFORM(WIN) 1641 #if !PLATFORM(WIN) || USE(DIRECT2D) 1642 1642 int FontCascade::offsetForPositionForComplexText(const TextRun& run, float x, bool includePartialGlyphs) const 1643 1643 { -
trunk/Source/WebCore/platform/graphics/FontPlatformData.h
r248748 r251900 104 104 105 105 #if PLATFORM(WIN) && USE(DIRECT2D) 106 FontPlatformData(GDIObject<HFONT>&&, IDWriteFont*, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);106 FontPlatformData(GDIObject<HFONT>&&, COMPtr<IDWriteFont>&&, float size, bool syntheticBold, bool syntheticOblique, bool useGDI); 107 107 #endif 108 108 … … 144 144 IDWriteFont* dwFont() const { return m_dwFont.get(); } 145 145 IDWriteFontFace* dwFontFace() const { return m_dwFontFace.get(); } 146 147 static HRESULT createFallbackFont(const LOGFONT&, IDWriteFont**);148 static HRESULT createFallbackFont(HFONT, IDWriteFont**);149 146 #endif 150 147 -
trunk/Source/WebCore/platform/graphics/win/ComplexTextControllerDirectWrite.cpp
r211836 r251900 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #include "ComplexTextController.h" 27 27 28 #if USE(DIRECT2D) 29 30 #include "DirectWriteUtilities.h" 31 #include "FontCache.h" 32 #include "FontCascade.h" 33 #include "TextAnalyzerHelper.h" 34 #include <dwrite_3.h> 35 28 36 namespace WebCore { 29 37 30 void ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned, unsigned, const Font*)38 static bool shape(IDWriteTextAnalyzer* analyzer, const DWRITE_SCRIPT_ANALYSIS& analysis, const FontPlatformData& fontPlatformData, const WCHAR* text, unsigned length, unsigned suggestedCount, Vector<Glyph>& glyphs, Vector<Glyph>& clusterMap, Vector<DWRITE_SHAPING_TEXT_PROPERTIES>& textProperties, Vector<DWRITE_SHAPING_GLYPH_PROPERTIES>& glyphProperties, unsigned& glyphCount) 31 39 { 32 // FIXME: Implement this. 33 ASSERT_NOT_REACHED(); 40 HRESULT shapeResult = E_PENDING; 41 42 do { 43 shapeResult = analyzer->GetGlyphs(text, length, fontPlatformData.dwFontFace(), fontPlatformData.orientation() == FontOrientation::Vertical, false, 44 &analysis, nullptr, nullptr, nullptr, nullptr, 0, suggestedCount, clusterMap.data(), textProperties.data(), 45 glyphs.data(), glyphProperties.data(), &glyphCount); 46 47 if (shapeResult == E_OUTOFMEMORY) { 48 // Need to resize our buffers (except for clusterMap. It is always the length of the string). 49 glyphs.resize(glyphs.size() * 2); 50 textProperties.resize(glyphs.size()); 51 glyphProperties.resize(glyphs.size()); 52 } 53 } while (shapeResult == E_OUTOFMEMORY); 54 55 if (FAILED(shapeResult)) 56 return false; 57 58 return true; 59 } 60 61 void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp, unsigned length, unsigned stringLocation, const Font* font) 62 { 63 if (!font) { 64 // Create a run of missing glyphs from the primary font. 65 m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, 0, length, m_run.ltr())); 66 return; 67 } 68 69 auto& fontPlatformData = font->platformData(); 70 71 wchar_t localeName[LOCALE_NAME_MAX_LENGTH] = { }; 72 int localeLength = GetUserDefaultLocaleName(reinterpret_cast<LPWSTR>(&localeName), LOCALE_NAME_MAX_LENGTH); 73 RELEASE_ASSERT(localeLength < LOCALE_NAME_MAX_LENGTH); 74 75 Vector<DWRITE_FONT_FEATURE> fontFeatures(1); 76 fontFeatures[0].nameTag = DWRITE_FONT_FEATURE_TAG_KERNING; 77 fontFeatures[0].parameter = m_font.enableKerning() ? 1 : 0; 78 79 if (fontPlatformData.orientation() == FontOrientation::Vertical) 80 fontFeatures.append({DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING, 1}); 81 82 DWRITE_TYPOGRAPHIC_FEATURES usedFeatures; 83 usedFeatures.features = fontFeatures.data(); 84 usedFeatures.featureCount = fontFeatures.size(); 85 86 Vector<const DWRITE_TYPOGRAPHIC_FEATURES*> features; 87 features.append(&usedFeatures); 88 89 COMPtr<IDWriteTextAnalyzer> analyzer; 90 HRESULT hr = DirectWrite::factory()->CreateTextAnalyzer(&analyzer); 91 RELEASE_ASSERT(SUCCEEDED(hr)); 92 93 TextAnalyzerHelper helper(reinterpret_cast<LPWSTR>(&localeName), reinterpret_cast<LPCWSTR>(cp), length); 94 95 hr = analyzer->AnalyzeScript(&helper, 0, length, &helper); 96 RELEASE_ASSERT(SUCCEEDED(hr)); 97 98 unsigned totalSuggestedCount = (3 * length / 2 + 16); 99 100 Vector<Glyph> glyphs; 101 Vector<Glyph> clusterMap; 102 Vector<DWRITE_SHAPING_TEXT_PROPERTIES> textProperties; 103 Vector<DWRITE_SHAPING_GLYPH_PROPERTIES> glyphProperties; 104 Vector<FLOAT> glyphAdvances; 105 Vector<DWRITE_GLYPH_OFFSET> glyphOffsets; 106 Vector<FloatPoint> origins; 107 Vector<FloatSize> advances; 108 Vector<unsigned> stringIndices; 109 110 glyphs.reserveCapacity(totalSuggestedCount); 111 clusterMap.reserveCapacity(length); 112 textProperties.reserveCapacity(totalSuggestedCount); 113 glyphProperties.reserveCapacity(totalSuggestedCount); 114 glyphAdvances.reserveCapacity(totalSuggestedCount); 115 glyphOffsets.reserveCapacity(totalSuggestedCount); 116 origins.reserveCapacity(totalSuggestedCount); 117 advances.reserveCapacity(totalSuggestedCount); 118 stringIndices.reserveCapacity(totalSuggestedCount); 119 120 for (const auto& run : helper.m_analyzedRuns) { 121 const UChar* currentCP = cp + run.startPosition; 122 LPCWSTR textPosition = reinterpret_cast<LPCWSTR>(currentCP); 123 124 unsigned suggestedCount = (3 * run.length / 2 + 16); 125 glyphs.resize(suggestedCount); 126 clusterMap.resize(run.length); 127 textProperties.resize(suggestedCount); 128 glyphProperties.resize(suggestedCount); 129 130 unsigned glyphCount = 0; 131 if (!shape(analyzer.get(), run.analysis, fontPlatformData, textPosition, run.length, suggestedCount, glyphs, clusterMap, textProperties, glyphProperties, glyphCount)) 132 return; 133 134 glyphs.shrink(glyphCount); 135 textProperties.shrink(glyphCount); 136 glyphProperties.shrink(glyphCount); 137 glyphAdvances.resize(glyphCount); 138 glyphOffsets.resize(glyphCount); 139 140 HRESULT placementResult = analyzer->GetGlyphPlacements(textPosition, clusterMap.data(), textProperties.data(), run.length, 141 glyphs.data(), glyphProperties.data(), glyphCount, fontPlatformData.dwFontFace(), 142 fontPlatformData.size(), fontPlatformData.orientation() == FontOrientation::Vertical, m_run.ltr(), 143 &run.analysis, reinterpret_cast<LPCWSTR>(localeName), 144 features.data(), &run.length, 1, 145 glyphAdvances.data(), glyphOffsets.data()); 146 if (FAILED(placementResult)) 147 return; 148 149 // Convert all chars that should be treated as spaces to use the space glyph. 150 // We also create a map that allows us to quickly go from space glyphs back to their corresponding characters. 151 float spaceWidth = font->spaceWidth() - font->syntheticBoldOffset(); 152 153 for (int k = 0; k < run.length; ++k) { 154 UChar ch = *(currentCP + k); 155 bool treatAsSpace = FontCascade::treatAsSpace(ch); 156 bool treatAsZeroWidthSpace = FontCascade::treatAsZeroWidthSpace(ch); 157 if (treatAsSpace || treatAsZeroWidthSpace) { 158 // Substitute in the space glyph at the appropriate place in the glyphs 159 // array. 160 glyphs[clusterMap[k]] = font->spaceGlyph(); 161 glyphAdvances[clusterMap[k]] = treatAsSpace ? spaceWidth : 0; 162 } 163 } 164 165 origins.resize(glyphCount); 166 advances.resize(glyphCount); 167 stringIndices.resize(glyphCount); 168 169 for (size_t i = 0; i < glyphCount; ++i) { 170 stringIndices[i] = i; 171 origins[i] = FloatPoint(glyphOffsets[i].advanceOffset, glyphOffsets[i].ascenderOffset); 172 advances[i] = FloatSize(glyphAdvances[i], 0); 173 } 174 175 m_complexTextRuns.append(ComplexTextRun::create(advances, origins, glyphs, stringIndices, FloatSize(), *font, currentCP, 0, run.length, 0, run.length, m_run.ltr())); 176 } 34 177 } 35 178 36 179 } 180 181 #endif -
trunk/Source/WebCore/platform/graphics/win/DirectWriteUtilities.cpp
r248748 r251900 191 191 Vector<wchar_t> localeName(LOCALE_NAME_MAX_LENGTH); 192 192 int localeLength = GetUserDefaultLocaleName(localeName.data(), LOCALE_NAME_MAX_LENGTH); 193 194 COMPtr<IDWriteFontFamily> fontFamily = fontFamilyForCollection(systemFontCollection.get(), localeName, logFont); 195 if (!fontFamily) 196 fontFamily = fontFamilyForCollection(webProcessFontCollection(), localeName, logFont); 193 RELEASE_ASSERT(localeLength <= LOCALE_NAME_MAX_LENGTH); 194 195 COMPtr<IDWriteFontCollection1> collection(Query, systemFontCollection); 196 197 COMPtr<IDWriteFontFamily> fontFamily = fontFamilyForCollection(collection.get(), localeName, logFont); 198 if (!fontFamily) { 199 collection = webProcessFontCollection(); 200 fontFamily = fontFamilyForCollection(collection.get(), localeName, logFont); 201 } 197 202 198 203 if (!fontFamily) { 199 204 // Just return the first system font. 200 hr = systemFontCollection->GetFontFamily(0, &fontFamily); 205 collection = COMPtr<IDWriteFontCollection1>(Query, systemFontCollection); 206 hr = collection->GetFontFamily(0, &fontFamily); 201 207 if (FAILED(hr)) 202 208 return nullptr; … … 219 225 } 220 226 227 DWRITE_FONT_WEIGHT fontWeight(const FontPlatformData&) 228 { 229 return DWRITE_FONT_WEIGHT_REGULAR; 230 } 231 232 DWRITE_FONT_STYLE fontStyle(const FontPlatformData&) 233 { 234 return DWRITE_FONT_STYLE_NORMAL; 235 } 236 237 DWRITE_FONT_STRETCH fontStretch(const FontPlatformData&) 238 { 239 return DWRITE_FONT_STRETCH_NORMAL; 240 } 241 221 242 } // namespace DirectWrite 222 243 -
trunk/Source/WebCore/platform/graphics/win/DirectWriteUtilities.h
r248748 r251900 37 37 interface IDWriteGdiInterop; 38 38 39 enum DWRITE_FONT_WEIGHT; 40 enum DWRITE_FONT_STYLE; 41 enum DWRITE_FONT_STRETCH; 42 39 43 namespace WebCore { 40 44 45 class FontPlatformData; 41 46 class SharedBuffer; 42 47 … … 53 58 Vector<wchar_t> familyNameForLocale(IDWriteFontFamily*, const Vector<wchar_t>& localeName); 54 59 60 DWRITE_FONT_WEIGHT fontWeight(const FontPlatformData&); 61 DWRITE_FONT_STYLE fontStyle(const FontPlatformData&); 62 DWRITE_FONT_STRETCH fontStretch(const FontPlatformData&); 63 55 64 } // namespace DirectWrite 56 65 -
trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
r248846 r251900 54 54 ASSERT(m_fontReference); 55 55 56 auto faceName = m_name.charactersWithNullTermination(); 57 if (faceName.size() > LF_FACESIZE) { 58 faceName.resize(LF_FACESIZE); 59 faceName.last() = 0; 60 } 61 56 62 LOGFONT logFont { }; 57 memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination().data(), sizeof(logFont.lfFaceName[0]) * std::min<size_t>(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length()));63 memcpy(logFont.lfFaceName, faceName.data(), sizeof(logFont.lfFaceName[0]) * std::min<size_t>(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length())); 58 64 59 65 logFont.lfHeight = -size; … … 81 87 return FontPlatformData(WTFMove(hfont), cgFont.get(), size, bold, italic, renderingMode == FontRenderingMode::Alternate); 82 88 #else 83 COMPtr<IDWriteFont> dwFont = DirectWrite::createWithPlatformFont(logFont);84 return FontPlatformData(WTFMove(hfont), dwFont.get(), size, bold, italic, renderingMode == FontRenderingMode::Alternate);89 auto font = DirectWrite::createWithPlatformFont(logFont); 90 return FontPlatformData(WTFMove(hfont), WTFMove(font), size, bold, italic, renderingMode == FontRenderingMode::Alternate); 85 91 #endif 86 92 } -
trunk/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp
r248748 r251900 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 54 54 } 55 55 56 FontPlatformData::FontPlatformData(GDIObject<HFONT>&& hfont, IDWriteFont*font, float size, bool bold, bool oblique, bool useGDI)56 FontPlatformData::FontPlatformData(GDIObject<HFONT>&& hfont, COMPtr<IDWriteFont>&& font, float size, bool bold, bool oblique, bool useGDI) 57 57 : m_syntheticBold(bold) 58 58 , m_syntheticOblique(oblique) 59 59 , m_size(size) 60 60 , m_font(SharedGDIObject<HFONT>::create(WTFMove(hfont))) 61 , m_dwFont( font)61 , m_dwFont(WTFMove(font)) 62 62 , m_useGDI(useGDI) 63 63 { … … 117 117 } 118 118 119 HRESULT FontPlatformData::createFallbackFont(const LOGFONT& logFont, IDWriteFont** dwFont)120 {121 if (!dwFont)122 return E_POINTER;123 124 *dwFont = DirectWrite::createWithPlatformFont(logFont).get();125 126 return S_OK;127 }128 129 HRESULT FontPlatformData::createFallbackFont(HFONT hfont, IDWriteFont** dwFont)130 {131 if (!dwFont)132 return E_POINTER;133 134 COMPtr<IDWriteFontCollection> fontCollection;135 HRESULT hr = DirectWrite::factory()->GetSystemFontCollection(&fontCollection);136 if (FAILED(hr))137 return hr;138 139 HWndDC hdc(0);140 HGDIOBJ oldFont = ::SelectObject(hdc, hfont);141 142 COMPtr<IDWriteFontFace> fontFace;143 hr = DirectWrite::gdiInterop()->CreateFontFaceFromHdc(hdc, &fontFace);144 if (FAILED(hr)) {145 ::SelectObject(hdc, oldFont);146 return hr;147 }148 149 LOGFONT gdiBasedFont = { };150 hr = DirectWrite::gdiInterop()->ConvertFontFaceToLOGFONT(fontFace.get(), &gdiBasedFont);151 if (FAILED(hr)) {152 ::SelectObject(hdc, oldFont);153 return hr;154 }155 156 hr = fontCollection->GetFontFromFontFace(fontFace.get(), dwFont);157 158 if (!SUCCEEDED(hr))159 hr = DirectWrite::webProcessFontCollection()->GetFontFromFontFace(fontFace.get(), dwFont);160 161 ::SelectObject(hdc, oldFont);162 if (SUCCEEDED(hr))163 return hr;164 165 return createFallbackFont(gdiBasedFont, dwFont);166 }167 168 119 } 169 120 -
trunk/Source/WebCore/platform/graphics/win/FontWin.cpp
r239549 r251900 34 34 #include "Logging.h" 35 35 #include "TextRun.h" 36 #include "UniscribeController.h"37 36 #include <wtf/MathExtras.h> 38 37 38 #if !USE(DIRECT2D) 39 #include "UniscribeController.h" 40 #endif 39 41 40 42 namespace WebCore { … … 49 51 return false; 50 52 } 53 54 #if !USE(DIRECT2D) 51 55 52 56 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const … … 114 118 } 115 119 120 #endif 121 116 122 } -
trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp
r248748 r251900 53 53 int localeLength = GetUserDefaultLocaleName(reinterpret_cast<LPWSTR>(&localeName), LOCALE_NAME_MAX_LENGTH); 54 54 RELEASE_ASSERT(localeLength <= LOCALE_NAME_MAX_LENGTH); 55 localeName[localeLength] = '\0';56 55 57 56 TextAnalyzerHelper helper(reinterpret_cast<LPWSTR>(&localeName), reinterpret_cast<LPWSTR>(buffer), bufferLength); … … 60 59 RELEASE_ASSERT(SUCCEEDED(hr)); 61 60 62 unsigned returnedCount = 0; 63 Glyph localGlyphBuffer[GlyphPage::size]; 64 Glyph clusterMap[GlyphPage::size]; 61 Vector<Glyph> glyphs(GlyphPage::size, 0); 62 Vector<Glyph> clusterMap(GlyphPage::size, 0); 65 63 Vector<DWRITE_SHAPING_TEXT_PROPERTIES> textProperties(GlyphPage::size); 66 64 Vector<DWRITE_SHAPING_GLYPH_PROPERTIES> glyphProperties(GlyphPage::size); 67 65 68 hr = analyzer->GetGlyphs(reinterpret_cast<LPCWSTR>(buffer), bufferLength, fontPlatformData.dwFontFace(), fontPlatformData.orientation() == FontOrientation::Vertical, false,69 &helper.m_analysis, nullptr, nullptr, nullptr, nullptr, 0, GlyphPage::size, clusterMap, textProperties.data(),70 localGlyphBuffer, glyphProperties.data(), &returnedCount);71 if (!SUCCEEDED(hr))72 return false;66 const WCHAR* textStart = reinterpret_cast<LPCWSTR>(buffer); 67 Glyph* glyphData = glyphs.data(); 68 Glyph* clusterMapData = clusterMap.data(); 69 DWRITE_SHAPING_TEXT_PROPERTIES* textPropertiesData = textProperties.data(); 70 DWRITE_SHAPING_GLYPH_PROPERTIES* glyphPropertiesData = glyphProperties.data(); 73 71 74 for (unsigned i = 0; i < GlyphPage::size; i++) { 75 Glyph glyph = localGlyphBuffer[i]; 72 unsigned total = 0; 73 unsigned maxGlyphCount = GlyphPage::size; 74 for (const auto& run : helper.m_analyzedRuns) { 75 RELEASE_ASSERT(total + run.length <= bufferLength); 76 77 unsigned returnedCount = 0; 78 hr = analyzer->GetGlyphs(textStart + run.startPosition, run.length, fontPlatformData.dwFontFace(), fontPlatformData.orientation() == FontOrientation::Vertical, false, 79 &run.analysis, nullptr, nullptr, nullptr, nullptr, 0, maxGlyphCount, clusterMapData, textPropertiesData, 80 glyphData, glyphPropertiesData, &returnedCount); 81 82 if (!SUCCEEDED(hr)) 83 return false; 84 85 glyphData += returnedCount; 86 clusterMapData += returnedCount; 87 textPropertiesData += returnedCount; 88 glyphPropertiesData += returnedCount; 89 maxGlyphCount -= returnedCount; 90 } 91 92 for (unsigned i = 0; i < GlyphPage::size; ++i) { 93 Glyph glyph = glyphs[i]; 76 94 if (!glyph) 77 95 setGlyphForIndex(i, 0); -
trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.cpp
r206597 r251900 31 31 namespace WebCore { 32 32 33 TextAnalyzerHelper::TextAnalyzerHelper( WCHAR* localeName,WCHAR* buffer, unsigned bufferLength)33 TextAnalyzerHelper::TextAnalyzerHelper(const WCHAR* localeName, const WCHAR* buffer, unsigned bufferLength) 34 34 : m_localeName(localeName) 35 35 , m_buffer(buffer) … … 123 123 HRESULT TextAnalyzerHelper::SetScriptAnalysis(UINT32 textPosition, UINT32 textLength, const DWRITE_SCRIPT_ANALYSIS* analysis) 124 124 { 125 m_analysis = *analysis; 125 AnalyzedRun current = { textPosition, textLength, *analysis }; 126 m_analyzedRuns.append(WTFMove(current)); 126 127 127 128 return S_OK; -
trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.h
r206597 r251900 27 27 28 28 #include <dwrite.h> 29 #include <wtf/Vector.h> 29 30 30 31 namespace WebCore { 31 32 33 struct AnalyzedRun { 34 unsigned startPosition { 0 }; 35 unsigned length { 0 }; 36 DWRITE_SCRIPT_ANALYSIS analysis; 37 }; 38 32 39 struct TextAnalyzerHelper : public IDWriteTextAnalysisSink, IDWriteTextAnalysisSource { 33 TextAnalyzerHelper( WCHAR* localeName,WCHAR* buffer, unsigned bufferLength);40 TextAnalyzerHelper(const WCHAR* localeName, const WCHAR* buffer, unsigned bufferLength); 34 41 35 42 // IUnknown … … 51 58 virtual HRESULT STDMETHODCALLTYPE SetNumberSubstitution(UINT32 textPosition, UINT32 textLength, IDWriteNumberSubstitution*); 52 59 53 WCHAR* m_localeName { nullptr };54 WCHAR* m_buffer { nullptr };60 const WCHAR* m_localeName { nullptr }; 61 const WCHAR* m_buffer { nullptr }; 55 62 unsigned m_bufferLength { 0 }; 56 DWRITE_SCRIPT_ANALYSIS m_analysis { };63 Vector<AnalyzedRun> m_analyzedRuns; 57 64 ULONG m_refCount { 0 }; 58 65 };
Note: See TracChangeset
for help on using the changeset viewer.