aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_FreeType.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/SkFontHost_FreeType.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/SkFontHost_FreeType.cpp')
-rw-r--r--src/ports/SkFontHost_FreeType.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 3e8e9576dd..f1c1b555f2 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -511,6 +511,23 @@ static bool canSubset(FT_Face face) {
return (fsType & FT_FSTYPE_NO_SUBSETTING) == 0;
}
+static void populate_glyph_to_unicode(FT_Face& face, SkTDArray<SkUnichar>* glyphToUnicode) {
+ FT_Long numGlyphs = face->num_glyphs;
+ glyphToUnicode->setCount(SkToInt(numGlyphs));
+ sk_bzero(glyphToUnicode->begin(), sizeof((*glyphToUnicode)[0]) * numGlyphs);
+
+ FT_UInt glyphIndex;
+ SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex);
+ while (glyphIndex) {
+ SkASSERT(glyphIndex < SkToUInt(numGlyphs));
+ // Use the first character that maps to this glyphID. https://crbug.com/359065
+ if (0 == (*glyphToUnicode)[glyphIndex]) {
+ (*glyphToUnicode)[glyphIndex] = charCode;
+ }
+ charCode = FT_Get_Next_Char(face, charCode, &glyphIndex);
+ }
+}
+
static SkAdvancedTypefaceMetrics::FontType get_font_type(FT_Face face) {
const char* fontType = FT_Get_X11_Font_Format(face);
static struct { const char* s; SkAdvancedTypefaceMetrics::FontType t; } values[] = {
@@ -585,26 +602,17 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_FreeType::onGetAdvancedMet
}
info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax,
face->bbox.xMax, face->bbox.yMin);
- return info;
-}
-void SkTypeface_FreeType::getGlyphToUnicodeMap(SkUnichar* dstArray) const {
- SkASSERT(dstArray);
- AutoFTAccess fta(this);
- FT_Face face = fta.face();
- FT_Long numGlyphs = face->num_glyphs;
- sk_bzero(dstArray, sizeof(SkUnichar) * numGlyphs);
+ bool perGlyphInfo = FT_IS_SCALABLE(face);
- FT_UInt glyphIndex;
- SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex);
- while (glyphIndex) {
- SkASSERT(glyphIndex < SkToUInt(numGlyphs));
- // Use the first character that maps to this glyphID. https://crbug.com/359065
- if (0 == dstArray[glyphIndex]) {
- dstArray[glyphIndex] = charCode;
- }
- charCode = FT_Get_Next_Char(face, charCode, &glyphIndex);
+ if (perGlyphInfo &&
+ info->fType != SkAdvancedTypefaceMetrics::kType1_Font &&
+ face->num_charmaps)
+ {
+ populate_glyph_to_unicode(face, &(info->fGlyphToUnicode));
}
+
+ return info;
}
void SkTypeface_FreeType::getPostScriptGlyphNames(SkString* dstArray) const {