33#ifdef SK_TYPEFACE_FACTORY_FREETYPE
37#ifdef SK_TYPEFACE_FACTORY_CORETEXT
41#ifdef SK_TYPEFACE_FACTORY_DIRECTWRITE
46#ifdef SK_TYPEFACE_FACTORY_FONTATIONS
75 if (
stream->getLength() == 0) {
76 return SkEmptyTypeface::Make();
84 std::unique_ptr<SkStreamAsset>
onOpenStream(
int* ttcIndex)
const override {
return nullptr; }
92 sk_ref_sp(
const_cast<SkEmptyTypeface*
>(
this)), effects, desc);
99 desc->setFactoryId(FactoryId);
108 int onGetUPEM()
const override {
return 0; }
122 return new EmptyLocalizedStrings;
128 int coordinateCount)
const override
133 int parameterCount)
const override
146 return SkEmptyTypeface::Make();
150 if (facea == faceb) {
153 if (!facea || !faceb) {
168 std::vector<DecoderProc>* decoders() {
170 { SkEmptyTypeface::FactoryId, SkEmptyTypeface::MakeFromStream },
172#ifdef SK_TYPEFACE_FACTORY_CORETEXT
173 { SkTypeface_Mac::FactoryId, SkTypeface_Mac::MakeFromStream },
175#ifdef SK_TYPEFACE_FACTORY_DIRECTWRITE
178#ifdef SK_TYPEFACE_FACTORY_FREETYPE
181#ifdef SK_TYPEFACE_FACTORY_FONTATIONS
185 return decoders.
get();
199 decoders()->push_back(DecoderProc{
id,
make});
203 bool isLocalData =
false;
206 if (desc.getFactoryId() == 0) {
207 SkDEBUGF(
"Factory was not set for %s.\n", desc.getFamilyName());
210 bool shouldSerializeData =
false;
217 if (shouldSerializeData) {
220 if (desc.hasStream()) {
221 desc.setCollectionIndex(index);
228 desc.setVariationCoordinates(0);
232 desc.serialize(wstream);
238 return stream.detachAsData();
247 if (desc.hasStream()) {
248 for (
const DecoderProc& proc : *decoders()) {
249 if (proc.id == desc.getFactoryId()) {
250 return proc.makeFromStream(desc.detachStream(), desc.getFontArguments());
254 [[maybe_unused]]
FactoryId id = desc.getFactoryId();
255 SkDEBUGF(
"Could not find factory %c%c%c%c for %s.\n",
256 (
char)((
id >> 24) & 0xFF),
257 (
char)((
id >> 16) & 0xFF),
258 (
char)((
id >> 8) & 0xFF),
259 (
char)((
id >> 0) & 0xFF),
260 desc.getFamilyName());
271 desc.getFontArguments());
278 return lastResortMgr->legacyMakeTypeface(desc.getFamilyName(), desc.getStyle());
280 return SkEmptyTypeface::Make();
285bool SkTypeface::glyphMaskNeedsCurrentColor()
const {
326 (void)this->
getTableData(tag, 0, size, data->writable_data());
334 if (
nullptr == ttcIndex) {
336 ttcIndex = &ttcIndexStorage;
343 if (
nullptr == ttcIndex) {
345 ttcIndex = &ttcIndexStorage;
354 return scalerContext;
370class SkConvertToUTF32 {
372 SkConvertToUTF32() {}
378 uni = fStorage.reset(byteLength);
379 const char* ptr = (
const char*)
text;
380 const char*
end = ptr + byteLength;
381 for (
int i = 0; ptr <
end; ++i) {
386 uni = fStorage.reset(byteLength);
387 const uint16_t* ptr = (
const uint16_t*)
text;
388 const uint16_t*
end = ptr + (byteLength >> 1);
389 for (
int i = 0; ptr <
end; ++i) {
409 if (0 == byteLength) {
425 SkConvertToUTF32 storage;
426 const SkUnichar* uni = storage.convert(
text, byteLength, encoding);
442 int32_t adjustments[])
const {
447 if (
nullptr ==
glyphs ||
nullptr == adjustments) {
472std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface::getAdvancedMetrics()
const {
474 if (result &&
result->fPostScriptName.isEmpty()) {
481 SkOTTableOS2::Version::V2::Type::Field fsType;
484 if (this->
getTableData(os2Tag, fsTypeOffset,
sizeof(fsType), &fsType) ==
sizeof(fsType)) {
485 if (fsType.Bitmap || (fsType.Restricted && !(fsType.PreviewPrint || fsType.Editable))) {
488 if (fsType.NoSubsetting) {
497 int32_t adjustments[])
const {
520 const SkScalar invTextSize = 1 / textSize;
524 font.setSize(textSize);
525 font.setLinearMetrics(
true);
539 ctx->getFontMetrics(&fm);
543 bounds->setLTRB(fm.
fXMin * invTextSize, fm.
fTop * invTextSize,
SkStrokeRec::Style fStyle
static float next(float f)
#define SK_ABORT(message,...)
#define SkTEndian_SwapBE32(n)
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kUTF16
uses two byte words to represent most of Unicode
@ kUTF32
uses four byte words to represent all of Unicode
@ kGlyphID
uses two byte words to represent glyph indices
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
static void sk_bzero(void *buffer, size_t size)
sk_sp< T > sk_ref_sp(T *obj)
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
static sk_sp< SkTypeface > SK_SPI MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
static constexpr SkTypeface::FactoryId FactoryId
SkDescriptor * getDesc() const
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
static constexpr SkTypeface::FactoryId FactoryId
static sk_sp< SkData > MakeUninitialized(size_t length)
SkFontArguments::VariationPosition::Coordinate * setVariationCoordinates(int coordinateCount)
static bool Deserialize(SkStream *, SkFontDescriptor *result)
static int CountTextElements(const void *text, size_t byteLength, SkTextEncoding)
static SkDescriptor * AutoDescriptorGivenRecAndEffects(const SkScalerContextRec &rec, const SkScalerContextEffects &effects, SkAutoDescriptor *ad)
static void MakeRecAndEffectsFromFont(const SkFont &font, SkScalerContextRec *rec, SkScalerContextEffects *effects)
static std::unique_ptr< SkScalerContext > MakeEmpty(sk_sp< SkTypeface > typeface, const SkScalerContextEffects &effects, const SkDescriptor *desc)
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
static constexpr SkTypeface::FactoryId FactoryId
static constexpr SkTypeface::FactoryId FactoryId
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
virtual std::unique_ptr< SkStreamAsset > onOpenExistingStream(int *ttcIndex) const
LocalizedStrings * createFamilyNameIterator() const
std::unique_ptr< SkStreamAsset > openExistingStream(int *ttcIndex) const
sk_sp< SkData > copyTableData(SkFontTableTag tag) const
virtual sk_sp< SkData > onCopyTableData(SkFontTableTag) const
virtual void getPostScriptGlyphNames(SkString *) const =0
SkTypefaceID uniqueID() const
virtual std::unique_ptr< SkAdvancedTypefaceMetrics > onGetAdvancedMetrics() const =0
int getUnitsPerEm() const
virtual bool onGetKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
virtual void getGlyphToUnicodeMap(SkUnichar *dstArray) const =0
void getFamilyName(SkString *name) const
virtual std::unique_ptr< SkScalerContext > onCreateScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const =0
virtual int onCountGlyphs() const =0
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
virtual int onGetTableTags(SkFontTableTag tags[]) const =0
static void Register(FactoryId id, sk_sp< SkTypeface >(*make)(std::unique_ptr< SkStreamAsset >, const SkFontArguments &))
int getVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const
int textToGlyphs(const void *text, size_t byteLength, SkTextEncoding encoding, SkGlyphID glyphs[], int maxGlyphCount) const
bool getKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
int getTableTags(SkFontTableTag tags[]) const
virtual std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const =0
virtual void onGetFontDescriptor(SkFontDescriptor *, bool *isLocal) const =0
size_t getTableSize(SkFontTableTag) const
int getVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const
virtual sk_sp< SkTypeface > onMakeClone(const SkFontArguments &) const =0
static bool Equal(const SkTypeface *facea, const SkTypeface *faceb)
bool getPostScriptName(SkString *name) const
static sk_sp< SkTypeface > MakeDeserialize(SkStream *, sk_sp< SkFontMgr > lastResortMgr)
virtual size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void *data) const =0
virtual bool onGetPostScriptName(SkString *) const =0
virtual void onGetFamilyName(SkString *familyName) const =0
virtual void onFilterRec(SkScalerContextRec *) const =0
static sk_sp< SkTypeface > MakeEmpty()
virtual bool onGlyphMaskNeedsCurrentColor() const =0
std::unique_ptr< SkStreamAsset > openStream(int *ttcIndex) const
virtual bool onComputeBounds(SkRect *) const
virtual LocalizedStrings * onCreateFamilyNameIterator() const =0
virtual int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const =0
std::unique_ptr< SkScalerContext > createScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const
size_t getTableData(SkFontTableTag tag, size_t offset, size_t length, void *data) const
SkGlyphID unicharToGlyph(SkUnichar unichar) const
virtual void onCharsToGlyphs(const SkUnichar *chars, int count, SkGlyphID glyphs[]) const =0
virtual int onGetUPEM() const =0
void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const
SkTypeface(const SkFontStyle &style, bool isFixedPitch=false)
virtual int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const =0
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
static Editor::Movement convert(skui::Key key)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static sk_sp< SkImage > make(sk_sp< SkColorSpace > cs)
SK_SPI SkUnichar NextUTF16(const uint16_t **ptr, const uint16_t *end)
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
@ kNotEmbeddable_FontFlag
May not be embedded.
@ kNotSubsettable_FontFlag
May not be subset.
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
static constexpr SK_OT_ULONG TAG