replace SkFont::glyphsToUnichars with SkFontPriv::GlyphsToUnichars

Change-Id: Ideea45d7b23eb9e821664be96d480a7d64c69a42
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215826
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2019-05-24 11:00:20 -04:00 committed by Skia Commit-Bot
parent 1e8f6e2372
commit c4c812c273
3 changed files with 17 additions and 22 deletions

View File

@ -508,14 +508,11 @@ private:
SkScalar setupForAsPaths(SkPaint*);
bool hasSomeAntiAliasing() const;
void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const;
friend class GrTextBlob;
friend class SkCanonicalizeFont;
friend class SkFontPriv;
friend class SkGlyphRunListPainter;
friend class SkTextBlobCacheDiffCanvas;
friend class SVGTextBuilder;
friend class SkStrikeSpecStorage;
};

View File

@ -209,22 +209,6 @@ int SkFont::textToGlyphs(const void* text, size_t byteLength, SkTextEncoding enc
return count;
}
void SkFont::glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const {
if (count <= 0) {
return;
}
auto typeface = this->getTypefaceOrDefault();
const unsigned numGlyphsInTypeface = typeface->countGlyphs();
SkAutoTArray<SkUnichar> unichars(numGlyphsInTypeface);
typeface->getGlyphToUnicodeMap(unichars.get());
for (int i = 0; i < count; ++i) {
unsigned id = glyphs[i];
text[i] = (id < numGlyphsInTypeface) ? unichars[id] : 0xFFFD;
}
}
static void set_bounds(const SkGlyph& g, SkRect* bounds) {
bounds->set(SkIntToScalar(g.fLeft),
SkIntToScalar(g.fTop),
@ -472,8 +456,20 @@ int SkFontPriv::CountTextElements(const void* text, size_t byteLength, SkTextEnc
}
void SkFontPriv::GlyphsToUnichars(const SkFont& font, const SkGlyphID glyphs[], int count,
SkUnichar uni[]) {
font.glyphsToUnichars(glyphs, count, uni);
SkUnichar text[]) {
if (count <= 0) {
return;
}
auto typeface = font.getTypefaceOrDefault();
const unsigned numGlyphsInTypeface = typeface->countGlyphs();
SkAutoTArray<SkUnichar> unichars(numGlyphsInTypeface);
typeface->getGlyphToUnicodeMap(unichars.get());
for (int i = 0; i < count; ++i) {
unsigned id = glyphs[i];
text[i] = (id < numGlyphsInTypeface) ? unichars[id] : 0xFFFD;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -28,6 +28,7 @@
#include "src/core/SkClipOpPriv.h"
#include "src/core/SkClipStack.h"
#include "src/core/SkDraw.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkUtils.h"
#include "src/shaders/SkShaderBase.h"
#include "src/xml/SkXMLWriter.h"
@ -843,7 +844,8 @@ public:
, fLastCharWasWhitespace(true) { // start off in whitespace mode to strip all leadingspace
auto runSize = glyphRun.runSize();
SkAutoSTArray<64, SkUnichar> unichars(runSize);
glyphRun.font().glyphsToUnichars(glyphRun.glyphsIDs().data(), runSize, unichars.get());
SkFontPriv::GlyphsToUnichars(glyphRun.font(), glyphRun.glyphsIDs().data(),
runSize, unichars.get());
auto positions = glyphRun.positions();
for (size_t i = 0; i < runSize; ++i) {
this->appendUnichar(unichars[i], positions[i]);