diff options
author | Greg Daniel <egdaniel@google.com> | 2018-05-09 15:35:54 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-09 15:36:06 +0000 |
commit | 97c1108607584b6050a6880d6ce22846e4913a92 (patch) | |
tree | e6cb5bfa22fdd2fba53c9cd49d3beed28fff686b /src/ports/SkFontHost_win.cpp | |
parent | 2ed5f69da6f101e60a3cf49c0767212b563552f3 (diff) |
Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode"
This reverts commit 1c2bcd8b14e029a70e88b1e81acd29553cab0d1c.
Reason for revert: breaking chrome roll
Original change's description:
> SkAdvancedTypefaceMetrics: factor out GlyphToUnicode
>
> Change-Id: Iedce8c1ea2c405d5ab64ccac353970d5cd2b9d63
> Reviewed-on: https://skia-review.googlesource.com/126507
> Commit-Queue: Hal Canary <halcanary@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: Ib1ff8484ffd09cdb88d461ac00745aa32c191124
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/127000
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/ports/SkFontHost_win.cpp')
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index f1da8053f2..35a0a74b22 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -261,7 +261,6 @@ protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; - void getGlyphToUnicodeMap(SkUnichar*) const override; std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; int onCharsToGlyphs(const void* chars, Encoding encoding, @@ -363,8 +362,7 @@ void SkLOGFONTFromTypeface(const SkTypeface* face, LOGFONT* lf) { // require parsing the TTF cmap table (platform 4, encoding 12) directly instead // of calling GetFontUnicodeRange(). static void populate_glyph_to_unicode(HDC fontHdc, const unsigned glyphCount, - SkUnichar* glyphToUnicode) { - sk_bzero(glyphToUnicode, sizeof(SkUnichar) * glyphCount); + SkTDArray<SkUnichar>* glyphToUnicode) { DWORD glyphSetBufferSize = GetFontUnicodeRanges(fontHdc, nullptr); if (!glyphSetBufferSize) { return; @@ -377,6 +375,8 @@ static void populate_glyph_to_unicode(HDC fontHdc, const unsigned glyphCount, return; } + glyphToUnicode->setCount(glyphCount); + memset(glyphToUnicode->begin(), 0, glyphCount * sizeof(SkUnichar)); for (DWORD i = 0; i < glyphSet->cRanges; ++i) { // There is no guarantee that within a Unicode range, the corresponding // glyph id in a font file are continuous. So, even if we have ranges, @@ -399,8 +399,9 @@ static void populate_glyph_to_unicode(HDC fontHdc, const unsigned glyphCount, // unlikely to have collisions since glyph reuse happens mostly for // different Unicode pages. for (USHORT j = 0; j < count; ++j) { - if (glyph[j] != 0xFFFF && glyph[j] < glyphCount && glyphToUnicode[glyph[j]] == 0) { - glyphToUnicode[glyph[j]] = chars[j]; + if (glyph[j] != 0xffff && glyph[j] < glyphCount && + (*glyphToUnicode)[glyph[j]] == 0) { + (*glyphToUnicode)[glyph[j]] = chars[j]; } } } @@ -1706,23 +1707,6 @@ void LogFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, *isLocalStream = this->fSerializeAsStream; } -void LogFontTypeface::getGlyphToUnicodeMap(SkUnichar* dstArray) const { - HDC hdc = ::CreateCompatibleDC(nullptr); - HFONT font = CreateFontIndirect(&fLogFont); - HFONT savefont = (HFONT)SelectObject(hdc, font); - LOGFONT lf = fLogFont; - HFONT designFont = CreateFontIndirect(&lf); - SelectObject(hdc, designFont); - - unsigned int glyphCount = calculateGlyphCount(hdc, fLogFont); - populate_glyph_to_unicode(hdc, glyphCount, dstArray); - - SelectObject(hdc, savefont); - DeleteObject(designFont); - DeleteObject(font); - DeleteDC(hdc); -} - std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics() const { LOGFONT lf = fLogFont; std::unique_ptr<SkAdvancedTypefaceMetrics> info(nullptr); @@ -1773,6 +1757,8 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics } } + populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); + if (glyphCount > 0 && (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font; |