8 #ifndef SkTypeface_DEFINED
9 #define SkTypeface_DEFINED
11 #include "../private/SkBitmaskEnum.h"
12 #include "../private/SkOnce.h"
13 #include "../private/SkWeakRefCnt.h"
14 #include "SkFontArguments.h"
15 #include "SkFontStyle.h"
21 class SkFontDescriptor;
22 class SkScalerContext;
26 struct SkAdvancedTypefaceMetrics;
27 struct SkScalerContextEffects;
28 struct SkScalerContextRec;
30 typedef uint32_t SkFontID;
32 typedef uint32_t SkFontTableTag;
65 return static_cast<Style>(
66 (fStyle.weight() >= SkFontStyle::kSemiBold_Weight ? kBold : kNormal) |
67 (fStyle.slant() != SkFontStyle::kUpright_Slant ? kItalic : kNormal));
71 bool isBold()
const {
return fStyle.weight() >= SkFontStyle::kSemiBold_Weight; }
74 bool isItalic()
const {
return fStyle.slant() != SkFontStyle::kUpright_Slant; }
93 int coordinateCount)
const;
98 SkFontID
uniqueID()
const {
return fUniqueID; }
104 static SkFontID UniqueID(
const SkTypeface* face);
185 int charsToGlyphs(
const void* chars, Encoding encoding,
SkGlyphID glyphs[],
186 int glyphCount)
const;
191 int countGlyphs()
const;
197 int countTables()
const;
204 int getTableTags(SkFontTableTag tags[])
const;
208 size_t getTableSize(SkFontTableTag)
const;
230 size_t getTableData(SkFontTableTag tag,
size_t offset,
size_t length,
237 int getUnitsPerEm()
const;
259 bool getKerningPairAdjustments(
const SkGlyphID glyphs[],
int count,
260 int32_t adjustments[])
const;
270 void unref() {
delete this; }
284 void getFamilyName(
SkString* name)
const;
298 std::unique_ptr<SkFontData> makeFontData()
const;
305 std::unique_ptr<SkScalerContext> createScalerContext(
const SkScalerContextEffects&,
307 bool allowFailure =
false)
const;
317 void filterRec(SkScalerContextRec* rec)
const {
318 this->onFilterRec(rec);
321 void getFontDescriptor(SkFontDescriptor* desc,
bool* isLocal)
const {
322 this->onGetFontDescriptor(desc, isLocal);
325 void* internal_private_getCTFontRef()
const {
326 return this->onGetCTFontRef();
340 friend class SkScalerContext;
341 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal);
343 virtual SkScalerContext* onCreateScalerContext(
const SkScalerContextEffects&,
344 const SkDescriptor*)
const = 0;
345 virtual void onFilterRec(SkScalerContextRec*)
const = 0;
348 virtual std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics()
const;
350 virtual SkStreamAsset* onOpenStream(
int* ttcIndex)
const = 0;
352 virtual std::unique_ptr<SkFontData> onMakeFontData()
const;
354 virtual int onGetVariationDesignPosition(
356 int coordinateCount)
const = 0;
358 virtual void onGetFontDescriptor(SkFontDescriptor*,
bool* isLocal)
const = 0;
360 virtual int onCharsToGlyphs(
const void* chars, Encoding,
SkGlyphID glyphs[],
361 int glyphCount)
const = 0;
362 virtual int onCountGlyphs()
const = 0;
364 virtual int onGetUPEM()
const = 0;
365 virtual bool onGetKerningPairAdjustments(
const SkGlyphID glyphs[],
int count,
366 int32_t adjustments[])
const;
371 virtual void onGetFamilyName(
SkString* familyName)
const = 0;
374 virtual LocalizedStrings* onCreateFamilyNameIterator()
const = 0;
376 virtual int onGetTableTags(SkFontTableTag tags[])
const = 0;
377 virtual size_t onGetTableData(SkFontTableTag,
size_t offset,
378 size_t length,
void* data)
const = 0;
380 virtual bool onComputeBounds(
SkRect*)
const;
382 virtual void* onGetCTFontRef()
const {
return nullptr; }
385 friend class SkRandomTypeface;
386 friend class SkPDFFont;
387 friend class GrPathRendering;
388 friend class GrGLPathRendering;
391 std::unique_ptr<SkAdvancedTypefaceMetrics> getAdvancedMetrics()
const;
397 mutable SkOnce fBoundsOnce;
401 friend class SkGlyphCache;
403 typedef SkWeakRefCnt INHERITED;
bool isFixedPitch() const
Returns true if the typeface claims to be fixed-pitch.
Definition: SkTypeface.h:79
Style style() const
Returns the typeface's intrinsic style attributes.
Definition: SkTypeface.h:64
SkFontStyle fontStyle() const
Returns the typeface's intrinsic style attributes.
Definition: SkTypeface.h:57
Style
Style specifies the intrinsic style attributes of a given typeface.
Definition: SkTypeface.h:47
Definition: SkFontArguments.h:17
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:299
SkStreamAsset is a SkStreamSeekable for which getLength is required.
Definition: SkStream.h:164
void setIsFixedPitch(bool isFixedPitch)
Sets the fixedPitch bit.
Definition: SkTypeface.h:336
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
Definition: SkPaint.h:45
Definition: SkTypeface.h:262
The SkTypeface class specifies the typeface and intrinsic style of a font.
Definition: SkTypeface.h:43
void setFontStyle(SkFontStyle style)
Sets the font style.
Definition: SkTypeface.h:338
Definition: SkTypeface.h:266
Definition: SkFontStyle.h:13
SkStream – abstraction for a source of bytes.
Definition: SkStream.h:40
Definition: SkStream.h:182
bool isBold() const
Returns true if style() has the kBold bit set.
Definition: SkTypeface.h:71
SkFontID uniqueID() const
Return a 32bit value for this typeface, unique for the underlying font data.
Definition: SkTypeface.h:98
Light weight class for managing strings.
Definition: SkString.h:121
bool isItalic() const
Returns true if style() has the kItalic bit set.
Definition: SkTypeface.h:74