module

Egui::FontCuts

Constants

LONG_TOKENS = {"r" => "regular", "b" => "bold", "i" => "italic", "bi" => "bold italic", "bd" => "bold", "it" => "italic", "z" => "bold italic"}

Glued short codes ("Ubuntu-R.ttf") → long form before lookup.

STYLE_WORDS = ["thin", "extralight", "ultralight", "light", "medium", "semibold", "demibold", "bold", "extrabold", "ultrabold", "black", "heavy", "italic", "oblique", "regular", "book", "roman"] of ::String

Trailing style words stripped off a legacy family name: "Noto Sans Thin" → "Noto Sans"; width families ("Noto Sans ExtraCondensed") stay their own family, like Google's. At least one word always remains.

WEIGHTS = {"thin" => {"Thin", 100}, "extralight" => {"ExtraLight", 200}, "ultralight" => {"ExtraLight", 200}, "light" => {"Light", 300}, "" => {"Regular", 400}, "regular" => {"Regular", 400}, "book" => {"Regular", 400}, "r" => {"Regular", 400}, "roman" => {"Regular", 400}, "medium" => {"Medium", 500}, "semibold" => {"SemiBold", 600}, "demibold" => {"SemiBold", 600}, "bold" => {"Bold", 700}, "extrabold" => {"ExtraBold", 800}, "ultrabold" => {"ExtraBold", 800}, "black" => {"Black", 900}, "heavy" => {"Black", 900}}

Filename token → {prettified slot name, CSS weight}.

Class methods

axis(family : String | Nil) : Array(Int32)

The family's ROMAN weight axis — distinct weights, 100→900. Empty when the family is unknown (nothing installed under it).

Source
closest(family : String | Nil, target : Int32) : Cut | Nil

CSS font matching (simplified): the exact slot when it exists, else the NEAREST — ties break towards 400 (heavier side when the target is above 400, lighter side below). Italic cuts never match a roman target (the italic machinery owns slant).

Source
installed
Source
normalize_family(name : String) : String
Source
parse(path : String) : Cut

Parse the post-dash filename token into a Cut: "BoldItalic" → Bold 700 Italic, "Italic" → Regular 400 Italic, "SemiBold" → SemiBold 600 roman, "ExtraCondensedBold" → known: false (a width shape, not a weight slot — it keeps its prettified token label).

Source
stack_name(path : String) : String

The deferred-stack family name for one cut file — unique per path, can't collide with catalog family names.

Source
style_token(path : String) : String

The style segment of a font filename: after the last '-' ("NotoSans-BoldItalic.ttf" → "BoldItalic", "Ubuntu-R.ttf" → "R"); no dash at all → "" (the whole base is the family name).

Source
weight_name(num : Int32) : String

The CSS name of a ladder slot ("700" → "Bold").

Source

Nested types