#include "include/ports/SkTypeface_fontations.h"
#include "include/codec/SkCodec.h"
#include "include/codec/SkPngDecoder.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkFontMetrics.h"
#include "include/core/SkImage.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkStream.h"
#include "include/effects/SkGradientShader.h"
#include "include/pathops/SkPathOps.h"
#include "src/core/SkFontDescriptor.h"
#include "src/core/SkFontPriv.h"
#include "src/ports/SkTypeface_fontations_priv.h"
#include "src/ports/fontations/src/skpath_bridge.h"
namespace {
[[maybe_unused]] static inline const constexpr bool kSkShowTextBlitCoverage = …;
sk_sp<SkData> streamToData(const std::unique_ptr<SkStreamAsset>& font_data) { … }
rust::Box<::fontations_ffi::BridgeFontRef> make_bridge_font_ref(sk_sp<SkData> fontData,
uint32_t index) { … }
static_assert …;
rust::Box<fontations_ffi::BridgeNormalizedCoords> make_normalized_coords(
fontations_ffi::BridgeFontRef const& bridgeFontRef,
const SkFontArguments::VariationPosition& variationPosition) { … }
SkMatrix SkMatrixFromFontationsTransform(const fontations_ffi::Transform& transformArg) { … }
bool isLCD(const SkScalerContextRec& rec) { … }
bool bothZero(SkScalar a, SkScalar b) { … }
bool isAxisAligned(const SkScalerContextRec& rec) { … }
}
sk_sp<SkTypeface> SkTypeface_Make_Fontations(std::unique_ptr<SkStreamAsset> fontData,
const SkFontArguments& args) { … }
SkTypeface_Fontations::SkTypeface_Fontations(
sk_sp<SkData> fontData,
const SkFontStyle& style,
uint32_t ttcIndex,
rust::Box<fontations_ffi::BridgeFontRef>&& fontRef,
rust::Box<fontations_ffi::BridgeMappingIndex>&& mappingIndex,
rust::Box<fontations_ffi::BridgeNormalizedCoords>&& normalizedCoords,
rust::Box<fontations_ffi::BridgeOutlineCollection>&& outlines,
rust::Vec<uint32_t>&& palette)
: … { … }
sk_sp<SkTypeface> SkTypeface_Fontations::MakeFromStream(std::unique_ptr<SkStreamAsset> stream,
const SkFontArguments& args) { … }
sk_sp<SkTypeface> SkTypeface_Fontations::MakeFromData(sk_sp<SkData> data,
const SkFontArguments& args) { … }
namespace sk_fontations {
void PathGeometrySink::going_to(SkPoint point) { … }
bool PathGeometrySink::current_is_not(SkPoint point) { … }
void PathGeometrySink::move_to(float x, float y) { … }
void PathGeometrySink::line_to(float x, float y) { … }
void PathGeometrySink::quad_to(float cx0, float cy0, float x, float y) { … }
void PathGeometrySink::curve_to(float cx0, float cy0, float cx1, float cy1, float x, float y) { … }
void PathGeometrySink::close() { … }
SkPath PathGeometrySink::into_inner() && { … }
AxisWrapper::AxisWrapper(SkFontParameters::Variation::Axis axisArray[], size_t axisCount)
: … { … }
bool AxisWrapper::populate_axis(
size_t i, uint32_t axisTag, float min, float def, float max, bool hidden) { … }
size_t AxisWrapper::size() const { … }
}
int SkTypeface_Fontations::onGetUPEM() const { … }
void SkTypeface_Fontations::onGetFamilyName(SkString* familyName) const { … }
bool SkTypeface_Fontations::onGetPostScriptName(SkString* postscriptName) const { … }
bool SkTypeface_Fontations::onGlyphMaskNeedsCurrentColor() const { … }
void SkTypeface_Fontations::onCharsToGlyphs(const SkUnichar* chars,
int count,
SkGlyphID glyphs[]) const { … }
int SkTypeface_Fontations::onCountGlyphs() const { … }
void SkTypeface_Fontations::getGlyphToUnicodeMap(SkUnichar* codepointForGlyphMap) const { … }
void SkTypeface_Fontations::onFilterRec(SkScalerContextRec* rec) const { … }
class SkrifaLocalizedStrings : public SkTypeface::LocalizedStrings { … };
SkTypeface::LocalizedStrings* SkTypeface_Fontations::onCreateFamilyNameIterator() const { … }
class SkFontationsScalerContext : public SkScalerContext { … };
std::unique_ptr<SkStreamAsset> SkTypeface_Fontations::onOpenStream(int* ttcIndex) const { … }
sk_sp<SkTypeface> SkTypeface_Fontations::onMakeClone(const SkFontArguments& args) const { … }
std::unique_ptr<SkScalerContext> SkTypeface_Fontations::onCreateScalerContext(
const SkScalerContextEffects& effects, const SkDescriptor* desc) const { … }
std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_Fontations::onGetAdvancedMetrics() const { … }
void SkTypeface_Fontations::onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const { … }
size_t SkTypeface_Fontations::onGetTableData(SkFontTableTag tag,
size_t offset,
size_t length,
void* data) const { … }
int SkTypeface_Fontations::onGetTableTags(SkFontTableTag tags[]) const { … }
int SkTypeface_Fontations::onGetVariationDesignPosition(
SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const { … }
int SkTypeface_Fontations::onGetVariationDesignParameters(
SkFontParameters::Variation::Axis parameters[], int parameterCount) const { … }
namespace sk_fontations {
namespace {
const uint16_t kForegroundColorPaletteIndex = …;
void populateStopsAndColors(std::vector<SkScalar>& dest_stops,
std::vector<SkColor4f>& dest_colors,
const SkSpan<const SkColor>& palette,
SkColor foregroundColor,
fontations_ffi::BridgeColorStops& color_stops) { … }
SkColor4f lerpSkColor(SkColor4f c0, SkColor4f c1, float t) { … }
enum TruncateStops { … };
void truncateToStopInterpolating(SkScalar zeroRadiusStop,
std::vector<SkColor4f>& colors,
std::vector<SkScalar>& stops,
TruncateStops truncateStops) { … }
inline SkBlendMode ToSkBlendMode(uint16_t colrV1CompositeMode) { … }
inline SkTileMode ToSkTileMode(uint8_t extendMode) { … }
}
ColorPainter::ColorPainter(SkFontationsScalerContext& scaler_context,
SkCanvas& canvas,
SkSpan<const SkColor> palette,
SkColor foregroundColor,
bool antialias,
uint16_t upem)
: … { … }
void ColorPainter::push_transform(const fontations_ffi::Transform& transform_arg) { … }
void ColorPainter::pop_transform() { … }
void ColorPainter::push_clip_glyph(uint16_t glyph_id) { … }
void ColorPainter::push_clip_rectangle(float x_min, float y_min, float x_max, float y_max) { … }
void ColorPainter::pop_clip() { … }
void ColorPainter::configure_solid_paint(uint16_t palette_index, float alpha, SkPaint& paint) { … }
void ColorPainter::fill_solid(uint16_t palette_index, float alpha) { … }
void ColorPainter::fill_glyph_solid(uint16_t glyph_id, uint16_t palette_index, float alpha) { … }
void ColorPainter::configure_linear_paint(const fontations_ffi::FillLinearParams& linear_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode,
SkPaint& paint,
SkMatrix* paintTransform) { … }
void ColorPainter::fill_linear(const fontations_ffi::FillLinearParams& linear_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode) { … }
void ColorPainter::fill_glyph_linear(uint16_t glyph_id,
const fontations_ffi::Transform& transform,
const fontations_ffi::FillLinearParams& linear_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode) { … }
void ColorPainter::configure_radial_paint(
const fontations_ffi::FillRadialParams& fill_radial_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode,
SkPaint& paint,
SkMatrix* paintTransform) { … }
void ColorPainter::fill_radial(const fontations_ffi::FillRadialParams& fill_radial_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode) { … }
void ColorPainter::fill_glyph_radial(uint16_t glyph_id,
const fontations_ffi::Transform& transform,
const fontations_ffi::FillRadialParams& fill_radial_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode) { … }
void ColorPainter::configure_sweep_paint(const fontations_ffi::FillSweepParams& sweep_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode,
SkPaint& paint,
SkMatrix* paintTransform) { … }
void ColorPainter::fill_sweep(const fontations_ffi::FillSweepParams& sweep_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode) { … }
void ColorPainter::fill_glyph_sweep(uint16_t glyph_id,
const fontations_ffi::Transform& transform,
const fontations_ffi::FillSweepParams& sweep_params,
fontations_ffi::BridgeColorStops& bridge_stops,
uint8_t extend_mode) { … }
void ColorPainter::push_layer(uint8_t compositeMode) { … }
void ColorPainter::pop_layer() { … }
BoundsPainter::BoundsPainter(SkFontationsScalerContext& scaler_context,
SkMatrix initialTransfom,
uint16_t upem)
: … { … }
SkRect BoundsPainter::getBoundingBox() { … }
void BoundsPainter::push_transform(const fontations_ffi::Transform& transform_arg) { … }
void BoundsPainter::pop_transform() { … }
void BoundsPainter::push_clip_glyph(uint16_t glyph_id) { … }
void BoundsPainter::push_clip_rectangle(float x_min, float y_min, float x_max, float y_max) { … }
void BoundsPainter::fill_glyph_solid(uint16_t glyph_id, uint16_t, float) { … }
void BoundsPainter::fill_glyph_radial(uint16_t glyph_id,
const fontations_ffi::Transform&,
const fontations_ffi::FillRadialParams&,
fontations_ffi::BridgeColorStops&,
uint8_t) { … }
void BoundsPainter::fill_glyph_linear(uint16_t glyph_id,
const fontations_ffi::Transform&,
const fontations_ffi::FillLinearParams&,
fontations_ffi::BridgeColorStops&,
uint8_t) { … }
void BoundsPainter::fill_glyph_sweep(uint16_t glyph_id,
const fontations_ffi::Transform&,
const fontations_ffi::FillSweepParams&,
fontations_ffi::BridgeColorStops&,
uint8_t) { … }
}