<< lib/user-interface/SLFont.sleela SLeeLa Standard Library Definition. Definition: Defines SLFont — a SleelaUI font for Sleela and her UI. A font bundles a face (family, size, weight, slant, letter spacing, line height) with an ordered stack of SLFontEffect entries — drop/inner shadows, a soft glow, a directional light sheen, an EMITTER (text that radiates light into a scene), an outline, a relief emboss/engrave, and a gradient fill — plus a QUALITY level (draft .. ultra) that trades samples for smoothness, so a program can "choose many quality effects". Each method bottoms out in a `font*` SLVM built-in that calls the SleelaUI Font C ABI (sleela_ui_font.h); the look comes from the toolkit's own rasterizer, so a styled string is pixel-identical on every OS. A font is a VM-local handle (-1 = none). Attach it to a text widget with SLWidget.setFont (uiWidgetSetFont) to render that widget's label with the font's effects, or draw directly into an SLDrawContext. Family: user-interface. Native VM/UI work crosses the explicit `font*` SLVM bridge. >> #sleela 2.5 material; class SLFont { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10363; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-07"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } < Weight ordinals (mirror SLUIFontWeight). > static final int THIN = 100; static final int LIGHT = 300; static final int REGULAR = 400; static final int MEDIUM = 500; static final int SEMIBOLD = 600; static final int BOLD = 700; static final int BLACK = 900; < Slant ordinals (mirror SLUIFontSlant). > static final int UPRIGHT = 0; static final int ITALIC = 1; static final int OBLIQUE = 2; < Quality ordinals (mirror SLUIFontQuality). > static final int QUALITY_DRAFT = 0; static final int QUALITY_LOW = 1; static final int QUALITY_MEDIUM = 2; static final int QUALITY_HIGH = 3; static final int QUALITY_ULTRA = 4; < VM-local font handle (-1 = none) > int font; < Create a font with a family ("system"/"mono"/a real face) and point size. > void create(String family, double sizePt) { font = fontCreate(family, sizePt); } int handle() { return font; } boolean valid() { return font >= 0; } void destroy() { if (font >= 0) { fontDestroy(font); font = -1; } } < ---- face attributes ---------------------------------------------------- > void setFamily(String family) { if (font >= 0) { fontSetFamily(font, family); } } void setSize(double sizePt) { if (font >= 0) { fontSetSize(font, sizePt); } } void setWeight(int weight) { if (font >= 0) { fontSetWeight(font, weight); } } void setSlant(int slant) { if (font >= 0) { fontSetSlant(font, slant); } } void setLetterSpacing(double px) { if (font >= 0) { fontSetLetterSpacing(font, px); } } void setLineHeight(double multiple) { if (font >= 0) { fontSetLineHeight(font, multiple); } } void setQuality(int quality) { if (font >= 0) { fontSetQuality(font, quality); } } double size() { if (font < 0) { return 0.0; } return fontSize(font); } < ---- effect stack ------------------------------------------------------- > < Add an effect (applied back-to-front in add order). > void addEffect(SLFontEffect e) { if (font >= 0) { fontAddEffect(font, e.type, e.color, e.color2, e.dx, e.dy, e.blur, e.size, e.intensity, e.opacity, e.relief, e.reservedAnchor); } } void clearEffects() { if (font >= 0) { fontClearEffects(font); } } int effectCount() { if (font < 0) { return 0; } return fontEffectCount(font); } < ---- measuring ---------------------------------------------------------- > double measure(String utf8) { if (font < 0) { return 0.0; } return fontMeasure(font, utf8); } double ascent() { if (font < 0) { return 0.0; } return fontAscent(font); } double descent() { if (font < 0) { return 0.0; } return fontDescent(font); } double lineHeight() { if (font < 0) { return 0.0; } return fontLineHeight(font); } < ---- drawing ------------------------------------------------------------ > < Draw into an SLDrawContext with the full effect stack at (x, baseline). > void draw(SLDrawContext dc, String utf8, int x, int baseline, int color) { if (font >= 0 && dc != null) { fontDraw(font, dc.handle(), utf8, x, baseline, color); } } < If this font carries an EMITTER effect, register that emission into a light > < scene for text drawn at (x, baseline). A pure emitter reserves nothing; an > < anchored one binds as a source. Returns the light index or an error. > int emitInto(SLLightScene scene, int x, int baseline, String utf8) { if (font < 0 || scene == null) { return -1; } return fontEmitIntoScene(font, scene.handle(), x, baseline, utf8); } }