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>
This commit is contained in:
parent
151a883e86
commit
0a8da21fba
@ -828,9 +828,6 @@ protected:
|
||||
unsigned generateGlyphCount() override {
|
||||
return 0;
|
||||
}
|
||||
uint16_t generateCharToGlyph(SkUnichar uni) override {
|
||||
return 0;
|
||||
}
|
||||
bool generateAdvance(SkGlyph* glyph) override {
|
||||
glyph->zeroMetrics();
|
||||
return true;
|
||||
|
@ -264,15 +264,6 @@ public:
|
||||
// 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 @@ protected:
|
||||
/** 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; }
|
||||
|
||||
|
@ -32,11 +32,6 @@ unsigned SkScalerContextProxy::generateGlyphCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t SkScalerContextProxy::generateCharToGlyph(SkUnichar) {
|
||||
SK_ABORT("Should never be called.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SkScalerContextProxy::generateAdvance(SkGlyph* glyph) {
|
||||
return false;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ public:
|
||||
|
||||
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;
|
||||
|
@ -504,7 +504,6 @@ public:
|
||||
|
||||
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 @@ unsigned SkScalerContext_FreeType::generateGlyphCount() {
|
||||
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...
|
||||
|
@ -906,7 +906,6 @@ public:
|
||||
|
||||
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 @@ unsigned SkScalerContext_Mac::generateGlyphCount(void) {
|
||||
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;
|
||||
}
|
||||
|
@ -555,7 +555,6 @@ public:
|
||||
|
||||
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 @@ unsigned SkScalerContext_GDI::generateGlyphCount() {
|
||||
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 @@ sk_sp<SkTypeface> LogFontTypeface::onMakeClone(const SkFontArguments& args) cons
|
||||
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) {
|
||||
|
@ -374,13 +374,6 @@ unsigned SkScalerContext_DW::generateGlyphCount() {
|
||||
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;
|
||||
|
@ -28,7 +28,6 @@ public:
|
||||
|
||||
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;
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
|
||||
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 @@ RandomScalerContext::RandomScalerContext(sk_sp<SkRandomTypeface> face,
|
||||
|
||||
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) {
|
||||
|
@ -199,10 +199,6 @@ protected:
|
||||
|
||||
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);
|
||||
|
||||
|
@ -179,13 +179,6 @@ protected:
|
||||
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user