| 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 |
|
| 14 |
int SkTypeface_proxy::onGetUPEM() const { return fRealTypeface->getUnitsPerEm(); } |
| 15 |
|
| 16 |
std::unique_ptr<SkStreamAsset> SkTypeface_proxy::onOpenStream(int* ttcIndex) const { |
| 17 |
return fRealTypeface->onOpenStream(ttcIndex); |
| 18 |
} |
| 19 |
|
| 20 |
sk_sp<SkTypeface> SkTypeface_proxy::onMakeClone(const SkFontArguments& args) const { |
| 21 |
return fRealTypeface->onMakeClone(args); |
| 22 |
} |
| 23 |
|
| 24 |
bool SkTypeface_proxy::onGlyphMaskNeedsCurrentColor() const { |
| 25 |
return fRealTypeface->glyphMaskNeedsCurrentColor(); |
| 26 |
} |
| 27 |
|
| 28 |
int SkTypeface_proxy::onGetVariationDesignPosition( |
| 29 |
SkSpan<SkFontArguments::VariationPosition::Coordinate> coordinates) const { |
| 30 |
return fRealTypeface->onGetVariationDesignPosition(coordinates); |
| 31 |
} |
| 32 |
|
| 33 |
int SkTypeface_proxy::onGetVariationDesignParameters( |
| 34 |
SkSpan<SkFontParameters::Variation::Axis> parameters) const { |
| 35 |
return fRealTypeface->onGetVariationDesignParameters(parameters); |
| 36 |
} |
| 37 |
|
| 38 |
SkFontStyle SkTypeface_proxy::onGetFontStyle() const { |
| 39 |
return fRealTypeface->onGetFontStyle(); |
| 40 |
} |
| 41 |
|
| 42 |
bool SkTypeface_proxy::onGetFixedPitch() const { |
| 43 |
return fRealTypeface->onGetFixedPitch(); |
| 44 |
} |
| 45 |
|
| 46 |
void SkTypeface_proxy::onGetFamilyName(SkString* familyName) const { |
| 47 |
fRealTypeface->onGetFamilyName(familyName); |
| 48 |
} |
| 49 |
|
| 50 |
bool SkTypeface_proxy::onGetPostScriptName(SkString* postScriptName) const { |
| 51 |
return fRealTypeface->getPostScriptName(postScriptName); |
| 52 |
} |
| 53 |
|
| 54 |
int SkTypeface_proxy::onGetResourceName(SkString* resourceName) const { |
| 55 |
return fRealTypeface->getResourceName(resourceName); |
| 56 |
} |
| 57 |
|
| 58 |
SkTypeface::LocalizedStrings* SkTypeface_proxy::onCreateFamilyNameIterator() const { |
| 59 |
return fRealTypeface->createFamilyNameIterator(); |
| 60 |
} |
| 61 |
|
| 62 |
int SkTypeface_proxy::onGetTableTags(SkSpan<SkFontTableTag> tags) const { |
| 63 |
return fRealTypeface->readTableTags(tags); |
| 64 |
} |
| 65 |
|
| 66 |
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 |
|
| 70 |
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 |
|
| 79 |
void SkTypeface_proxy::onFilterRec(SkScalerContextRec* rec) const { |
| 80 |
fRealTypeface->onFilterRec(rec); |
| 81 |
} |
| 82 |
|
| 83 |
void SkTypeface_proxy::onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const { |
| 84 |
fRealTypeface->onGetFontDescriptor(desc, serialize); |
| 85 |
} |
| 86 |
|
| 87 |
void SkTypeface_proxy::getGlyphToUnicodeMap(SkSpan<SkUnichar> glyphToUnicode) const { |
| 88 |
fRealTypeface->getGlyphToUnicodeMap(glyphToUnicode); |
| 89 |
} |
| 90 |
|
| 91 |
void SkTypeface_proxy::getPostScriptGlyphNames(SkString* names) const { |
| 92 |
return fRealTypeface->getPostScriptGlyphNames(names); |
| 93 |
} |
| 94 |
|
| 95 |
std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_proxy::onGetAdvancedMetrics() const { |
| 96 |
return fRealTypeface->onGetAdvancedMetrics(); |
| 97 |
} |
| 98 |
|
| 99 |
void SkTypeface_proxy::onCharsToGlyphs(SkSpan<const SkUnichar> chars, |
| 100 |
SkSpan<SkGlyphID> glyphs) const { |
| 101 |
fRealTypeface->unicharsToGlyphs(chars, glyphs); |
| 102 |
} |
| 103 |
|
| 104 |
int SkTypeface_proxy::onCountGlyphs() const { return fRealTypeface->countGlyphs(); } |
| 105 |
|
| 106 |
void* SkTypeface_proxy::onGetCTFontRef() const { return fRealTypeface->onGetCTFontRef(); } |
| 107 |
|
| 108 |
bool SkTypeface_proxy::onGetKerningPairAdjustments(SkSpan<const SkGlyphID> glyphs, |
| 109 |
SkSpan<int32_t> adjustments) const { |
| 110 |
return fRealTypeface->onGetKerningPairAdjustments(glyphs, adjustments); |
| 111 |
} |
| 112 |
|
| 113 |
SkScalerContext_proxy::SkScalerContext_proxy(std::unique_ptr<SkScalerContext> realScalerContext, |
| 114 |
SkTypeface_proxy& proxyTypeface, |
| 115 |
const SkScalerContextEffects& effects, |
| 116 |
const SkDescriptor* desc) |
| 117 |
: SkScalerContext(proxyTypeface, effects, desc) |
| 118 |
, fRealScalerContext(std::move(realScalerContext)) |
| 119 |
{ } |
| 120 |
|
| 121 |
SkScalerContext::GlyphMetrics SkScalerContext_proxy::generateMetrics(const SkGlyph& glyph, SkArenaAlloc* alloc) { |
| 122 |
return fRealScalerContext->generateMetrics(glyph, alloc); |
| 123 |
} |
| 124 |
|
| 125 |
void SkScalerContext_proxy::generateImage(const SkGlyph& glyph, void* imageBuffer) { |
| 126 |
fRealScalerContext->generateImage(glyph, imageBuffer); |
| 127 |
} |
| 128 |
|
| 129 |
std::optional<SkScalerContext::GeneratedPath> |
| 130 |
SkScalerContext_proxy::generatePath(const SkGlyph& glyph) { |
| 131 |
return fRealScalerContext->generatePath(glyph); |
| 132 |
} |
| 133 |
|
| 134 |
sk_sp<SkDrawable> SkScalerContext_proxy::generateDrawable(const SkGlyph& glyph) { |
| 135 |
return fRealScalerContext->generateDrawable(glyph); |
| 136 |
} |
| 137 |
|
| 138 |
void SkScalerContext_proxy::generateFontMetrics(SkFontMetrics* metrics) { |
| 139 |
fRealScalerContext->generateFontMetrics(metrics); |
| 140 |
} |