Remove generateCharFromGlyph and charToGlyphID.
The methods on SkScalerContext are no longer used.
Change-Id: I6a5a5f2eb7018cb6369ea90649ab5a65b5a6660a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/208660
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index b197dae..4e1e715 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -828,9 +828,6 @@
unsigned generateGlyphCount() override {
return 0;
}
- uint16_t generateCharToGlyph(SkUnichar uni) override {
- return 0;
- }
bool generateAdvance(SkGlyph* glyph) override {
glyph->zeroMetrics();
return true;
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 4ee91b5..946245c 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -264,15 +264,6 @@
// DEPRECATED
bool isVertical() const { return false; }
- /** Return the corresponding glyph for the specified unichar. Since contexts
- may be chained (under the hood), the glyphID that is returned may in
- fact correspond to a different font/context. In that case, we use the
- base-glyph-count to know how to translate back into local glyph space.
- */
- uint16_t charToGlyphID(SkUnichar uni) {
- return generateCharToGlyph(uni);
- }
-
unsigned getGlyphCount() { return this->generateGlyphCount(); }
void getAdvance(SkGlyph*);
void getMetrics(SkGlyph*);
@@ -385,11 +376,6 @@
/** Returns the number of glyphs in the font. */
virtual unsigned generateGlyphCount() = 0;
- /** Returns the glyph id for the given unichar.
- * If there is no 1:1 mapping from the unichar to a glyph id, returns 0.
- */
- virtual uint16_t generateCharToGlyph(SkUnichar unichar) = 0;
-
void forceGenerateImageFromPath() { fGenerateImageFromPath = true; }
void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; }
diff --git a/src/core/SkTypeface_remote.cpp b/src/core/SkTypeface_remote.cpp
index 427078a..6478472a 100644
--- a/src/core/SkTypeface_remote.cpp
+++ b/src/core/SkTypeface_remote.cpp
@@ -32,11 +32,6 @@
return 0;
}
-uint16_t SkScalerContextProxy::generateCharToGlyph(SkUnichar) {
- SK_ABORT("Should never be called.");
- return 0;
-}
-
bool SkScalerContextProxy::generateAdvance(SkGlyph* glyph) {
return false;
}
diff --git a/src/core/SkTypeface_remote.h b/src/core/SkTypeface_remote.h
index 183ec9c..46908c5 100644
--- a/src/core/SkTypeface_remote.h
+++ b/src/core/SkTypeface_remote.h
@@ -31,7 +31,6 @@
protected:
unsigned generateGlyphCount() override;
- uint16_t generateCharToGlyph(SkUnichar) override;
bool generateAdvance(SkGlyph* glyph) override;
void generateMetrics(SkGlyph* glyph) override;
void generateImage(const SkGlyph& glyph) override;
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 5ca73a0..c21f884 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -504,7 +504,6 @@
protected:
unsigned generateGlyphCount() override;
- uint16_t generateCharToGlyph(SkUnichar uni) override;
bool generateAdvance(SkGlyph* glyph) override;
void generateMetrics(SkGlyph* glyph) override;
void generateImage(const SkGlyph& glyph) override;
@@ -1035,11 +1034,6 @@
return fFace->num_glyphs;
}
-uint16_t SkScalerContext_FreeType::generateCharToGlyph(SkUnichar uni) {
- SkAutoMutexAcquire ac(gFTMutex);
- return SkToU16(FT_Get_Char_Index( fFace, uni ));
-}
-
bool SkScalerContext_FreeType::generateAdvance(SkGlyph* glyph) {
/* unhinted and light hinted text have linearly scaled advances
* which are very cheap to compute with some font formats...
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 32e5bc3..5f9cbcf 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -906,7 +906,6 @@
protected:
unsigned generateGlyphCount(void) override;
- uint16_t generateCharToGlyph(SkUnichar uni) override;
bool generateAdvance(SkGlyph* glyph) override;
void generateMetrics(SkGlyph* glyph) override;
void generateImage(const SkGlyph& glyph) override;
@@ -1127,23 +1126,6 @@
return fGlyphCount;
}
-uint16_t SkScalerContext_Mac::generateCharToGlyph(SkUnichar uni) {
- AUTO_CG_LOCK();
-
- CGGlyph cgGlyph[2];
- UniChar theChar[2]; // UniChar is a UTF-16 16-bit code unit.
-
- // Get the glyph
- size_t numUniChar = SkUTF::ToUTF16(uni, theChar);
- SkASSERT(sizeof(CGGlyph) <= sizeof(uint16_t));
-
- // Undocumented behavior of CTFontGetGlyphsForCharacters with non-bmp code points:
- // When a surrogate pair is detected, the glyph index used is the index of the high surrogate.
- // It is documented that if a mapping is unavailable, the glyph will be set to 0.
- CTFontGetGlyphsForCharacters(fCTFont.get(), theChar, cgGlyph, numUniChar);
- return cgGlyph[0];
-}
-
bool SkScalerContext_Mac::generateAdvance(SkGlyph* glyph) {
return false;
}
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index d811458..bbb37c7 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -555,7 +555,6 @@
protected:
unsigned generateGlyphCount() override;
- uint16_t generateCharToGlyph(SkUnichar uni) override;
bool generateAdvance(SkGlyph* glyph) override;
void generateMetrics(SkGlyph* glyph) override;
void generateImage(const SkGlyph& glyph) override;
@@ -793,74 +792,6 @@
return fGlyphCount;
}
-uint16_t SkScalerContext_GDI::generateCharToGlyph(SkUnichar utf32) {
- uint16_t index = 0;
- WCHAR utf16[2];
- // TODO(ctguil): Support characters that generate more than one glyph.
- if (SkUTF::ToUTF16(utf32, (uint16_t*)utf16) == 1) {
- // Type1 fonts fail with uniscribe API. Use GetGlyphIndices for plane 0.
-
- /** Real documentation for GetGlyphIndiciesW:
- *
- * When GGI_MARK_NONEXISTING_GLYPHS is not specified and a character does not map to a
- * glyph, then the 'default character's glyph is returned instead. The 'default character'
- * is available in fTM.tmDefaultChar. FON fonts have a default character, and there exists
- * a usDefaultChar in the 'OS/2' table, version 2 and later. If there is no
- * 'default character' specified by the font, then often the first character found is used.
- *
- * When GGI_MARK_NONEXISTING_GLYPHS is specified and a character does not map to a glyph,
- * then the glyph 0xFFFF is used. In Windows XP and earlier, Bitmap/Vector FON usually use
- * glyph 0x1F instead ('Terminal' appears to be special, returning 0xFFFF).
- * Type1 PFM/PFB, TT, OT TT, OT CFF all appear to use 0xFFFF, even on XP.
- */
- DWORD result = GetGlyphIndicesW(fDDC, utf16, 1, &index, GGI_MARK_NONEXISTING_GLYPHS);
- if (result == GDI_ERROR
- || 0xFFFF == index
- || (0x1F == index &&
- (fType == SkScalerContext_GDI::kBitmap_Type ||
- fType == SkScalerContext_GDI::kLine_Type)
- /*&& winVer < Vista */)
- )
- {
- index = 0;
- }
- } else {
- // Use uniscribe to detemine glyph index for non-BMP characters.
- static const int numWCHAR = 2;
- static const int maxItems = 2;
- // MSDN states that this can be nullptr, but some things don't work then.
- SCRIPT_CONTROL sc;
- memset(&sc, 0, sizeof(sc));
- // Add extra item to SCRIPT_ITEM to work around a bug (now documented).
- // https://bugzilla.mozilla.org/show_bug.cgi?id=366643
- SCRIPT_ITEM si[maxItems + 1];
- int numItems;
- HRZM(ScriptItemize(utf16, numWCHAR, maxItems, &sc, nullptr, si, &numItems),
- "Could not itemize character.");
-
- // Disable any attempt at shaping.
- // Without this ScriptShape may return 0x80040200 (USP_E_SCRIPT_NOT_IN_FONT)
- // when all that is desired here is a simple cmap lookup.
- for (SCRIPT_ITEM& item : si) {
- item.a.eScript = SCRIPT_UNDEFINED;
- }
-
- // Sometimes ScriptShape cannot find a glyph for a non-BMP and returns 2 space glyphs.
- static const int maxGlyphs = 2;
- SCRIPT_VISATTR vsa[maxGlyphs];
- WORD outGlyphs[maxGlyphs];
- WORD logClust[numWCHAR];
- int numGlyphs;
- HRZM(ScriptShape(fDDC, &fSC, utf16, numWCHAR, maxGlyphs, &si[0].a,
- outGlyphs, logClust, vsa, &numGlyphs),
- "Could not shape character.");
- if (1 == numGlyphs) {
- index = outGlyphs[0];
- }
- }
- return index;
-}
-
bool SkScalerContext_GDI::generateAdvance(SkGlyph* glyph) {
return false;
}
@@ -1898,6 +1829,21 @@
static void bmpCharsToGlyphs(HDC hdc, const WCHAR* bmpChars, int count, uint16_t* glyphs,
bool Ox1FHack)
{
+ // Type1 fonts fail with uniscribe API. Use GetGlyphIndices for plane 0.
+
+ /** Real documentation for GetGlyphIndicesW:
+ *
+ * When GGI_MARK_NONEXISTING_GLYPHS is not specified and a character does not map to a
+ * glyph, then the 'default character's glyph is returned instead. The 'default character'
+ * is available in fTM.tmDefaultChar. FON fonts have a default character, and there exists
+ * a usDefaultChar in the 'OS/2' table, version 2 and later. If there is no
+ * 'default character' specified by the font, then often the first character found is used.
+ *
+ * When GGI_MARK_NONEXISTING_GLYPHS is specified and a character does not map to a glyph,
+ * then the glyph 0xFFFF is used. In Windows XP and earlier, Bitmap/Vector FON usually use
+ * glyph 0x1F instead ('Terminal' appears to be special, returning 0xFFFF).
+ * Type1 PFM/PFB, TT, OT TT, OT CFF all appear to use 0xFFFF, even on XP.
+ */
DWORD result = GetGlyphIndicesW(hdc, bmpChars, count, glyphs, GGI_MARK_NONEXISTING_GLYPHS);
if (GDI_ERROR == result) {
for (int i = 0; i < count; ++i) {
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp
index 0e3965d..04d7791 100644
--- a/src/ports/SkScalerContext_win_dw.cpp
+++ b/src/ports/SkScalerContext_win_dw.cpp
@@ -374,13 +374,6 @@
return fGlyphCount;
}
-uint16_t SkScalerContext_DW::generateCharToGlyph(SkUnichar uni) {
- uint16_t index = 0;
- UINT32* uniPtr = reinterpret_cast<UINT32*>(&uni);
- this->getDWriteTypeface()->fDWriteFontFace->GetGlyphIndices(uniPtr, 1, &index);
- return index;
-}
-
bool SkScalerContext_DW::generateAdvance(SkGlyph* glyph) {
glyph->fAdvanceX = 0;
glyph->fAdvanceY = 0;
diff --git a/src/ports/SkScalerContext_win_dw.h b/src/ports/SkScalerContext_win_dw.h
index a462d98..3e79a0d 100644
--- a/src/ports/SkScalerContext_win_dw.h
+++ b/src/ports/SkScalerContext_win_dw.h
@@ -28,7 +28,6 @@
protected:
unsigned generateGlyphCount() override;
- uint16_t generateCharToGlyph(SkUnichar uni) override;
bool generateAdvance(SkGlyph* glyph) override;
void generateMetrics(SkGlyph* glyph) override;
void generateImage(const SkGlyph& glyph) override;
diff --git a/tools/fonts/RandomScalerContext.cpp b/tools/fonts/RandomScalerContext.cpp
index d20834c..3431c93 100644
--- a/tools/fonts/RandomScalerContext.cpp
+++ b/tools/fonts/RandomScalerContext.cpp
@@ -25,7 +25,6 @@
protected:
unsigned generateGlyphCount() override;
- uint16_t generateCharToGlyph(SkUnichar) override;
bool generateAdvance(SkGlyph*) override;
void generateMetrics(SkGlyph*) override;
void generateImage(const SkGlyph&) override;
@@ -52,10 +51,6 @@
unsigned RandomScalerContext::generateGlyphCount() { return fProxy->getGlyphCount(); }
-uint16_t RandomScalerContext::generateCharToGlyph(SkUnichar uni) {
- return fProxy->charToGlyphID(uni);
-}
-
bool RandomScalerContext::generateAdvance(SkGlyph* glyph) { return fProxy->generateAdvance(glyph); }
void RandomScalerContext::generateMetrics(SkGlyph* glyph) {
diff --git a/tools/fonts/TestSVGTypeface.cpp b/tools/fonts/TestSVGTypeface.cpp
index 4a78084..80ee05a 100644
--- a/tools/fonts/TestSVGTypeface.cpp
+++ b/tools/fonts/TestSVGTypeface.cpp
@@ -199,10 +199,6 @@
unsigned generateGlyphCount() override { return this->getTestSVGTypeface()->countGlyphs(); }
- uint16_t generateCharToGlyph(SkUnichar u) override {
- return this->getTestSVGTypeface()->unicharToGlyph(u);
- }
-
bool generateAdvance(SkGlyph* glyph) override {
this->getTestSVGTypeface()->getAdvance(glyph);
diff --git a/tools/fonts/TestTypeface.cpp b/tools/fonts/TestTypeface.cpp
index f8427cc..05f5d79 100644
--- a/tools/fonts/TestTypeface.cpp
+++ b/tools/fonts/TestTypeface.cpp
@@ -179,13 +179,6 @@
unsigned generateGlyphCount() override { return this->getTestTypeface()->onCountGlyphs(); }
- uint16_t generateCharToGlyph(SkUnichar uni) override {
- uint16_t glyph;
- (void)this->getTestTypeface()->onCharsToGlyphs(
- (const void*)&uni, SkTypeface::kUTF32_Encoding, &glyph, 1);
- return glyph;
- }
-
bool generateAdvance(SkGlyph* glyph) override {
this->getTestTypeface()->getAdvance(glyph);