• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/core/SkAdvancedTypefaceMetrics.h"
9 #include "src/ports/SkTypeface_proxy.h"
10 
11 #include <memory>
12 #include <utility>
13 
onGetUPEM() const14 int SkTypeface_proxy::onGetUPEM() const { return fRealTypeface->getUnitsPerEm(); }
15 
onOpenStream(int * ttcIndex) const16 std::unique_ptr<SkStreamAsset> SkTypeface_proxy::onOpenStream(int* ttcIndex) const {
17     return fRealTypeface->onOpenStream(ttcIndex);
18 }
19 
onMakeClone(const SkFontArguments & args) const20 sk_sp<SkTypeface> SkTypeface_proxy::onMakeClone(const SkFontArguments& args) const {
21     return fRealTypeface->onMakeClone(args);
22 }
23 
onGlyphMaskNeedsCurrentColor() const24 bool SkTypeface_proxy::onGlyphMaskNeedsCurrentColor() const {
25     return fRealTypeface->glyphMaskNeedsCurrentColor();
26 }
27 
onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],int coordinateCount) const28 int SkTypeface_proxy::onGetVariationDesignPosition(
29         SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const {
30     return fRealTypeface->onGetVariationDesignPosition(coordinates, coordinateCount);
31 }
32 
onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],int parameterCount) const33 int SkTypeface_proxy::onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
34                                                      int parameterCount) const {
35     return fRealTypeface->onGetVariationDesignParameters(parameters, parameterCount);
36 }
37 
onGetFontStyle() const38 SkFontStyle SkTypeface_proxy::onGetFontStyle() const {
39     return fRealTypeface->onGetFontStyle();
40 }
41 
onGetFixedPitch() const42 bool SkTypeface_proxy::onGetFixedPitch() const {
43     return fRealTypeface->onGetFixedPitch();
44 }
45 
onGetFamilyName(SkString * familyName) const46 void SkTypeface_proxy::onGetFamilyName(SkString* familyName) const {
47     fRealTypeface->onGetFamilyName(familyName);
48 }
49 
onGetPostScriptName(SkString * postScriptName) const50 bool SkTypeface_proxy::onGetPostScriptName(SkString* postScriptName) const {
51     return fRealTypeface->getPostScriptName(postScriptName);
52 }
53 
onGetResourceName(SkString * resourceName) const54 int SkTypeface_proxy::onGetResourceName(SkString* resourceName) const {
55     return fRealTypeface->getResourceName(resourceName);
56 }
57 
onCreateFamilyNameIterator() const58 SkTypeface::LocalizedStrings* SkTypeface_proxy::onCreateFamilyNameIterator() const {
59     return fRealTypeface->createFamilyNameIterator();
60 }
61 
onGetTableTags(SkFontTableTag tags[]) const62 int SkTypeface_proxy::onGetTableTags(SkFontTableTag tags[]) const {
63     return fRealTypeface->getTableTags(tags);
64 }
65 
onGetTableData(SkFontTableTag tag,size_t offset,size_t length,void * data) const66 size_t SkTypeface_proxy::onGetTableData(SkFontTableTag tag, size_t offset, size_t length, void* data) const {
67     return fRealTypeface->getTableData(tag, offset, length, data);
68 }
69 
onCreateScalerContext(const SkScalerContextEffects & effects,const SkDescriptor * desc) const70 std::unique_ptr<SkScalerContext> SkTypeface_proxy::onCreateScalerContext(
71         const SkScalerContextEffects& effects, const SkDescriptor* desc) const {
72     return std::make_unique<SkScalerContext_proxy>(
73             fRealTypeface->onCreateScalerContextAsProxyTypeface(effects, desc, const_cast<SkTypeface_proxy*>(this)),
74             *const_cast<SkTypeface_proxy*>(this),
75             effects,
76             desc);
77 }
78 
onFilterRec(SkScalerContextRec * rec) const79 void SkTypeface_proxy::onFilterRec(SkScalerContextRec* rec) const {
80     fRealTypeface->onFilterRec(rec);
81 }
82 
onGetFontDescriptor(SkFontDescriptor * desc,bool * serialize) const83 void SkTypeface_proxy::onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const {
84     fRealTypeface->onGetFontDescriptor(desc, serialize);
85 }
86 
getGlyphToUnicodeMap(SkUnichar * glyphToUnicode) const87 void SkTypeface_proxy::getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const {
88     fRealTypeface->getGlyphToUnicodeMap(glyphToUnicode);
89 }
90 
getPostScriptGlyphNames(SkString * names) const91 void SkTypeface_proxy::getPostScriptGlyphNames(SkString* names) const {
92     return fRealTypeface->getPostScriptGlyphNames(names);
93 }
94 
onGetAdvancedMetrics() const95 std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_proxy::onGetAdvancedMetrics() const {
96     return fRealTypeface->onGetAdvancedMetrics();
97 }
98 
onCharsToGlyphs(const SkUnichar * chars,int count,SkGlyphID glyphs[]) const99 void SkTypeface_proxy::onCharsToGlyphs(const SkUnichar* chars, int count, SkGlyphID glyphs[]) const {
100     fRealTypeface->unicharsToGlyphs(chars, count, glyphs);
101 }
102 
onCountGlyphs() const103 int SkTypeface_proxy::onCountGlyphs() const { return fRealTypeface->countGlyphs(); }
104 
onGetCTFontRef() const105 void* SkTypeface_proxy::onGetCTFontRef() const { return fRealTypeface->onGetCTFontRef(); }
106 
onGetKerningPairAdjustments(const SkGlyphID glyphs[],int count,int32_t adjustments[]) const107 bool SkTypeface_proxy::onGetKerningPairAdjustments(const SkGlyphID glyphs[], int count,
108                                                    int32_t adjustments[]) const  {
109     return fRealTypeface->onGetKerningPairAdjustments(glyphs, count, adjustments);
110 }
111 
SkScalerContext_proxy(std::unique_ptr<SkScalerContext> realScalerContext,SkTypeface_proxy & proxyTypeface,const SkScalerContextEffects & effects,const SkDescriptor * desc)112 SkScalerContext_proxy::SkScalerContext_proxy(std::unique_ptr<SkScalerContext> realScalerContext,
113                                              SkTypeface_proxy& proxyTypeface,
114                                              const SkScalerContextEffects& effects,
115                                              const SkDescriptor* desc)
116         : SkScalerContext(proxyTypeface, effects, desc)
117         , fRealScalerContext(std::move(realScalerContext))
118 { }
119 
generateMetrics(const SkGlyph & glyph,SkArenaAlloc * alloc)120 SkScalerContext::GlyphMetrics SkScalerContext_proxy::generateMetrics(const SkGlyph& glyph, SkArenaAlloc* alloc) {
121     return fRealScalerContext->generateMetrics(glyph, alloc);
122 }
123 
generateImage(const SkGlyph & glyph,void * imageBuffer)124 void SkScalerContext_proxy::generateImage(const SkGlyph& glyph, void* imageBuffer) {
125     fRealScalerContext->generateImage(glyph, imageBuffer);
126 }
127 
generatePath(const SkGlyph & glyph,SkPath * path,bool * modified)128 bool SkScalerContext_proxy::generatePath(const SkGlyph& glyph, SkPath* path, bool* modified) {
129     return fRealScalerContext->generatePath(glyph, path, modified);
130 }
131 
generateDrawable(const SkGlyph & glyph)132 sk_sp<SkDrawable> SkScalerContext_proxy::generateDrawable(const SkGlyph& glyph) {
133     return fRealScalerContext->generateDrawable(glyph);
134 }
135 
generateFontMetrics(SkFontMetrics * metrics)136 void SkScalerContext_proxy::generateFontMetrics(SkFontMetrics* metrics) {
137     fRealScalerContext->generateFontMetrics(metrics);
138 }
139