aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkTypeface_win_dw.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-05-09 15:35:54 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-09 15:36:06 +0000
commit97c1108607584b6050a6880d6ce22846e4913a92 (patch)
treee6cb5bfa22fdd2fba53c9cd49d3beed28fff686b /src/ports/SkTypeface_win_dw.cpp
parent2ed5f69da6f101e60a3cf49c0767212b563552f3 (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/SkTypeface_win_dw.cpp')
-rw-r--r--src/ports/SkTypeface_win_dw.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp
index 38e68dccca..69bf7ff034 100644
--- a/src/ports/SkTypeface_win_dw.cpp
+++ b/src/ports/SkTypeface_win_dw.cpp
@@ -288,31 +288,42 @@ void DWriteFontTypeface::onFilterRec(SkScalerContextRec* rec) const {
///////////////////////////////////////////////////////////////////////////////
//PDF Support
-void DWriteFontTypeface::getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const {
- unsigned glyphCount = fDWriteFontFace->GetGlyphCount();
- sk_bzero(glyphToUnicode, sizeof(SkUnichar) * glyphCount);
- IDWriteFontFace* fontFace = fDWriteFontFace.get();
+// Construct Glyph to Unicode table.
+// Unicode code points that require conjugate pairs in utf16 are not
+// supported.
+// TODO(bungeman): This never does what anyone wants.
+// What is really wanted is the text to glyphs mapping
+static void populate_glyph_to_unicode(IDWriteFontFace* fontFace,
+ const unsigned glyphCount,
+ SkTDArray<SkUnichar>* glyphToUnicode) {
+ //Do this like free type instead
+ SkAutoTMalloc<SkUnichar> glyphToUni(
+ (SkUnichar*)sk_calloc_throw(sizeof(SkUnichar) * glyphCount));
int maxGlyph = -1;
unsigned remainingGlyphCount = glyphCount;
for (UINT32 c = 0; c < 0x10FFFF && remainingGlyphCount != 0; ++c) {
UINT16 glyph = 0;
- HRVM(fontFace->GetGlyphIndices(&c, 1, &glyph), "Failed to get glyph index.");
+ HRVM(fontFace->GetGlyphIndices(&c, 1, &glyph),
+ "Failed to get glyph index.");
// Intermittent DW bug on Windows 10. See crbug.com/470146.
if (glyph >= glyphCount) {
- return;
+ return;
}
- if (0 < glyph && glyphToUnicode[glyph] == 0) {
+ if (0 < glyph && glyphToUni[glyph] == 0) {
maxGlyph = SkTMax(static_cast<int>(glyph), maxGlyph);
- glyphToUnicode[glyph] = c; // Always use lowest-index unichar.
+ glyphToUni[glyph] = c; // Always use lowest-index unichar.
--remainingGlyphCount;
}
}
+ SkTDArray<SkUnichar>(glyphToUni, maxGlyph + 1).swap(*glyphToUnicode);
}
std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetrics() const {
std::unique_ptr<SkAdvancedTypefaceMetrics> info(nullptr);
+ const unsigned glyphCount = fDWriteFontFace->GetGlyphCount();
+
DWRITE_FONT_METRICS dwfm;
fDWriteFontFace->GetMetrics(&dwfm);
@@ -347,6 +358,9 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetr
info->fPostScriptName = info->fFontName;
}
+
+ populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGlyphToUnicode));
+
DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
if (fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE &&
fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)