Extend SkFontMgr_Custom to cover ttc, otf, pfb.
Adds ability to test ScanFont with Type1 (pfb) fonts
and fonts with multiple faces (ttc).
Committed: https://skia.googlesource.com/skia/+/ee0c2e4fd429424beaa35f29e7f656997ba3f115
Review URL: https://codereview.chromium.org/672723002
diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h
index 79e6d65..226f55d 100644
--- a/src/ports/SkFontHost_FreeType_common.h
+++ b/src/ports/SkFontHost_FreeType_common.h
@@ -12,6 +12,7 @@
#include "SkGlyph.h"
#include "SkScalerContext.h"
#include "SkTypeface.h"
+#include "SkTypes.h"
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -48,8 +49,18 @@
/** For SkFontMgrs to make use of our ability to extract
* name and style from a stream, using FreeType's API.
*/
- static bool ScanFont(SkStream* stream, int ttcIndex,
- SkString* name, SkFontStyle* style, bool* isFixedPitch);
+ class Scanner : ::SkNoncopyable {
+ public:
+ Scanner();
+ ~Scanner();
+ bool recognizedFont(SkStream* stream, int* numFonts) const;
+ bool scanFont(SkStream* stream, int ttcIndex,
+ SkString* name, SkFontStyle* style, bool* isFixedPitch) const;
+ private:
+ FT_Face openFace(SkStream* stream, int ttcIndex, FT_Stream ftStream) const;
+ FT_Library fLibrary;
+ mutable SkMutex fLibraryMutex;
+ };
protected:
SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch)