module 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.
FaceBytesviewGlyphTableOutlinesFontFormatsAxisNamedInstanceTrueTypeGlyphsCharacterMapFaceColorTablesanyVariationTablesFace::readvariableaxisshareddevice_deltaFaceTablesvariation_glyphdatacovers_asciicoverspostscript_namepostscript_name_atglyph_ofadvancehmtx_advanceleft_side_bearingcomponent_countkerningglyph_data
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: TrueTypeGlyphsCff: *OutlinesNothingno 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) -> boolreads what TrueType's reading leaves of the face from its tables: false when it does not read
exp at: (&Face, &[f32]) -> Facethe 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) -> f32the glyph's advance at the face's position, from
hmtx'sexp device_delta: (&Face, u64, u32) -> f32a 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
gvardeltas thereexp is_color: (&Face, u32) -> boolwhether 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: u32exp minimum: f32exp default: f32exp maximum: f32
type NamedInstancesource
exp type NamedInstance = struct
A named instance of fvar: its subfamily's name and user values.
Fields
exp name: u32in
nameexp values: Vector<f32>
type TrueTypeGlyphssource
exp type TrueTypeGlyphs = struct
Fields
exp glyf: u64exp loca: u64exp long_loca: bool
type CharacterMapsource
exp type CharacterMap = enum
The cmap subtable a face maps characters by, at its offset.
Variants
Segments: u64format 4, the Basic Multilingual Plane
Groups: u64format 12, every plane
SameGlyphs: u64format 13, ranges of characters showing one glyph
type Facesource
exp type Face = struct
Fields
exp bytes: FaceBytesexp units_per_em: f32 = 1000.0exp ascender: f32 = 0.0font units, up
exp descender: f32 = 0.0negative
exp line_gap: f32 = 0.0exp glyph_count: u32 = 0exp weight: u32 = 400OS/2's usWeightClass, 400 regular, 700 bold
exp embolden: f32 = 0.0synthetic 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.0exp underline_thickness: f32 = 0.0exp strikeout_position: f32 = 0.0exp strikeout_thickness: f32 = 0.0exp metric_count: u32 = 0exp cmap: CharacterMapexp sequences: Option<u64> = ::Nonecmap's variation sequences, format 14
exp glyphs: GlyphTableexp hmtx: u64where 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> = ::Nonethe feature variations GSUB and GPOS make there
exp gpos_variation: Option<u64> = ::Noneexp 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 = 0its
nametable, 0 for noneexp colors: ColorTables = ColorTables {}exp formats: Option<FontFormats> = ::Nonethe formats text_fonts installed when it was read
Functions
exp fn Face::read(bytes: FaceBytes, index: u32, formats: Option<FontFormats>) -> Option<Face>exp fn variable(self face: &Face) -> boolexp fn axis(self face: &Face, name: &[u8]) -> Option<u64>exp fn shared(self face: &Face) -> Faceexp fn device_delta(self face: &Face, base: u64, offset: u32) -> f32exp fn variation_glyph(self face: &Face, c: u32, selector: u32) -> Option<u32>exp fn data(self face: &Face) -> &[u8]exp fn covers_ascii(self face: &Face) -> boolexp fn covers(self face: &Face, text: &[u8], start: u64, end: u64) -> boolexp fn postscript_name(self face: &Face) -> Stringexp fn glyph_of(self face: &Face, c: u32) -> u32exp fn advance(self face: &Face, glyph: u32) -> f32exp fn hmtx_advance(self face: &Face, glyph: u32) -> f32exp fn left_side_bearing(self face: &Face, glyph: u32) -> f32exp fn kerning(self face: &Face, left: u32, right: u32) -> f32exp fn glyph_data(self face: &Face, table: &TrueTypeGlyphs, glyph: u32) -> &[u8]exp fn outline(self face: &Face, glyph: u32) -> Outlineexp fn drawn_outline(self face: &Face, glyph: u32) -> Outlineexp fn extents(self face: &Face, glyph: u32) -> Option<Extents>
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> = ::Noneexp cpal: Option<u64> = ::Noneexp cblc: Option<u64> = ::Noneexp cbdt: Option<u64> = ::Noneexp 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> = ::Noneexp avar: Option<u64> = ::Noneexp gvar: Option<u64> = ::Noneexp hvar: Option<u64> = ::Noneexp 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 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 = 0exp hhea: u64 = 0exp maxp: u64 = 0exp os2: u64 = 0exp post: u64 = 0exp cmap: u64 = 0exp glyf: u64 = 0exp loca: u64 = 0exp cff: u64 = 0exp cff2: u64 = 0exp hmtx: u64 = 0exp kern: u64 = 0exp gsub: u64 = 0exp gpos: u64 = 0exp gdef: u64 = 0exp fvar: u64 = 0exp avar: u64 = 0exp gvar: u64 = 0exp hvar: u64 = 0exp mvar: u64 = 0exp name: u64 = 0exp colr: u64 = 0exp cpal: u64 = 0exp cblc: u64 = 0exp cbdt: u64 = 0exp 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.