README

Milky2018/moon_swash/scale does not have a README file

#
Bounds

#
Format

Mask generator (subset).

Ported from upstream zeno/src/mask.rs (Apache-2.0 OR MIT).

#
PaletteIndex

type PaletteIndex = UInt16

Scaling, hinting and rasterization of visual glyph representations.

This package is an early scaffold ported from upstream swash/src/scale/*. The public data model aims to stay source-compatible with upstream where practical; functional rasterization is implemented incrementally.

#
Placement

#
Point

using @Milky2018/moon_zeno { type Vector as Point }

Two dimensional vector.

#
StrikeIndex

type StrikeIndex = UInt

#
Transform

2D affine transform.

Ported from upstream zeno/src/geometry.rs (Apache-2.0 OR MIT).

#
Vector

Two dimensional vector.

#
Verb

using @Milky2018/moon_zeno { type Verb }

Minimal geometry types used by swash/scale.

Upstream swash depends on the external zeno crate; in MoonBit we depend on Milky2018/moon_zeno and re-export the geometry types used by swash/scale.

#
ColorProxy

type ColorProxy

#
ColorProxy::from_font

#
ColorProxy::layers

fn ColorProxy::layers(self : ColorProxy, data : Bytes, glyph_id : UInt16) -> ColrLayers?

#
ColrLayer

type ColrLayer

#
ColrLayer::color_index

fn ColrLayer::color_index(self : ColrLayer) -> UInt16?

#
ColrLayer::glyph_id

fn ColrLayer::glyph_id(self : ColrLayer) -> UInt16

#
ColrLayers

type ColrLayers

#
ColrLayers::get

fn ColrLayers::get(self : ColrLayers, index : UInt16) -> ColrLayer?

#
ColrLayers::len

fn ColrLayers::len(self : ColrLayers) -> UInt16

#
Content

pub(all) enum Content {
Mask
SubpixelMask
Color
}

Content of a scaled glyph image.

#
Content::default

fn Content::default() -> Content

#
Image

pub struct Image {
source : Source
content : Content
placement :
Placement

data : Array[Byte]
}
fn Image::Image() -> Image

Scaled glyph image.

#
Image::clear

fn Image::clear(self : Image) -> Unit

#
Image::content

fn Image::content(self : Image) -> Content

#
Image::data

fn Image::data(self : Image) -> Bytes

Copying accessor for image data.

Note: this clones the underlying bytes. Prefer Image::data_view() for zero-copy access.

#
Image::data_view

fn Image::data_view(self : Image) -> ArrayView[Byte]

Zero-copy view of the raw image data.

This is preferred over Image::data() when integrating with renderers that can upload from an ArrayView[Byte] directly.

#
Image::placement

#
Image::source

fn Image::source(self : Image) -> Source

#
Image::to_rgba8

fn Image::to_rgba8(self : Image, base_color : Array[Byte]) -> Bool

Converts Mask / SubpixelMask content into an RGBA8 buffer in-place.

  • base_color is [r, g, b, a] (0..255). The output is premultiplied RGBA8, suitable for standard premultiplied-alpha blending.
  • For SubpixelMask, the input stores per-channel coverage in RGB (alpha channel is unused by the rasterizer). We multiply each channel by its corresponding coverage and set output alpha to max(r, g, b) coverage.

Returns false if the image buffer/placement is inconsistent or base_color is invalid.

#
Layer

pub struct Layer {
points : Array[
Vector
]
verbs : Array[
Verb
]
color_index : UInt16?
}

Reference to a layer in a scaled outline.

MoonBit does not currently expose slice borrows, so this is materialized as owned point/verb arrays.

#
Layer::bounds

#
Layer::color_index

fn Layer::color_index(self : Layer) -> UInt16?

#
Layer::points

#
Layer::verbs

#
LayerData

pub struct LayerData {
points_start : Int
points_end : Int
verbs_start : Int
verbs_end : Int
color_index : UInt16?
}

Glyph outline.

Ported from upstream swash/src/scale/outline.rs (Apache-2.0 OR MIT).

Note: MoonBit doesn't currently expose slice borrowing like Rust, so the Layer accessors return index ranges into the shared points/verbs arrays.

#
Outline

pub struct Outline {
layers : Array[LayerData]
points : Array[
Vector
]
verbs : Array[
Verb
]
is_color : Bool
}
fn Outline::Outline() -> Outline

Scaled glyph outline represented as a collection of layers and a sequence of points and verbs.

#
Outline::begin_layer

fn Outline::begin_layer(self : Outline, color_index : UInt16?) -> Unit

Internal builder method (upstream: pub(super)).

#
Outline::bounds

#
Outline::clear

fn Outline::clear(self : Outline) -> Unit

#
Outline::close

fn Outline::close(self : Outline) -> Unit

Internal builder method (upstream: pub(super)).

#
Outline::curve_to

Internal builder method (upstream: pub(super)).

#
Outline::embolden

fn Outline::embolden(self : Outline, x_strength : Double, y_strength : Double) -> Unit

Applies a faux bold to the outline with the specified strengths in the x and y directions.

#
Outline::finish

fn Outline::finish(self : Outline) -> Unit

Internal builder method (upstream: pub(super)).

#
Outline::get

fn Outline::get(self : Outline, index : Int) -> Layer?

#
Outline::is_color

fn Outline::is_color(self : Outline) -> Bool

#
Outline::is_empty

fn Outline::is_empty(self : Outline) -> Bool

#
Outline::layer_data

fn Outline::layer_data(self : Outline, index : Int) -> LayerData?

#
Outline::len

fn Outline::len(self : Outline) -> Int

#
Outline::line_to

fn Outline::line_to(self : Outline, p :
Vector
) -> Unit

Internal builder method (upstream: pub(super)).

#
Outline::move_to

fn Outline::move_to(self : Outline, p :
Vector
) -> Unit

Internal builder method (upstream: pub(super)).

#
Outline::path

Returns path data for the outline.

#
Outline::points

#
Outline::quad_to

Internal builder method (upstream: pub(super)).

#
Outline::set_color

fn Outline::set_color(self : Outline, color : Bool) -> Unit

Internal builder method (upstream: pub(super)).

#
Outline::transform

fn Outline::transform(self : Outline, transform :
Transform
) -> Unit

#
Outline::verbs

#
OutlineWriter

type OutlineWriter

#
Render

pub struct Render {
sources : Array[Source]
format :
Format

offset :
Vector

transform :
Transform
?
embolden : Double
foreground : Array[Byte]
style :
Style

}
fn Render::Render(sources : Array[Source]) -> Render

Renderer scaffolding.

Ported from upstream swash::scale::Render.

#
Render::default_color

fn Render::default_color(self : Render, color : Array[Byte]) -> Render

#
Render::embolden

fn Render::embolden(self : Render, strength : Double) -> Render

#
Render::format

fn Render::format(self : Render, format :
Format
) -> Render

#
Render::offset

fn Render::offset(self : Render, offset :
Vector
) -> Render

#
Render::render

fn Render::render(self : Render, scaler : Scaler, glyph_id : UInt16) -> Image?

#
Render::render_into

fn Render::render_into(self : Render, scaler : Scaler, glyph_id : UInt16, image : Image) -> Bool

#
Render::style

fn Render::style(self : Render, style :
Style
) -> Render

#
Render::transform

fn Render::transform(self : Render, transform :
Transform
?) -> Render

#
ScaleContext

pub struct ScaleContext {
// private fields
}
fn ScaleContext::ScaleContext() -> ScaleContext

#
ScaleContext::builder

#
ScaleContext::builder_with_id

fn ScaleContext::builder_with_id(self : ScaleContext, font :
FontRef
, id : (UInt64, UInt64)) -> ScalerBuilder

Creates a builder for constructing a scaler with this context, specified font and a custom unique identifier.

#
ScaleContext::with_max_entries

fn ScaleContext::with_max_entries(max_entries : Int) -> ScaleContext

Creates a new scaling context with the specified maximum number of cache entries.

This mirrors the upstream API. The value is clamped to 1..=64.

#
Scaler

type Scaler

#
Scaler::has_bitmaps

fn Scaler::has_bitmaps(self : Scaler) -> Bool

#
Scaler::has_color_bitmaps

fn Scaler::has_color_bitmaps(self : Scaler) -> Bool

#
Scaler::has_color_outlines

fn Scaler::has_color_outlines(self : Scaler) -> Bool

#
Scaler::has_outlines

fn Scaler::has_outlines(self : Scaler) -> Bool

#
Scaler::hint

fn Scaler::hint(self : Scaler) -> Bool

#
Scaler::scale_bitmap

fn Scaler::scale_bitmap(self : Scaler, glyph_id : UInt16, strike : StrikeWith) -> Image?

#
Scaler::scale_bitmap_into

fn Scaler::scale_bitmap_into(self : Scaler, glyph_id : UInt16, strike : StrikeWith, image : Image) -> Bool

#
Scaler::scale_color_bitmap

fn Scaler::scale_color_bitmap(self : Scaler, glyph_id : UInt16, strike : StrikeWith) -> Image?

#
Scaler::scale_color_bitmap_into

fn Scaler::scale_color_bitmap_into(self : Scaler, glyph_id : UInt16, strike : StrikeWith, image : Image) -> Bool

#
Scaler::scale_color_outline

fn Scaler::scale_color_outline(self : Scaler, glyph_id : UInt16) -> Outline?

#
Scaler::scale_color_outline_into

fn Scaler::scale_color_outline_into(self : Scaler, glyph_id : UInt16, outline : Outline) -> Bool

#
Scaler::scale_outline

fn Scaler::scale_outline(_self : Scaler, _glyph_id : UInt16) -> Outline?

#
Scaler::scale_outline_into

fn Scaler::scale_outline_into(self : Scaler, glyph_id : UInt16, outline : Outline) -> Bool

#
Scaler::size

fn Scaler::size(self : Scaler) -> Double

#
ScalerBuilder

type ScalerBuilder

Builder for configuring a scaler.

#
ScalerBuilder::build

fn ScalerBuilder::build(self : ScalerBuilder) -> Scaler

#
ScalerBuilder::hint

fn ScalerBuilder::hint(self : ScalerBuilder, yes : Bool) -> ScalerBuilder

#
ScalerBuilder::normalized_coords

fn ScalerBuilder::normalized_coords(self : ScalerBuilder, coords : ArrayView[Int]) -> ScalerBuilder

#
ScalerBuilder::size

fn ScalerBuilder::size(self : ScalerBuilder, ppem : Double) -> ScalerBuilder

#
ScalerBuilder::variations

#
ScalerProxy

type ScalerProxy

#
ScalerProxy::from_font

#
Source

pub(all) enum Source {
Outline
ColorOutline(UInt16)
Bitmap(StrikeWith)
ColorBitmap(StrikeWith)
}

Glyph sources for the renderer.

#
Source::default

fn Source::default() -> Source

#
StrikeWith

pub(all) enum StrikeWith {
ExactSize
BestFit
LargestSize
Index(UInt)
}

Bitmap strike selection mode.

#
blit

fn blit(mask : Array[Byte], mask_width : UInt, mask_height : UInt, x : Int, y : Int, color : Array[Byte], target : Array[Byte], target_width : UInt, target_height : UInt) -> Unit

Alpha blends an 8-bit mask tinted with color into a target RGBA buffer.

#
inflate_zlib

fn inflate_zlib(data : Bytes) -> Array[Byte] raise
YaziError

Inflates a zlib stream.

In PNG this is used for concatenated IDAT data.

#
is_png

fn is_png(data : Bytes) -> Bool

Returns true if the data begins with the PNG signature.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io