zztaeha

Rust constants

225 constants in daegun 2.0.0, as the compiler exports them, filed by area: the free ones, and those that hang off a type, such as each script and each name id. Each says what it means and where it goes.

Base

What everything else is built on: errors and their kinds, tags, glyph ids, boxes and orientation. These live at the root of the crate.

GlyphId::NOTDEF
pub const NOTDEF: GlyphId = GlyphId(0);

Glyph 0, the glyph a font draws for a character it has no glyph for.

OpenType keeps the "missing glyph" at index 0, where it goes by the name .notdef. Most fonts draw it as an empty box.

Use it as the fallback where a lookup such as Font::glyph_id answers None. It is also the default of ShapeOptions::not_found_glyph, so a shaped run holds it wherever the font lacked a character, and it is the value GlyphId::default() returns.

use daegun::GlyphId;

// Inter has no glyph for this character, so draw its missing glyph.
let glyph = font.glyph_id('語').unwrap_or(GlyphId::NOTDEF);
assert_eq!(glyph, GlyphId(0));
assert_eq!(GlyphId::NOTDEF, GlyphId::default());

Fonts

Opening a font and asking what it is: its names, its tables, its variation axes and the locations they make, and the caches that keep its work. Font, Location and their kin live at the root of the crate.

NameId::COMPATIBLE_FULL_NAME
pub const COMPATIBLE_FULL_NAME: NameId = NameId(18);

Name ID 18: the compatible full name, for the Macintosh alone, where its font menu should show something other than name ID 4.

NameId::DARK_BACKGROUND_PALETTE
pub const DARK_BACKGROUND_PALETTE: NameId = NameId(24);

Name ID 24: the name of a color font's palette that is meant for dark backgrounds.

NameId::DESCRIPTION
pub const DESCRIPTION: NameId = NameId(10);

Name ID 10: a description of the typeface.

NameId::DESIGNER
pub const DESIGNER: NameId = NameId(9);

Name ID 9: the name of the typeface's designer.

NameId::DESIGNER_URL
pub const DESIGNER_URL: NameId = NameId(12);

Name ID 12: the URL of the typeface's designer.

NameId::FAMILY_NAME
pub const FAMILY_NAME: NameId = NameId(1);

Name ID 1: the family name as older software groups fonts, with at most four styles to a family.

The four are regular, italic, bold and bold italic. A family with more styles is split into several families under this ID, one for its SemiBold for instance, and NameId::TYPOGRAPHIC_FAMILY_NAME names it as a whole. Font::family_name reads that name first and this one second.

NameId::FULL_NAME
pub const FULL_NAME: NameId = NameId(4);

Name ID 4: the full name, family and style together, such as Inter Variable Bold.

NameId::LICENSE_DESCRIPTION
pub const LICENSE_DESCRIPTION: NameId = NameId(13);

Name ID 13: the license description, which says in plain words how the font may be used.

NameId::LICENSE_URL
pub const LICENSE_URL: NameId = NameId(14);

Name ID 14: a URL where more about the font's license can be found.

NameId::LIGHT_BACKGROUND_PALETTE
pub const LIGHT_BACKGROUND_PALETTE: NameId = NameId(23);

Name ID 23: the name of a color font's palette that is meant for light backgrounds.

NameId::MANUFACTURER
pub const MANUFACTURER: NameId = NameId(8);

Name ID 8: the name of the foundry or company that made the font.

NameId::POSTSCRIPT_CID_FINDFONT_NAME
pub const POSTSCRIPT_CID_FINDFONT_NAME: NameId = NameId(20);

Name ID 20: the PostScript CID findfont name, the name a CID-keyed font goes by with PostScript's findfont operator.

NameId::POSTSCRIPT_NAME
pub const POSTSCRIPT_NAME: NameId = NameId(6);

Name ID 6: the PostScript name, a short ASCII name without spaces, such as InterVariable-Bold, that printing and PDF software know the font by.

NameId::SAMPLE_TEXT
pub const SAMPLE_TEXT: NameId = NameId(19);

Name ID 19: sample text, the text the font's maker wants shown as a specimen of it.

NameId::SUBFAMILY_NAME
pub const SUBFAMILY_NAME: NameId = NameId(2);

Name ID 2: the style within the family of name ID 1, by convention Regular, Italic, Bold or Bold Italic.

NameId::TRADEMARK
pub const TRADEMARK: NameId = NameId(7);

Name ID 7: the trademark notice.

NameId::TYPOGRAPHIC_FAMILY_NAME
pub const TYPOGRAPHIC_FAMILY_NAME: NameId = NameId(16);

Name ID 16: the typographic family name, which groups every style of a family however many there are.

A font usually carries it only where it differs from NameId::FAMILY_NAME, which stops at four styles. Font::family_name returns this name where the font has it.

NameId::TYPOGRAPHIC_SUBFAMILY_NAME
pub const TYPOGRAPHIC_SUBFAMILY_NAME: NameId = NameId(17);

Name ID 17: the typographic subfamily name, the style within the typographic family, such as SemiBold.

NameId::UNIQUE_ID
pub const UNIQUE_ID: NameId = NameId(3);

Name ID 3: a string that identifies this font and no other, such as 4.001;git-9221beed3;RSMS;InterVariable-Regular.

NameId::VARIATIONS_POSTSCRIPT_NAME_PREFIX
pub const VARIATIONS_POSTSCRIPT_NAME_PREFIX: NameId = NameId(25);

Name ID 25: the prefix that the PostScript names of a variable font's instances start with.

Inter Variable's is InterVariable. Where an instance has no PostScript name of its own, daegun builds one from this prefix, or from the family name where the font has no prefix. The names at any location but the default leave this ID out, as one instance has no use for it.

NameId::VENDOR_URL
pub const VENDOR_URL: NameId = NameId(11);

Name ID 11: the URL of the font's vendor.

NameId::VERSION_STRING
pub const VERSION_STRING: NameId = NameId(5);

Name ID 5: the version string, by convention Version and a number, such as Version 4.001.

NameId::WWS_FAMILY_NAME
pub const WWS_FAMILY_NAME: NameId = NameId(21);

Name ID 21: the WWS family name, for a family whose members differ only in weight, width and slope.

WWS stands for weight, width and slope. A typographic family that also varies in something else, such as optical size, names each group that varies in those three alone here, for software that sorts styles by them.

NameId::WWS_SUBFAMILY_NAME
pub const WWS_SUBFAMILY_NAME: NameId = NameId(22);

Name ID 22: the WWS subfamily name, the style within the WWS family of name ID 21.

Metrics

A font's metrics in font units, y up: line spacing, the OS/2 and post tables, STAT, tracking and the flags a PDF writer needs. The calls are on Font, and their types are in daegun::metrics.

metrics::DEFAULT_POINT_SIZE
pub const DEFAULT_POINT_SIZE: f64 = 12.0;

The point size a font's tracking is read at when no usable size is given: 12 points.

Font::tracking reads the trak table at this size when its point_size is not finite and above zero. Shaping does the same when ShapeOptions::point_size is None or such a size.

use daegun::metrics::DEFAULT_POINT_SIZE;
use daegun::Orientation;

assert_eq!(DEFAULT_POINT_SIZE, 12.0);
// A size that is no size is read as this one. For a font whose trak table gives 10 units at
// 10 pt and -10 at 20 pt, both answers are 6.
let fallback = font.tracking(f64::NAN, Orientation::Horizontal);
assert_eq!(fallback, font.tracking(DEFAULT_POINT_SIZE, Orientation::Horizontal));
metrics::PdfFlags::FIXED_PITCH
pub const FIXED_PITCH: PdfFlags = PdfFlags(0x01);

Every glyph has the same width, as in a typewriter face.

Font::pdf_flags sets it when the isFixedPitch field of the post table is not 0. It takes the font's word for it and measures no advances. A font without a post table never has the flag.

use daegun::metrics::PdfFlags;
use daegun::Location;

// Noto Color Emoji says that all of its glyphs are one width.
assert!(font.pdf_flags(&Location::default()).contains(PdfFlags::FIXED_PITCH));
metrics::PdfFlags::ITALIC
pub const ITALIC: PdfFlags = PdfFlags(0x40);

The glyphs slant: the font states an italic angle other than 0.

Font::pdf_flags sets it when Font::italic_angle is not 0. It goes by the angle in post, not by the italic bit of OS/2, so an oblique face that states an angle has it as well. At a location other than the default, on a variable font with a slnt axis, it is set where that axis is off 0.

use daegun::metrics::PdfFlags;
use daegun::{Font, Location};

assert!(!font.pdf_flags(&Location::default()).contains(PdfFlags::ITALIC));

// The italic of Irianis ADF states an angle of -13 degrees.
let italic = Font::from_collection(&bytes("Irianisadfstd/IrianisadfstdItalic.ttc"), 0)?;
assert!(italic.pdf_flags(&Location::default()).contains(PdfFlags::ITALIC));
metrics::PdfFlags::NONSYMBOLIC
pub const NONSYMBOLIC: PdfFlags = PdfFlags(0x20);

The font is not a symbol font, and every character it maps, control codes aside, is in the Adobe standard Latin set.

Font::pdf_flags sets it whenever it does not set PdfFlags::SYMBOLIC, so a font has one of the two and never both. A font with no cmap table is nonsymbolic too.

use daegun::metrics::PdfFlags;
use daegun::Location;

// An AAT test font that maps nothing beyond the standard Latin set.
let flags = font.pdf_flags(&Location::default());
assert!(flags.contains(PdfFlags::NONSYMBOLIC));
assert!(!flags.contains(PdfFlags::SYMBOLIC));
metrics::PdfFlags::SCRIPT
pub const SCRIPT: PdfFlags = PdfFlags(0x08);

The glyphs look handwritten, going by the family class of OS/2.

Font::pdf_flags sets it when the class in Os2::family_class, its high byte, is 10, the class for scripts. Nothing is read from the glyphs, so a handwriting font that leaves the class at 0 comes back without it.

use daegun::metrics::PdfFlags;
use daegun::Location;

// Inter is not classed as a script face.
assert!(!font.pdf_flags(&Location::default()).contains(PdfFlags::SCRIPT));
metrics::PdfFlags::SERIF
pub const SERIF: PdfFlags = PdfFlags(0x02);

The glyphs have serifs, going by the family class of OS/2.

Font::pdf_flags sets it when the class in Os2::family_class, its high byte, is one of the serif classes: 1, 2, 3, 4, 5 or 7. Nothing is read from the glyphs, and a font may leave the class at 0. EB Garamond does, so it comes back without the flag for all its serifs.

use daegun::metrics::PdfFlags;
use daegun::Location;

// STIX Two Math records family class 1, the first of the serif classes.
let class = font.os2(&Location::default()).and_then(|os2| os2.family_class).map(|class| class >> 8);
assert_eq!(class, Some(1));
assert!(font.pdf_flags(&Location::default()).contains(PdfFlags::SERIF));
metrics::PdfFlags::SYMBOLIC
pub const SYMBOLIC: PdfFlags = PdfFlags(0x04);

The font holds characters outside the Adobe standard Latin set, or is a symbol font.

Font::pdf_flags follows PDF's rule. The flag is set for a Windows symbol font, one whose cmap has a symbol subtable and none keyed by Unicode. It is also set for any font that maps a character outside the Adobe standard Latin character set, the characters that PDF's built-in Latin encodings cover. Control codes do not count. One character is enough, so a font need not look like a symbol font to carry the flag: Inter has it, and its Greek letters alone would be enough. PdfFlags::NONSYMBOLIC is set in every other case.

use daegun::metrics::PdfFlags;
use daegun::Location;

// Inter maps the Greek letter lambda, which is outside the standard Latin set, so it is symbolic.
assert!(font.glyph_id('λ').is_some());
assert!(font.pdf_flags(&Location::default()).contains(PdfFlags::SYMBOLIC));

Shaping

Text to glyphs placed in font units, one run or the runs of mixed-direction text, and the carets that hit testing reads off them. The calls are on Font, and their types are in daegun::shape.

shape::ShapeOptions::DEFAULT
pub const DEFAULT: ShapeOptions<'static>;

The default options as a constant, the same value ShapeOptions::default() returns.

Being a constant, &ShapeOptions::DEFAULT borrows one static value where &ShapeOptions::default() builds a new one on the stack each call. Every with_ method is a const fn, so options of your own can be constants too.

use daegun::shape::{Direction, ShapeOptions};
use daegun::Location;

const RTL: ShapeOptions = ShapeOptions::DEFAULT.with_direction(Direction::RightToLeft);

let run = font.shape("Wave", &Location::default(), &RTL);
assert_eq!(ShapeOptions::DEFAULT, ShapeOptions::default());

Unicode

Text analysis that needs no font: bidi, grapheme and word boundaries, line breaking, scripts and character properties. Free functions and types in daegun::unicode. Every position is a byte offset where a character starts.

unicode::Script::ADLAM
pub const ADLAM: Script = Script(0);

The Adlam script, ISO 15924 Adlm.

unicode::Script::AHOM
pub const AHOM: Script = Script(1);

The Ahom script, ISO 15924 Ahom.

unicode::Script::ANATOLIAN_HIEROGLYPHS
pub const ANATOLIAN_HIEROGLYPHS: Script = Script(2);

The Anatolian Hieroglyphs script, ISO 15924 Hluw.

unicode::Script::ARABIC
pub const ARABIC: Script = Script(3);

The Arabic script, ISO 15924 Arab.

unicode::Script::ARMENIAN
pub const ARMENIAN: Script = Script(4);

The Armenian script, ISO 15924 Armn.

unicode::Script::AVESTAN
pub const AVESTAN: Script = Script(5);

The Avestan script, ISO 15924 Avst.

unicode::Script::BALINESE
pub const BALINESE: Script = Script(6);

The Balinese script, ISO 15924 Bali.

unicode::Script::BAMUM
pub const BAMUM: Script = Script(7);

The Bamum script, ISO 15924 Bamu.

unicode::Script::BASSA_VAH
pub const BASSA_VAH: Script = Script(8);

The Bassa Vah script, ISO 15924 Bass.

unicode::Script::BATAK
pub const BATAK: Script = Script(9);

The Batak script, ISO 15924 Batk.

unicode::Script::BENGALI
pub const BENGALI: Script = Script(10);

The Bengali script, ISO 15924 Beng.

unicode::Script::BERIA_ERFE
pub const BERIA_ERFE: Script = Script(11);

The Beria Erfe script, ISO 15924 Berf.

unicode::Script::BHAIKSUKI
pub const BHAIKSUKI: Script = Script(12);

The Bhaiksuki script, ISO 15924 Bhks.

unicode::Script::BOPOMOFO
pub const BOPOMOFO: Script = Script(13);

The Bopomofo script, ISO 15924 Bopo.

unicode::Script::BRAHMI
pub const BRAHMI: Script = Script(14);

The Brahmi script, ISO 15924 Brah.

unicode::Script::BRAILLE
pub const BRAILLE: Script = Script(15);

The Braille script, ISO 15924 Brai.

unicode::Script::BUGINESE
pub const BUGINESE: Script = Script(16);

The Buginese script, ISO 15924 Bugi.

unicode::Script::BUHID
pub const BUHID: Script = Script(17);

The Buhid script, ISO 15924 Buhd.

unicode::Script::CANADIAN_ABORIGINAL
pub const CANADIAN_ABORIGINAL: Script = Script(18);

The Canadian Aboriginal script, ISO 15924 Cans.

unicode::Script::CARIAN
pub const CARIAN: Script = Script(19);

The Carian script, ISO 15924 Cari.

unicode::Script::CAUCASIAN_ALBANIAN
pub const CAUCASIAN_ALBANIAN: Script = Script(20);

The Caucasian Albanian script, ISO 15924 Aghb.

unicode::Script::CHAKMA
pub const CHAKMA: Script = Script(21);

The Chakma script, ISO 15924 Cakm.

unicode::Script::CHAM
pub const CHAM: Script = Script(22);

The Cham script, ISO 15924 Cham.

unicode::Script::CHEROKEE
pub const CHEROKEE: Script = Script(23);

The Cherokee script, ISO 15924 Cher.

unicode::Script::CHORASMIAN
pub const CHORASMIAN: Script = Script(24);

The Chorasmian script, ISO 15924 Chrs.

unicode::Script::COMMON
pub const COMMON: Script = Script(25);

The Common script, ISO 15924 Zyyy, which holds the characters many scripts share, such as digits, spaces and punctuation.

unicode::Script::COPTIC
pub const COPTIC: Script = Script(26);

The Coptic script, ISO 15924 Copt.

unicode::Script::CUNEIFORM
pub const CUNEIFORM: Script = Script(27);

The Cuneiform script, ISO 15924 Xsux.

unicode::Script::CYPRIOT
pub const CYPRIOT: Script = Script(28);

The Cypriot script, ISO 15924 Cprt.

unicode::Script::CYPRO_MINOAN
pub const CYPRO_MINOAN: Script = Script(29);

The Cypro Minoan script, ISO 15924 Cpmn.

unicode::Script::CYRILLIC
pub const CYRILLIC: Script = Script(30);

The Cyrillic script, ISO 15924 Cyrl.

unicode::Script::DESERET
pub const DESERET: Script = Script(31);

The Deseret script, ISO 15924 Dsrt.

unicode::Script::DEVANAGARI
pub const DEVANAGARI: Script = Script(32);

The Devanagari script, ISO 15924 Deva.

unicode::Script::DIVES_AKURU
pub const DIVES_AKURU: Script = Script(33);

The Dives Akuru script, ISO 15924 Diak.

unicode::Script::DOGRA
pub const DOGRA: Script = Script(34);

The Dogra script, ISO 15924 Dogr.

unicode::Script::DUPLOYAN
pub const DUPLOYAN: Script = Script(35);

The Duployan script, ISO 15924 Dupl.

unicode::Script::EGYPTIAN_HIEROGLYPHS
pub const EGYPTIAN_HIEROGLYPHS: Script = Script(36);

The Egyptian Hieroglyphs script, ISO 15924 Egyp.

unicode::Script::ELBASAN
pub const ELBASAN: Script = Script(37);

The Elbasan script, ISO 15924 Elba.

unicode::Script::ELYMAIC
pub const ELYMAIC: Script = Script(38);

The Elymaic script, ISO 15924 Elym.

unicode::Script::ETHIOPIC
pub const ETHIOPIC: Script = Script(39);

The Ethiopic script, ISO 15924 Ethi.

unicode::Script::GARAY
pub const GARAY: Script = Script(40);

The Garay script, ISO 15924 Gara.

unicode::Script::GEORGIAN
pub const GEORGIAN: Script = Script(41);

The Georgian script, ISO 15924 Geor.

unicode::Script::GLAGOLITIC
pub const GLAGOLITIC: Script = Script(42);

The Glagolitic script, ISO 15924 Glag.

unicode::Script::GOTHIC
pub const GOTHIC: Script = Script(43);

The Gothic script, ISO 15924 Goth.

unicode::Script::GRANTHA
pub const GRANTHA: Script = Script(44);

The Grantha script, ISO 15924 Gran.

unicode::Script::GREEK
pub const GREEK: Script = Script(45);

The Greek script, ISO 15924 Grek.

unicode::Script::GUJARATI
pub const GUJARATI: Script = Script(46);

The Gujarati script, ISO 15924 Gujr.

unicode::Script::GUNJALA_GONDI
pub const GUNJALA_GONDI: Script = Script(47);

The Gunjala Gondi script, ISO 15924 Gong.

unicode::Script::GURMUKHI
pub const GURMUKHI: Script = Script(48);

The Gurmukhi script, ISO 15924 Guru.

unicode::Script::GURUNG_KHEMA
pub const GURUNG_KHEMA: Script = Script(49);

The Gurung Khema script, ISO 15924 Gukh.

unicode::Script::HAN
pub const HAN: Script = Script(50);

The Han script, ISO 15924 Hani.

unicode::Script::HANGUL
pub const HANGUL: Script = Script(51);

The Hangul script, ISO 15924 Hang.

unicode::Script::HANIFI_ROHINGYA
pub const HANIFI_ROHINGYA: Script = Script(52);

The Hanifi Rohingya script, ISO 15924 Rohg.

unicode::Script::HANUNOO
pub const HANUNOO: Script = Script(53);

The Hanunoo script, ISO 15924 Hano.

unicode::Script::HATRAN
pub const HATRAN: Script = Script(54);

The Hatran script, ISO 15924 Hatr.

unicode::Script::HEBREW
pub const HEBREW: Script = Script(55);

The Hebrew script, ISO 15924 Hebr.

unicode::Script::HIRAGANA
pub const HIRAGANA: Script = Script(56);

The Hiragana script, ISO 15924 Hira.

unicode::Script::IMPERIAL_ARAMAIC
pub const IMPERIAL_ARAMAIC: Script = Script(57);

The Imperial Aramaic script, ISO 15924 Armi.

unicode::Script::INHERITED
pub const INHERITED: Script = Script(58);

The Inherited script, ISO 15924 Zinh, which holds combining marks that take the script of the character they are attached to.

unicode::Script::INSCRIPTIONAL_PAHLAVI
pub const INSCRIPTIONAL_PAHLAVI: Script = Script(59);

The Inscriptional Pahlavi script, ISO 15924 Phli.

unicode::Script::INSCRIPTIONAL_PARTHIAN
pub const INSCRIPTIONAL_PARTHIAN: Script = Script(60);

The Inscriptional Parthian script, ISO 15924 Prti.

unicode::Script::JAVANESE
pub const JAVANESE: Script = Script(61);

The Javanese script, ISO 15924 Java.

unicode::Script::JURCHEN
pub const JURCHEN: Script = Script(62);

The Jurchen script, ISO 15924 Jurc.

unicode::Script::KAITHI
pub const KAITHI: Script = Script(63);

The Kaithi script, ISO 15924 Kthi.

unicode::Script::KANNADA
pub const KANNADA: Script = Script(64);

The Kannada script, ISO 15924 Knda.

unicode::Script::KATAKANA
pub const KATAKANA: Script = Script(65);

The Katakana script, ISO 15924 Kana.

unicode::Script::KAWI
pub const KAWI: Script = Script(66);

The Kawi script, ISO 15924 Kawi.

unicode::Script::KAYAH_LI
pub const KAYAH_LI: Script = Script(67);

The Kayah Li script, ISO 15924 Kali.

unicode::Script::KHAROSHTHI
pub const KHAROSHTHI: Script = Script(68);

The Kharoshthi script, ISO 15924 Khar.

unicode::Script::KHITAN_SMALL_SCRIPT
pub const KHITAN_SMALL_SCRIPT: Script = Script(69);

The Khitan Small Script, ISO 15924 Kits.

unicode::Script::KHMER
pub const KHMER: Script = Script(70);

The Khmer script, ISO 15924 Khmr.

unicode::Script::KHOJKI
pub const KHOJKI: Script = Script(71);

The Khojki script, ISO 15924 Khoj.

unicode::Script::KHUDAWADI
pub const KHUDAWADI: Script = Script(72);

The Khudawadi script, ISO 15924 Sind.

unicode::Script::KIRAT_RAI
pub const KIRAT_RAI: Script = Script(73);

The Kirat Rai script, ISO 15924 Krai.

unicode::Script::LAO
pub const LAO: Script = Script(74);

The Lao script, ISO 15924 Laoo.

unicode::Script::LATIN
pub const LATIN: Script = Script(75);

The Latin script, ISO 15924 Latn.

unicode::Script::LEPCHA
pub const LEPCHA: Script = Script(76);

The Lepcha script, ISO 15924 Lepc.

unicode::Script::LIMBU
pub const LIMBU: Script = Script(77);

The Limbu script, ISO 15924 Limb.

unicode::Script::LINEAR_A
pub const LINEAR_A: Script = Script(78);

The Linear A script, ISO 15924 Lina.

unicode::Script::LINEAR_B
pub const LINEAR_B: Script = Script(79);

The Linear B script, ISO 15924 Linb.

unicode::Script::LISU
pub const LISU: Script = Script(80);

The Lisu script, ISO 15924 Lisu.

unicode::Script::LYCIAN
pub const LYCIAN: Script = Script(81);

The Lycian script, ISO 15924 Lyci.

unicode::Script::LYDIAN
pub const LYDIAN: Script = Script(82);

The Lydian script, ISO 15924 Lydi.

unicode::Script::MAHAJANI
pub const MAHAJANI: Script = Script(83);

The Mahajani script, ISO 15924 Mahj.

unicode::Script::MAKASAR
pub const MAKASAR: Script = Script(84);

The Makasar script, ISO 15924 Maka.

unicode::Script::MALAYALAM
pub const MALAYALAM: Script = Script(85);

The Malayalam script, ISO 15924 Mlym.

unicode::Script::MANDAIC
pub const MANDAIC: Script = Script(86);

The Mandaic script, ISO 15924 Mand.

unicode::Script::MANICHAEAN
pub const MANICHAEAN: Script = Script(87);

The Manichaean script, ISO 15924 Mani.

unicode::Script::MARCHEN
pub const MARCHEN: Script = Script(88);

The Marchen script, ISO 15924 Marc.

unicode::Script::MASARAM_GONDI
pub const MASARAM_GONDI: Script = Script(89);

The Masaram Gondi script, ISO 15924 Gonm.

unicode::Script::MEDEFAIDRIN
pub const MEDEFAIDRIN: Script = Script(90);

The Medefaidrin script, ISO 15924 Medf.

unicode::Script::MEETEI_MAYEK
pub const MEETEI_MAYEK: Script = Script(91);

The Meetei Mayek script, ISO 15924 Mtei.

unicode::Script::MENDE_KIKAKUI
pub const MENDE_KIKAKUI: Script = Script(92);

The Mende Kikakui script, ISO 15924 Mend.

unicode::Script::MEROITIC_CURSIVE
pub const MEROITIC_CURSIVE: Script = Script(93);

The Meroitic Cursive script, ISO 15924 Merc.

unicode::Script::MEROITIC_HIEROGLYPHS
pub const MEROITIC_HIEROGLYPHS: Script = Script(94);

The Meroitic Hieroglyphs script, ISO 15924 Mero.

unicode::Script::MIAO
pub const MIAO: Script = Script(95);

The Miao script, ISO 15924 Plrd.

unicode::Script::MODI
pub const MODI: Script = Script(96);

The Modi script, ISO 15924 Modi.

unicode::Script::MONGOLIAN
pub const MONGOLIAN: Script = Script(97);

The Mongolian script, ISO 15924 Mong.

unicode::Script::MRO
pub const MRO: Script = Script(98);

The Mro script, ISO 15924 Mroo.

unicode::Script::MULTANI
pub const MULTANI: Script = Script(99);

The Multani script, ISO 15924 Mult.

unicode::Script::MYANMAR
pub const MYANMAR: Script = Script(100);

The Myanmar script, ISO 15924 Mymr.

unicode::Script::NABATAEAN
pub const NABATAEAN: Script = Script(101);

The Nabataean script, ISO 15924 Nbat.

unicode::Script::NAG_MUNDARI
pub const NAG_MUNDARI: Script = Script(102);

The Nag Mundari script, ISO 15924 Nagm.

unicode::Script::NANDINAGARI
pub const NANDINAGARI: Script = Script(103);

The Nandinagari script, ISO 15924 Nand.

unicode::Script::NEW_TAI_LUE
pub const NEW_TAI_LUE: Script = Script(104);

The New Tai Lue script, ISO 15924 Talu.

unicode::Script::NEWA
pub const NEWA: Script = Script(105);

The Newa script, ISO 15924 Newa.

unicode::Script::NKO
pub const NKO: Script = Script(106);

The Nko script, ISO 15924 Nkoo.

unicode::Script::NUSHU
pub const NUSHU: Script = Script(107);

The Nushu script, ISO 15924 Nshu.

unicode::Script::NYIAKENG_PUACHUE_HMONG
pub const NYIAKENG_PUACHUE_HMONG: Script = Script(108);

The Nyiakeng Puachue Hmong script, ISO 15924 Hmnp.

unicode::Script::OGHAM
pub const OGHAM: Script = Script(109);

The Ogham script, ISO 15924 Ogam.

unicode::Script::OL_CHIKI
pub const OL_CHIKI: Script = Script(110);

The Ol Chiki script, ISO 15924 Olck.

unicode::Script::OL_ONAL
pub const OL_ONAL: Script = Script(111);

The Ol Onal script, ISO 15924 Onao.

unicode::Script::OLD_HUNGARIAN
pub const OLD_HUNGARIAN: Script = Script(112);

The Old Hungarian script, ISO 15924 Hung.

unicode::Script::OLD_ITALIC
pub const OLD_ITALIC: Script = Script(113);

The Old Italic script, ISO 15924 Ital.

unicode::Script::OLD_NORTH_ARABIAN
pub const OLD_NORTH_ARABIAN: Script = Script(114);

The Old North Arabian script, ISO 15924 Narb.

unicode::Script::OLD_PERMIC
pub const OLD_PERMIC: Script = Script(115);

The Old Permic script, ISO 15924 Perm.

unicode::Script::OLD_PERSIAN
pub const OLD_PERSIAN: Script = Script(116);

The Old Persian script, ISO 15924 Xpeo.

unicode::Script::OLD_SOGDIAN
pub const OLD_SOGDIAN: Script = Script(117);

The Old Sogdian script, ISO 15924 Sogo.

unicode::Script::OLD_SOUTH_ARABIAN
pub const OLD_SOUTH_ARABIAN: Script = Script(118);

The Old South Arabian script, ISO 15924 Sarb.

unicode::Script::OLD_TURKIC
pub const OLD_TURKIC: Script = Script(119);

The Old Turkic script, ISO 15924 Orkh.

unicode::Script::OLD_UYGHUR
pub const OLD_UYGHUR: Script = Script(120);

The Old Uyghur script, ISO 15924 Ougr.

unicode::Script::ORIYA
pub const ORIYA: Script = Script(121);

The Oriya script, ISO 15924 Orya.

unicode::Script::OSAGE
pub const OSAGE: Script = Script(122);

The Osage script, ISO 15924 Osge.

unicode::Script::OSMANYA
pub const OSMANYA: Script = Script(123);

The Osmanya script, ISO 15924 Osma.

unicode::Script::PAHAWH_HMONG
pub const PAHAWH_HMONG: Script = Script(124);

The Pahawh Hmong script, ISO 15924 Hmng.

unicode::Script::PALMYRENE
pub const PALMYRENE: Script = Script(125);

The Palmyrene script, ISO 15924 Palm.

unicode::Script::PAU_CIN_HAU
pub const PAU_CIN_HAU: Script = Script(126);

The Pau Cin Hau script, ISO 15924 Pauc.

unicode::Script::PHAGS_PA
pub const PHAGS_PA: Script = Script(127);

The Phags Pa script, ISO 15924 Phag.

unicode::Script::PHOENICIAN
pub const PHOENICIAN: Script = Script(128);

The Phoenician script, ISO 15924 Phnx.

unicode::Script::PROTO_CUNEIFORM
pub const PROTO_CUNEIFORM: Script = Script(129);

The Proto Cuneiform script, ISO 15924 Pcun.

unicode::Script::PSALTER_PAHLAVI
pub const PSALTER_PAHLAVI: Script = Script(130);

The Psalter Pahlavi script, ISO 15924 Phlp.

unicode::Script::REJANG
pub const REJANG: Script = Script(131);

The Rejang script, ISO 15924 Rjng.

unicode::Script::RUNIC
pub const RUNIC: Script = Script(132);

The Runic script, ISO 15924 Runr.

unicode::Script::SAMARITAN
pub const SAMARITAN: Script = Script(133);

The Samaritan script, ISO 15924 Samr.

unicode::Script::SAURASHTRA
pub const SAURASHTRA: Script = Script(134);

The Saurashtra script, ISO 15924 Saur.

unicode::Script::SEAL
pub const SEAL: Script = Script(135);

The Seal script, ISO 15924 Seal.

unicode::Script::SHARADA
pub const SHARADA: Script = Script(136);

The Sharada script, ISO 15924 Shrd.

unicode::Script::SHAVIAN
pub const SHAVIAN: Script = Script(137);

The Shavian script, ISO 15924 Shaw.

unicode::Script::SIDDHAM
pub const SIDDHAM: Script = Script(138);

The Siddham script, ISO 15924 Sidd.

unicode::Script::SIDETIC
pub const SIDETIC: Script = Script(139);

The Sidetic script, ISO 15924 Sidt.

unicode::Script::SIGNWRITING
pub const SIGNWRITING: Script = Script(140);

The SignWriting script, ISO 15924 Sgnw.

unicode::Script::SINHALA
pub const SINHALA: Script = Script(141);

The Sinhala script, ISO 15924 Sinh.

unicode::Script::SOGDIAN
pub const SOGDIAN: Script = Script(142);

The Sogdian script, ISO 15924 Sogd.

unicode::Script::SORA_SOMPENG
pub const SORA_SOMPENG: Script = Script(143);

The Sora Sompeng script, ISO 15924 Sora.

unicode::Script::SOYOMBO
pub const SOYOMBO: Script = Script(144);

The Soyombo script, ISO 15924 Soyo.

unicode::Script::SUNDANESE
pub const SUNDANESE: Script = Script(145);

The Sundanese script, ISO 15924 Sund.

unicode::Script::SUNUWAR
pub const SUNUWAR: Script = Script(146);

The Sunuwar script, ISO 15924 Sunu.

unicode::Script::SYLOTI_NAGRI
pub const SYLOTI_NAGRI: Script = Script(147);

The Syloti Nagri script, ISO 15924 Sylo.

unicode::Script::SYRIAC
pub const SYRIAC: Script = Script(148);

The Syriac script, ISO 15924 Syrc.

unicode::Script::TAGALOG
pub const TAGALOG: Script = Script(149);

The Tagalog script, ISO 15924 Tglg.

unicode::Script::TAGBANWA
pub const TAGBANWA: Script = Script(150);

The Tagbanwa script, ISO 15924 Tagb.

unicode::Script::TAI_LE
pub const TAI_LE: Script = Script(151);

The Tai Le script, ISO 15924 Tale.

unicode::Script::TAI_THAM
pub const TAI_THAM: Script = Script(152);

The Tai Tham script, ISO 15924 Lana.

unicode::Script::TAI_VIET
pub const TAI_VIET: Script = Script(153);

The Tai Viet script, ISO 15924 Tavt.

unicode::Script::TAI_YO
pub const TAI_YO: Script = Script(154);

The Tai Yo script, ISO 15924 Tayo.

unicode::Script::TAKRI
pub const TAKRI: Script = Script(155);

The Takri script, ISO 15924 Takr.

unicode::Script::TAMIL
pub const TAMIL: Script = Script(156);

The Tamil script, ISO 15924 Taml.

unicode::Script::TANGSA
pub const TANGSA: Script = Script(157);

The Tangsa script, ISO 15924 Tnsa.

unicode::Script::TANGUT
pub const TANGUT: Script = Script(158);

The Tangut script, ISO 15924 Tang.

unicode::Script::TELUGU
pub const TELUGU: Script = Script(159);

The Telugu script, ISO 15924 Telu.

unicode::Script::THAANA
pub const THAANA: Script = Script(160);

The Thaana script, ISO 15924 Thaa.

unicode::Script::THAI
pub const THAI: Script = Script(161);

The Thai script, ISO 15924 Thai.

unicode::Script::TIBETAN
pub const TIBETAN: Script = Script(162);

The Tibetan script, ISO 15924 Tibt.

unicode::Script::TIFINAGH
pub const TIFINAGH: Script = Script(163);

The Tifinagh script, ISO 15924 Tfng.

unicode::Script::TIRHUTA
pub const TIRHUTA: Script = Script(164);

The Tirhuta script, ISO 15924 Tirh.

unicode::Script::TODHRI
pub const TODHRI: Script = Script(165);

The Todhri script, ISO 15924 Todr.

unicode::Script::TOLONG_SIKI
pub const TOLONG_SIKI: Script = Script(166);

The Tolong Siki script, ISO 15924 Tols.

unicode::Script::TOTO
pub const TOTO: Script = Script(167);

The Toto script, ISO 15924 Toto.

unicode::Script::TULU_TIGALARI
pub const TULU_TIGALARI: Script = Script(168);

The Tulu Tigalari script, ISO 15924 Tutg.

unicode::Script::UGARITIC
pub const UGARITIC: Script = Script(169);

The Ugaritic script, ISO 15924 Ugar.

unicode::Script::VAI
pub const VAI: Script = Script(170);

The Vai script, ISO 15924 Vaii.

unicode::Script::VITHKUQI
pub const VITHKUQI: Script = Script(171);

The Vithkuqi script, ISO 15924 Vith.

unicode::Script::WANCHO
pub const WANCHO: Script = Script(172);

The Wancho script, ISO 15924 Wcho.

unicode::Script::WARANG_CITI
pub const WARANG_CITI: Script = Script(173);

The Warang Citi script, ISO 15924 Wara.

unicode::Script::YEZIDI
pub const YEZIDI: Script = Script(174);

The Yezidi script, ISO 15924 Yezi.

unicode::Script::YI
pub const YI: Script = Script(175);

The Yi script, ISO 15924 Yiii.

unicode::Script::ZANABAZAR_SQUARE
pub const ZANABAZAR_SQUARE: Script = Script(176);

The Zanabazar Square script, ISO 15924 Zanb.

Layout

Paragraphs laid out in lines: wrapped, broken, aligned, in either writing mode, and one line justified by a font's JSTF table. Font::layout and the types in daegun::layout, all in font units.

layout::LayoutOptions::DEFAULT
pub const DEFAULT: LayoutOptions<'static>;

The default options as a constant, the same value LayoutOptions::default() returns.

They set text in horizontal lines that end only at hard breaks: LayoutOptions lists the default of every field. Every with_ method is a const fn, so options of your own can be constants built from this one.

use daegun::layout::{Align, LayoutOptions};
use daegun::Location;

const CENTERED: LayoutOptions = LayoutOptions::DEFAULT.with_align(Align::Center);

let layout = font.layout("Title\nA longer subtitle", &Location::default(), &CENTERED);
// With no measure, the short line is centered against the long one.
let (title, subtitle) = (&layout.lines[0], &layout.lines[1]);
assert_eq!(title.runs[0].offset.x, (subtitle.inline_size - title.inline_size) / 2.0);
assert!(LayoutOptions::DEFAULT.max_inline_size.is_infinite());

Outlines

A glyph's shape: as the font stores it in font units, hinted in pixels, or prepared for a rasterizer of your own, with the paths, pens, strokes, curves and polygons around it. The calls are on Font, and the rest is in daegun::outline.

outline::MAX_FLATTEN_POINTS
pub const MAX_FLATTEN_POINTS: usize = 1_048_576;

The most points Path::flatten returns, and the most Path::stroke_simplified holds: 1,048,576.

Past it both calls fail with ErrorKind::LimitExceeded. Path::flatten also gives up once it has read more than twice as many points, which counts those of contours it would leave out. The limit keeps a hostile or broken outline from asking for memory without end: at the finest setting one curve alone can become 4,096 edges.

Glyphs flattened for the screen come nowhere near it: Inter's o at 32 px is 80 points. Path::stroke has no such limit, as it sends each point to the pen as it works it out.

use daegun::outline::{OutlinePen, Path, MAX_FLATTEN_POINTS};
use daegun::ErrorKind;

// 300 curves, which at the finest setting come to more points than the limit.
let mut wave = Path::new();
wave.move_to(0.0, 0.0);
for i in 0..300 {
    let x = i as f32 * 10.0;
    wave.curve_to(x + 3.0, 50.0, x + 6.0, -50.0, x + 10.0, 0.0);
}
let refused = wave.flatten(0.0).map_err(|e| e.kind());
assert_eq!(refused, Err(ErrorKind::LimitExceeded));

// With a max_area of 1 the same path is 3,601 points, far under the limit.
let points: usize = wave.flatten(1.0)?.iter().map(Vec::len).sum();
assert_eq!(points, 3601);
assert!(points < MAX_FLATTEN_POINTS);
outline::OutlineOptions::DEFAULT
pub const DEFAULT: OutlineOptions;

The default options as a constant: the outline as the font draws it, scaled to the size and nothing more.

No hinting, no transform, no stroke, no embolden and no oblique. It is the value OutlineOptions::default() returns. Every with_ method is a const fn, so options of your own can be constants too.

use daegun::outline::{HintMode, OutlineOptions};

const HINTED: OutlineOptions = OutlineOptions::DEFAULT.with_hinting(HintMode::Auto);

assert_eq!(OutlineOptions::DEFAULT, OutlineOptions::default());
assert_eq!(OutlineOptions::DEFAULT.hinting, HintMode::None);
assert_eq!(HINTED.hinting, HintMode::Auto);

Color

Color glyphs: bitmap strikes, COLR layers and palettes, paint graphs and the scenes made from them, and the color math to sample a gradient and composite a layer. The calls are on Font, and the rest is in daegun::color.

color::IDENTITY
pub const IDENTITY: Matrix = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0];

The matrix that leaves every point where it is.

Pass it wherever a call wants a Matrix and you have no transform to apply: as the transform of Gradient::new, as the to_device of Ramp::new when the gradient is already in pixels, or as the ctm of color::lower to keep a scene in font units.

use daegun::color::{concat, IDENTITY};

let double = [2.0, 0.0, 0.0, 2.0, 0.0, 0.0];
// Chained with any matrix, on either side, it changes nothing.
assert_eq!(concat(&double, &IDENTITY), double);
assert_eq!(concat(&IDENTITY, &double), double);
color::SceneOptions::DEFAULT
pub const DEFAULT: SceneOptions = SceneOptions { palette: 0, foreground: Rgba { r: 0, g: 0, b: 0, a: 255 } };

The default options as a constant: palette 0 and opaque black text, the value SceneOptions::default() returns.

Being a constant, &SceneOptions::DEFAULT can be passed straight to Font::color_scene, with no variable to hold it. Both with_ methods are const fn, so options of your own can be constants too.

use daegun::color::{Rgba, SceneOptions};

const ON_DARK: SceneOptions = SceneOptions::DEFAULT.with_foreground(Rgba::opaque(255, 255, 255));

assert_eq!(SceneOptions::DEFAULT, SceneOptions::default());
assert_eq!(SceneOptions::DEFAULT.palette, 0);
assert_eq!(SceneOptions::DEFAULT.foreground, Rgba::opaque(0, 0, 0));
assert_eq!(ON_DARK.palette, 0);

Raw tables

Font data at the byte level, for tools that read or write a table daegun has no call for: reads and writes that never panic, the structures several tables share, loca and glyf, and building a font file from its tables. In daegun::raw.

raw::format::class::DELETED_GLYPH
pub const DELETED_GLYPH: u16 = 2;

The class of glyph 0xFFFF, the mark an AAT table leaves where it has deleted a glyph: class 2 of every state table.

An AAT state table sorts glyphs into classes, and its machine reads an entry by the state it is in and the class of the glyph it meets. The first classes are the same in every table, ahead of the font's own, and daegun names two of them: this one and END_OF_TEXT. Class 1 means out of bounds, a glyph the class table does not list, and StateTable::class answers it as the plain number 1.

A morx subtable deletes a glyph by turning it into glyph 0xFFFF, which stays in the run until the whole table has been applied, so later subtables still meet it and can act on its class. StateTable::class answers this class for glyph 0xFFFF without reading the class table.

use daegun::raw::bytes::read_u32_be;
use daegun::raw::format::{class, state, StateTable};
use daegun::Tag;

let morx = font.table(Tag::new(b"morx")).ok_or("no morx")?;
// This test font's one morx subtable starts at byte 48, and its state table 12 bytes after that.
let length = read_u32_be(morx, 48).ok_or("morx cut short")? as usize;
let body = morx.get(60..48 + length).ok_or("morx cut short")?;
let table = StateTable::parse(body, 2, font.glyph_count())?;

// The deleted glyph has its own class, and the start state has an entry for it like any other class.
assert_eq!(table.class(0xFFFF), class::DELETED_GLYPH);
assert!(table.entry(state::START_OF_TEXT, class::DELETED_GLYPH).is_some());
// A glyph the class table does not list is out of bounds, class 1.
assert_eq!(table.class(1000), 1);
raw::format::class::END_OF_TEXT
pub const END_OF_TEXT: u16 = 0;

The class an AAT state machine is given once the text has run out: class 0 of every state table.

An AAT state table sorts glyphs into classes, and StateTable::class gives the class of each glyph the machine meets. After the last glyph of a run the machine takes one more step, so a table can finish what it began. No glyph is left to take a class from, so that step reads the entry for this class: call StateTable::entry with the state the machine is in and END_OF_TEXT.

use daegun::raw::bytes::read_u32_be;
use daegun::raw::format::{class, state, StateTable};
use daegun::Tag;

let morx = font.table(Tag::new(b"morx")).ok_or("no morx")?;
// This test font's one morx subtable starts at byte 48, and its state table 12 bytes after that.
let length = read_u32_be(morx, 48).ok_or("morx cut short")? as usize;
let body = morx.get(60..48 + length).ok_or("morx cut short")?;
let table = StateTable::parse(body, 2, font.glyph_count())?;

// Walk the glyphs of "AB", then take the last step with the end-of-text class.
let mut current = state::START_OF_TEXT;
for c in ['A', 'B'] {
    let glyph = font.glyph_id(c).ok_or("no glyph")?;
    let entry = table.entry(current, table.class(glyph.0)).ok_or("no entry")?;
    // A driver acts on the entry here: its flags and extra words say what to do, and whether to
    // stay on this glyph.
    current = entry.new_state;
}
let last = table.entry(current, class::END_OF_TEXT).ok_or("no entry")?;
assert_eq!((last.new_state, last.flags), (0, 0));
raw::format::state::START_OF_TEXT
pub const START_OF_TEXT: u16 = 0;

The state an AAT state machine starts in: state 0 of every state table.

Pass it to StateTable::entry for the first glyph of a run, with the class StateTable::class gives that glyph. Each entry then names the state for the next glyph in Entry::new_state.

use daegun::raw::bytes::read_u32_be;
use daegun::raw::format::{state, StateTable};
use daegun::Tag;

let morx = font.table(Tag::new(b"morx")).ok_or("no morx")?;
// This test font's one morx subtable starts at byte 48, and its state table 12 bytes after that.
let length = read_u32_be(morx, 48).ok_or("morx cut short")? as usize;
let body = morx.get(60..48 + length).ok_or("morx cut short")?;
let table = StateTable::parse(body, 2, font.glyph_count())?;

// The first glyph of a run is met in the start state.
let first = font.glyph_id('A').ok_or("no A")?;
let entry = table.entry(state::START_OF_TEXT, table.class(first.0)).ok_or("no entry")?;
// In this font an A leaves the machine in the start state.
assert_eq!(entry.new_state, state::START_OF_TEXT);

Rasterizing

daegun's own rasterizer, which turns glyphs and paths into pixels, and what any rasterizer needs beyond outlines: subpixel layouts with their filters, and an atlas packer. In daegun::raster.

raster::MAX_DRAW_BYTES
pub const MAX_DRAW_BYTES: usize = 1 << 28;

The most bytes a draw that lends its image may hold in its buffers, the image among them: 2^28, which is 256 MiB.

Drawing takes working memory beside the image. Plain coverage keeps 9 bytes for each pixel while it works, next to the one byte of the image, so a glyph or a path reaches this limit at about 26 million pixels, long before both sides reach MAX_SIDE. A subpixel layout, a distance field and above all a multi-channel one, and a color glyph with its layers each keep more for a pixel and reach it sooner.

A draw that would pass the limit fails with ErrorKind::LimitExceeded. The image and the working buffers are counted before they are allocated, so a refused draw never allocates them. It applies to Rasterizer::glyph, Rasterizer::color_glyph, Rasterizer::distance_field and Rasterizer::path. The calls that draw into a Target work a band of rows at a time within a small fixed size, and have no such limit.

use daegun::raster::{RasterOptions, Rasterizer, MAX_DRAW_BYTES, MAX_SIDE};
use daegun::{ErrorKind, Location};

let mut rasterizer = Rasterizer::new();
let glyph = font.glyph_id('H').expect("the font maps H");
let (at, options) = (Location::default(), RasterOptions::DEFAULT);

// At 9,000 px Inter's H is 5,107 by 6,548 pixels: within MAX_SIDE each way, but at 10 bytes a pixel
// it would hold more than MAX_DRAW_BYTES.
assert_eq!(MAX_DRAW_BYTES, 1 << 28);
let lent = rasterizer.glyph(&font, glyph, &at, 9_000.0, &options);
assert_eq!(lent.map(drop).map_err(|e| e.kind()), Err(ErrorKind::LimitExceeded));
raster::MAX_OVERSAMPLE
pub const MAX_OVERSAMPLE: u8 = 4;

The most samples a layout takes for each pixel, in either direction.

SubpixelLayout::from_weights refuses an oversample above it, or one of 0, with ErrorKind::InvalidArgument. The layouts daegun builds stay inside it: they take 3 one way and 1 the other.

use daegun::raster::{SubpixelLayout, MAX_OVERSAMPLE};
use daegun::ErrorKind;

let one = [1.0];
let weights: [&[f32]; 3] = [&one, &one, &one];
// Four samples across a pixel is the most a layout takes.
let most = SubpixelLayout::from_weights((MAX_OVERSAMPLE, 1), (1, 1), (0, 0), weights)?;
assert_eq!(most.oversample(), (4, 1));

let over = SubpixelLayout::from_weights((MAX_OVERSAMPLE + 1, 1), (1, 1), (0, 0), weights);
assert_eq!(over.unwrap_err().kind(), ErrorKind::InvalidArgument);
raster::MAX_SIDE
pub const MAX_SIDE: u32 = 1 << 14;

The most pixels an image a rasterizer lends may be across or down: 16,384.

A draw whose image would be wider or taller fails with ErrorKind::LimitExceeded before its pixels are allocated. That holds for Rasterizer::glyph, Rasterizer::color_glyph, Rasterizer::distance_field and Rasterizer::path. In practice MAX_DRAW_BYTES stops a draw earlier, as an image this large on both sides would hold far more than that.

The calls that draw into a Target have no such limit: the target is yours, of any size, and can cover any part of a drawing however large the whole would be.

use daegun::raster::{RasterOptions, Rasterizer, Target, MAX_SIDE};
use daegun::{ErrorKind, Location};

let mut rasterizer = Rasterizer::new();
let glyph = font.glyph_id('H').expect("the font maps H");
let (at, options) = (Location::default(), RasterOptions::DEFAULT);

// At 40,000 px Inter's H is 29,102 pixels tall, past MAX_SIDE, so it cannot be lent.
assert_eq!(MAX_SIDE, 16_384);
let lent = rasterizer.glyph(&font, glyph, &at, 40_000.0, &options);
assert_eq!(lent.map(drop).map_err(|e| e.kind()), Err(ErrorKind::LimitExceeded));

// A target takes any part of it. These 64 by 16 pixels lie inside its left stem.
let mut pixels = vec![0u8; 64 * 16];
let target = Target::new(4_000, 10_000, 64, 16, 64, &mut pixels);
rasterizer.glyph_into(&font, glyph, &at, 40_000.0, &options, target)?;
assert!(pixels.iter().all(|&coverage| coverage == 255));
raster::MAX_TAPS
pub const MAX_TAPS: usize = MAX_OVERSAMPLE as usize + 4;

The most taps a layout's filter has, in either direction.

It bounds each number in the taps of SubpixelLayout::from_weights, which answers ErrorKind::InvalidArgument past it. Its value is MAX_OVERSAMPLE plus 4: room for every sample of a pixel at the highest oversampling, and two more on each side.

It is a usize, where the taps themselves are u8.

use daegun::raster::{SubpixelLayout, MAX_OVERSAMPLE, MAX_TAPS};

// The widest window: all four samples of a pixel, and two more on each side.
let taps = u8::try_from(MAX_TAPS)?;
let channel = vec![1.0 / f32::from(taps); MAX_TAPS];
let weights = [&channel[..], &channel[..], &channel[..]];
let wide = SubpixelLayout::from_weights((MAX_OVERSAMPLE, 1), (taps, 1), (-2, 0), weights)?;
assert_eq!((wide.oversample(), wide.taps(), wide.pad()), ((4, 1), (8, 1), (1, 0)));

// One tap more is refused.
let channel = vec![0.0; MAX_TAPS + 1];
let weights = [&channel[..], &channel[..], &channel[..]];
assert!(SubpixelLayout::from_weights((MAX_OVERSAMPLE, 1), (taps + 1, 1), (-2, 0), weights).is_err());
raster::MAX_WEIGHTS
pub const MAX_WEIGHTS: usize = MAX_TAPS * MAX_TAPS;

The most weights one channel of a filter has: MAX_TAPS squared.

A channel has taps.0 * taps.1 weights, so this is the longest slice SubpixelLayout::from_weights takes for a channel and the longest SubpixelLayout::weights returns. A layout stores its weights inline, with room for this many in each of three channels, so building or copying one allocates nothing.

use daegun::raster::{StripeOrder, SubpixelLayout, MAX_WEIGHTS};

// A fixed buffer that holds one channel of any layout.
let mut buffer = [0.0f32; MAX_WEIGHTS];
let lcd = SubpixelLayout::horizontal(StripeOrder::Rgb);
let red = lcd.weights(0).expect("a stripe layout has three channels");
buffer[..red.len()].copy_from_slice(red);
assert_eq!(red.len(), 7);
raster::RasterOptions::DEFAULT
pub const DEFAULT: RasterOptions<'static>;

The default options as a constant, the same value RasterOptions::default() returns.

Field by field: outline is OutlineOptions::DEFAULT, so no hinting, no transform, no stroke, no embolden and no oblique. offset is [0.0, 0.0], the origin of the glyph on a pixel corner. layout is SubpixelLayout::grayscale, one byte of coverage a pixel. darken is false. gamma is Gamma::Linear, coverage as it is.

Being a constant, &RasterOptions::DEFAULT borrows one static value, and since every with_ method is a const fn, options of your own can be constants too.

use daegun::outline::OutlineOptions;
use daegun::raster::{Gamma, RasterOptions};

// A constant of your own: the defaults with stem darkening on.
const SMALL_TEXT: RasterOptions = RasterOptions::DEFAULT.with_darken(true);
assert!(SMALL_TEXT.darken);

let defaults = RasterOptions::DEFAULT;
assert_eq!(defaults.outline, OutlineOptions::DEFAULT);
assert_eq!(defaults.offset, [0.0, 0.0]);
assert!(defaults.layout.is_grayscale());
assert!(!defaults.darken);
assert_eq!(defaults.gamma, Gamma::Linear);
assert_eq!(defaults, RasterOptions::default());

Type to search.