blob: ece4b8165d2ba00b7e4e9f89b469aa7da082302e [file] [log] [blame]
* Copyright 2023 Google Inc.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#ifndef SkTypeface_Fontations_DEFINED
#define SkTypeface_Fontations_DEFINED
#include "include/core/SkStream.h"
#include "include/core/SkTypeface.h"
#include "src/core/SkAdvancedTypefaceMetrics.h"
#include "src/core/SkScalerContext.h"
#include "src/ports/fontations/gen/src/"
#include <memory>
class SkStreamAsset;
/** SkTypeface implementation based on Google Fonts Fontations Rust libraries. */
class SkTypeface_Fontations : public SkTypeface {
SkTypeface_Fontations(std::unique_ptr<SkStreamAsset> font_data);
const fontations_ffi::BridgeFontRef& getBridgeFontRef() { return *fBridgeFontRef; }
std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override { return nullptr; }
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
std::unique_ptr<SkScalerContext> onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const override;
void onFilterRec(SkScalerContextRec*) const override;
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override {
return nullptr;
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override {}
void onCharsToGlyphs(const SkUnichar* chars, int count, SkGlyphID glyphs[]) const override;
int onCountGlyphs() const override;
void getPostScriptGlyphNames(SkString*) const override {}
void getGlyphToUnicodeMap(SkUnichar*) const override {}
int onGetUPEM() const override;
void onGetFamilyName(SkString* familyName) const override;
bool onGetPostScriptName(SkString*) const override;
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
bool onGlyphMaskNeedsCurrentColor() const override { return false; }
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
int coordinateCount) const override {
return 0;
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
int parameterCount) const override {
return 0;
int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override { return 0; }
sk_sp<SkData> fFontData;
// fBridgeFontRef accesses the data in fFontData. fFontData needs to be kept around for the
// lifetime of fBridgeFontRef to safely request parsed data.
rust::Box<::fontations_ffi::BridgeFontRef> fBridgeFontRef;
#endif // SkTypeface_Fontations_DEFINED