ui_access

module pkg::alloy::text::font::facesource

A font face read from TrueType data: where its tables are, its metrics, characters to glyphs, advances and outlines. Its bytes are kept as given, read in place.

type FaceBytessource

exp type FaceBytes = enum

A face's bytes: static ones, as the bundled fonts', the program's, a file's read whole, or one mapped (the system's fallback faces), whose pages are read only as they are touched.

Variants

Static: &[u8]
Owned: Vector<u8>
Read: *[u8]
Mapped: KeptMappedFile

Functions

fn viewsource

exp fn view(self b: &FaceBytes) -> &[u8]

type GlyphTablesource

exp type GlyphTable = enum

Where a face's outlines are: TrueType's glyf with its loca, or a CFF or CFF2 table pkg::alloy::text_fonts read and draws.

Variants

TrueType: TrueTypeGlyphs
Cff: *Outlines
Nothing

no outlines (or none read)

interface Outlinessource

exp interface Outlines

Outlines another package draws (text_fonts' CFF and CFF2).

Required functions

fn draw(self: &, face: &Face, glyph: u32, out: &var Outline);

the glyph's outline at the face's position on its axes

type FontFormatssource

exp type FontFormats = struct

What pkg::alloy::text_fonts installs on the fonts (install_formats), kept by each face read after: CFF and CFF2 outlines, variable faces and color glyphs, beyond TrueType's outlines.

Fields

exp read: (&var Face, &FaceTables) -> bool

reads what TrueType's reading leaves of the face from its tables: false when it does not read

exp at: (&Face, &[f32]) -> Face

the face at the user values on its axes, one an axis in fvar's order (its default for those not given)

exp named_instances: (&Face) -> Vector<NamedInstance>
exp advance: (&Face, u32, f32) -> f32

the glyph's advance at the face's position, from hmtx's

exp device_delta: (&Face, u64, u32) -> f32

a variation index device table's delta there (device_delta)

exp vary_points: (&Face, u32, &var Vector<Moved>, &[u32])

the points moved by the glyph's gvar deltas there

exp is_color: (&Face, u32) -> bool

whether the face draws the glyph in color

exp color_glyph: (&Face, u32, f32, f32, &TextColor) -> Option<ColorMask>

a color glyph's pixels at the size in pixels, moved right by the shift, the text's color where its palette takes it

type Axissource

exp type Axis = struct

An axis of fvar, in its user values.

Fields

exp tag: u32
exp minimum: f32
exp default: f32
exp maximum: f32
exp hidden: bool

type NamedInstancesource

exp type NamedInstance = struct

A named instance of fvar: its subfamily's name and user values.

Fields

exp name: u32

in name

exp values: Vector<f32>

type TrueTypeGlyphssource

exp type TrueTypeGlyphs = struct

Fields

exp glyf: u64
exp loca: u64
exp long_loca: bool

type CharacterMapsource

exp type CharacterMap = enum

The cmap subtable a face maps characters by, at its offset.

Variants

Segments: u64

format 4, the Basic Multilingual Plane

Groups: u64

format 12, every plane

SameGlyphs: u64

format 13, ranges of characters showing one glyph

type Facesource

exp type Face = struct

Fields

exp bytes: FaceBytes
exp units_per_em: f32 = 1000.0
exp ascender: f32 = 0.0

font units, up

exp descender: f32 = 0.0

negative

exp line_gap: f32 = 0.0
exp glyph_count: u32 = 0
exp weight: u32 = 400

OS/2's usWeightClass, 400 regular, 700 bold

exp embolden: f32 = 0.0

synthetic bold: how much thicker its outlines and wider its advances are, in font units (HarfBuzz's, after FreeType's em / 24)

exp underline_position: f32 = 0.0
exp underline_thickness: f32 = 0.0
exp strikeout_position: f32 = 0.0
exp strikeout_thickness: f32 = 0.0
exp metric_count: u32 = 0
exp cmap: CharacterMap
exp sequences: Option<u64> = ::None

cmap's variation sequences, format 14

exp glyphs: GlyphTable
exp hmtx: u64

where its tables sit

exp kern: Option<u64>
exp gsub: Option<u64>
exp gpos: Option<u64>
exp gdef: Option<u64>
exp gsub_sets: LookupSets = LookupSets::none()
exp gpos_sets: LookupSets = LookupSets::none()
exp axes: Vector<Axis> = Vector<Axis>::empty()

a variable face's axes, where on them it is (normalized, none at the default) and the tables varying it

exp values: Vector<f32> = Vector<f32>::empty()

in the axes' user values, none for the default

exp coords: Vector<f32> = Vector<f32>::empty()
exp variations: VariationTables = VariationTables {}
exp gsub_variation: Option<u64> = ::None

the feature variations GSUB and GPOS make there

exp gpos_variation: Option<u64> = ::None
exp hvar_scalars: Vector<f32> = Vector<f32>::empty()

the scalars there of the regions of HVAR's, GDEF's and CFF2's variation stores, none at the default

exp gdef_scalars: Vector<f32> = Vector<f32>::empty()
exp cff_scalars: Vector<f32> = Vector<f32>::empty()
exp ascii: [u64 : 2] = [0, 0]

which printable ASCII characters it has glyphs for, a bit each

exp name: u64 = 0

its name table, 0 for none

exp colors: ColorTables = ColorTables {}
exp formats: Option<FontFormats> = ::None

the formats text_fonts installed when it was read

Functions

type ColorTablessource

exp type ColorTables = struct

Where a face's color glyphs' tables sit (text_fonts' color.alloy and bitmaps.alloy).

Fields

exp colr: Option<u64> = ::None
exp cpal: Option<u64> = ::None
exp cblc: Option<u64> = ::None
exp cbdt: Option<u64> = ::None
exp sbix: Option<u64> = ::None

Functions

fn anysource

exp fn any(self t: &ColorTables) -> bool

Whether the face has color glyphs.

type VariationTablessource

exp type VariationTables = struct

Where a variable face's tables sit.

Fields

exp fvar: Option<u64> = ::None
exp avar: Option<u64> = ::None
exp gvar: Option<u64> = ::None
exp hvar: Option<u64> = ::None
exp mvar: Option<u64> = ::None

fn Face::readsource

exp fn Face::read(bytes: FaceBytes, index: u32, formats: Option<FontFormats>) -> Option<Face>

The face, or None when the data is no font this reads; a collection's face by index. TrueType's outlines are read here, the rest by the formats text_fonts installs, without which a CFF face has no outlines and a variable one is at its default.

fn variablesource

exp fn variable(self face: &Face) -> bool

Whether the face has axes to vary along.

fn axissource

exp fn axis(self face: &Face, name: &[u8]) -> Option<u64>

The index of the face's axis of the tag, if it has one.

fn sharedsource

exp fn shared(self face: &Face) -> Face

An instance of the face, the same until changed: reading its bytes and sharing its lookup sets, which must outlive it.

fn device_deltasource

exp fn device_delta(self face: &Face, base: u64, offset: u32) -> f32

A variation index device table's delta at the face's position, rounded to whole units as HarfBuzz rounds it; 0 for any other device table.

type FaceTablessource

exp type FaceTables = struct

Where a face's tables sit, 0 for those it lacks.

Fields

exp head: u64 = 0
exp hhea: u64 = 0
exp maxp: u64 = 0
exp os2: u64 = 0
exp post: u64 = 0
exp cmap: u64 = 0
exp glyf: u64 = 0
exp loca: u64 = 0
exp cff: u64 = 0
exp cff2: u64 = 0
exp hmtx: u64 = 0
exp kern: u64 = 0
exp gsub: u64 = 0
exp gpos: u64 = 0
exp gdef: u64 = 0
exp fvar: u64 = 0
exp avar: u64 = 0
exp gvar: u64 = 0
exp hvar: u64 = 0
exp mvar: u64 = 0
exp name: u64 = 0
exp colr: u64 = 0
exp cpal: u64 = 0
exp cblc: u64 = 0
exp cbdt: u64 = 0
exp sbix: u64 = 0

fn variation_glyphsource

exp fn variation_glyph(self face: &Face, c: u32, selector: u32) -> Option<u32>

The glyph for the character followed by the variation selector, if the face maps the sequence: its own, or the character's where the sequence takes the default glyph.

fn datasource

exp fn data(self face: &Face) -> &[u8]

fn covers_asciisource

exp fn covers_ascii(self face: &Face) -> bool

Whether the face has every printable ASCII character.

fn coverssource

exp fn covers(self face: &Face, text: &[u8], start: u64, end: u64) -> bool

Whether the face has glyphs for every character of the text from start to end but those default ignorable, which shaping may leave out.

fn postscript_namesource

exp fn postscript_name(self face: &Face) -> String

The face's PostScript name (name ID 6), empty when it has none.

fn postscript_name_atsource

exp fn postscript_name_at(d: &[u8], index: u32) -> Option<String>

The PostScript name of a font's face by its index in a collection, read from its name table alone; None past the collection's faces.

fn glyph_ofsource

exp fn glyph_of(self face: &Face, c: u32) -> u32

The glyph for the character, 0 (.notdef) when the face has none.

fn advancesource

exp fn advance(self face: &Face, glyph: u32) -> f32

The glyph's horizontal advance, in font units: hmtx's, moved at a variable face's position (text_fonts').

fn hmtx_advancesource

exp fn hmtx_advance(self face: &Face, glyph: u32) -> f32

The glyph's advance in hmtx, whatever the face's position.

fn left_side_bearingsource

exp fn left_side_bearing(self face: &Face, glyph: u32) -> f32

The glyph's left side bearing in hmtx.

fn component_countsource

exp fn component_count(g: &[u8]) -> u64

How many components a composite glyph's data lists.

fn kerningsource

exp fn kerning(self face: &Face, left: u32, right: u32) -> f32

The legacy kern table's adjustment between the two glyphs, in font units: the sum of its horizontal subtables' of formats 0 (pairs) and 2 (classes), as HarfBuzz reads them; cross-stream ones left out.

fn glyph_datasource

exp fn glyph_data(self face: &Face, table: &TrueTypeGlyphs, glyph: u32) -> &[u8]

The glyph's outline data in glyf: none for a glyph past the face's or without an outline.