The text of the system: a vector font with subpixel bands
The system draws its text with a vector font by default, with a coverage for each subpixel band. Spleen 8x16 is the fallback, and the other value of the setting font. The renderer adapts the ideas of a GPU font renderer to the design rules of this system: integers, a grid, and no work at run time that the build can do.
The terms are in Glossary: font, glyph, outline, coverage, subpixel band, font outlines, face, private glyph cache, grid fit, setting, settings page.
The idea in plain words. Each process draws each glyph of its text from the font outlines of the boot image, once, into its private glyph cache: a table of the coverage of each subpixel band of each glyph, in integers. Each later frame copies and blends from that cache, so drawing a text costs a few table reads per glyph. The boot image holds the outlines only, about 195 KB, and no drawn glyph. The principal changes the font in the process settings, and every window changes at once.
For whom. A reader who draws text in a process, and a reader who changes a font, the renderer or the setting.
The map of this guide. Sections 1 to 5: what a process does, the grid, the subpixel bands, fixed point, the glyph cache. Section 6: the font file and the candidates. Sections 7 and 8: the setting and the fallback. Sections 9 to 11: measures, gaps, open decisions. Section 12: the interface font and the text shaping module. Section 13: the glyphs past the glyph cache: the font outlines, the private glyph cache and the fallback chains. Section 14: the text rendering at any text size: the text size, the frame of a face, the rasterizer, the private glyph cache and its bounds.

1. What a process does
Nothing in its code. A process calls graphics.text, graphics.character, graphics.unsigned or the elements of src/library/modus/interface, src/library/modus/display opens the font outlines and gives the setting of the principal and the faces of the cells to src/library/modus/graphics when the process opens its window, and again at each change. Each window of the machine test draws with the vector font with no line of its own changed. Each display.present ends a frame of the text of the process: a process that draws by hand gets its glyph memory there, after its first glyph.
Two places draw large text directly: write_large in server, which calls graphics.text_scaled at a whole scale of the body, and text_draw in src/library/modus/interface, which calls graphics.text_sized at the text size of a record. The boot display (src/library/modus/bootscreen) draws every text in Spleen at the size of its scale, and reads no font file (The boot display at the scale of the screen in the repository). The large of scheduler writes a text record with a text size through interface.draw_text, so the package draws it; terminal has no large text of its own. They do not read the bitmap of Spleen directly: a process that uses the interface of the text needs no change for the vector font.
2. The grid
The font must fit the grid of the system: every layout was made for cells of 8 x 16 pixels. So the font of the cells is scaled until its advance is exactly 8 pixels, and each glyph stays inside its cell.
A text grid is laid out in cells of 8 x 16 pixels, and the spacing tokens of the design rules are multiples of 8 (The design rules: Text and The design rules: Spacing). The vector font lives on these cells:
- The default font is monospace. Its advance maps to exactly 8 pixels at scale 1: the scale of the outline is 8 / advance, the same on both axes. A line is 16 pixels. Each existing layout holds; no window changes its size.
- The scales 2 and 3 are real sizes: 16 x 32 and 24 x 48 pixels, each drawn from the outline at that size, not enlarged pixels. The large numbers of
scheduler,remote,terminalandservergain the most. - Spleen as the fallback is enlarged: the rule "no enlarged low-resolution font" holds for the default font. When a process has no valid font outlines, or when the principal chooses Spleen in the settings, Spleen draws each of its pixels as a square at the scales 2 and 3: the other choice at that moment is no large text.
- Every glyph is drawn by its process. Each character comes from the face of its text and its fallback chain, drawn by the process itself from the font outlines of the boot image into its private glyph cache, once, at the size of its text (sections 13 and 14).
- A glyph is cut to its cell. The ink and the color fringe of a glyph stay inside its cell of 8 x 16 (or 16 x 32, 24 x 48). A cell never draws into its neighbour: the terminal fills one cell and draws its character, and the damage by difference of
src/library/modus/interfacetakes the rectangle of a text record as all that it draws. A glyph that passes its advance (rare in a monospace font) loses that part. - The baseline puts the middle of the ink of the characters 33 to 126 at the middle of the cell (
vector_font.glyph_style_of). For JetBrains Mono at scale 1 it is row 12, the baseline of Spleen.
Grid fit (the hinting of this system)
No TrueType bytecode interpreter: the subsets have no instructions. In place of it, a light grid fit of the vertical metrics, with the flag FLAG_GRID_FIT of the cache:
- the baseline is on a whole pixel (the origin of the cell);
- the x-height (the top of
x) and the cap height (the top ofH) go to the nearest whole pixel; the points between 0 and the x-height scale to it, the points between the x-height and the cap height scale between the two, the points above the cap height and below the baseline keep the plain scale (vector_font.place_y).
Why: at 13 to 14 pixels to the em, the tops of the lowercase letters and of the capitals fall between two rows without it, and a row of half coverage under each top makes the text soft. The fit moves the tops onto rows, so the horizontal stems of n, e, t, E, H are sharp. The vertical stems need no fit across: the subpixel bands place them in thirds of a pixel. Not done: a fit of each stem (it needs the stems of each glyph: an outline analysis or the instructions of the font).
The picture build/fonts/candidates.png (modustool vector_fonts) has the default font with and without the fit; the default is with it. The default value is an open decision (section 11).
3. Subpixel bands
A pixel of a usual screen is three thin stripes: red, green and blue. Drawing each stripe on its own triples the resolution across, so the stems of the letters can sit at a third of a pixel. The cost is a faint color at the edges, which a filter keeps small.
- Coverage at 3 samples for each pixel across, one for each color stripe of the screen: the outline is drawn into an accumulation three times wider than the cell, with a margin of 6 thirds on each side.
- The filter: each third spreads over its neighbours with the weights 8, 77, 86, 77, 8 of 256 (the default filter of the usual LCD rendering), so that a side of a stem does not show one color alone. Measured on a stem of one pixel at its three places of a third (host test
filters_measured): the five taps give a fringe of at most 162 of 255 and a peak of 239; three taps (85, 86, 85) give 170 and 255; no filter gives 255 and 255. The five taps are chosen: the least fringe for a loss of 16 levels at the peak. - The words of the cache: for each pixel one word 0xGGRRGGBB: the coverage of the red, green and blue stripe after the filter, red at the left, and in the high byte the coverage of the whole pixel (the mean of its three thirds before the filter) for grayscale.
- The order of the stripes is a setting:
rgb(the default),bgr(the same words with red and blue swapped at the blend: exact, the same thirds),none(grayscale, the high byte). Under QEMU the screen of the host decides: the pixels of the machine go to a window of the host, whose own panel has its own order; most panels are RGB. - Text over a gradient or a picture: the blend reads the pixel under each covered pixel; nothing assumes a plain background.
- Colored text: the coverage of each channel times the color of the text, in linear light.
The blend in linear light
graphics.blend_coverage_row (in src/library/modus/graphics/blend.odin, beside blend_premultiplied_alpha of the pointer pictures: one family, one head comment): for each channel, with d the pixel under, c the color of the text and a the coverage of that channel,
result = sqrt((d * d * (255 - a) + c * c * a) / 255)
A gamma of 2 in place of the curve of sRGB, in integers: the sum is under 2^24, shifted right by 12 bits it indexes a table of 4096 square roots that each process makes once (4 KiB). A channel with coverage 0 keeps the pixel, 255 gives the color.
The error against the exact curve of sRGB (host test blend_error_against_srgb, each coverage 0 to 255):
| Text over | Gamma of 2 | No gamma (a blend of the encoded values) |
|---|---|---|
colors.text over colors.card_bottom | 8.5 levels at most | 51.0 levels |
colors.dim over colors.background | 4.2 | 27.2 |
colors.process over colors.card_top | 7.4 | 40.3 |
colors.background over colors.text | 8.9 | 54.9 |
Light text on a dark surface is the case of this system: a blend with no gamma makes each edge pixel up to 51 levels too dark, and the text looks thin.
What a screenshot shows
A picture of the screen holds the colored edges of each glyph: enlarged, each letter has orange and blue sides. This is the subpixel band at work, not a fault: on an RGB panel at its native size the three stripes of a pixel make the edge. The pictures of docs/screenshots are taken with the order rgb. The setting none gives gray edges, for a picture to read enlarged or a screen with no stripes in rows (a turned screen, many OLED panels).
4. Fixed point
The renderer uses integers only, so the same font gives the same bytes on every build and every host. This section says how the coverage stays exact with integers, and why no sum can overflow.
src/library/modus/vector_font/raster.odin has no floating point, and neither has the text path of a display (src/library/modus/graphics, src/library/modus/display):
- Coordinates in subunits: 256 to a pixel on each axis (24.8). The points of an outline are integers in units of the font; the placement maps them with rational numbers rounded to the nearest subunit (
divide_rounded). - Accumulation in
i32: a piece of a segment of height h with ends at ra and rb subunits from the left of its column adds h (512 - ra - rb) to its cell and h (ra + rb) to the next; a full pixel is 256 x 512 = 131 072. The overflow argument: a segment adds at most one full pixel to a cell of a row, and a glyph has at most 8192 segments (a segment past that is dropped), so a cell and a prefix sum stay under 2^30. - Cuts: a segment is cut at each row and each column; the place of a cut is a function of the segment and of the line of the cut only, so two pieces that meet share their point. The sum of the coverage of a closed outline is exactly the area of the polygon of its cut points.
- Exactness (host test
coverage_is_the_area): a rectangle at positions that are not on a pixel, triangles with edges at an eighth of a turn and the whole accumulation give a sum of coverage equal to their area, to the unit. Twelve convex polygons with edges at other angles: at most 0.000029 of their area apart (the rounding of the cut points). - The edges of the accumulation: what is left of it lies on its left side, what is right of it on its right side, so the coverage inside stays exact; a row has one cell more for a piece on the right side of the last column. Host test
the_last_column: a vertical edge exactly on the right side of the last column with widths 1, 2 and 3, and an outline that passes all four sides. - Quadratic curves are cut into 1 to 16 segments, so that each is at most 1/8 of a pixel from the curve; each point is computed from the ends and the control point, rounded: no error adds up along a curve.
- The result does not depend on the build: integers only; the host test
golden_cells_of_a_candidate(src/library/modus/vector_font) draws the cells of the characters of ASCII of JetBrains Mono at the scales 1, 2 and 3 two times, compares the hash of the rows with ink and their words of each scale with a constant, and checks that one changed word changes the hash of its scale. A change of the renderer changes these hashes: it needs a newRENDERER_VERSIONand new constants. The faces of the system have golden hashes of their own (section 14.5).
5. The glyph cache
The glyph cache was a file of the font already drawn: each character at each scale. It left the system. The five caches of the boot image, more than 1.3 MB, left first: each process draws its glyphs from the font outlines into its private glyph cache (section 14). The file, its builder and its fuzz target left after: the candidate fonts (vector_glyphs, build/fonts/candidates.png) draw through the face of the cells of a font set of their own (section 6), and the tests of the blend take their glyphs from a face, whose golden hashes prove the pixels (section 14.5). The character index stays, in the contract src/library/modus/contract/font_characters. This section and "Who can write a cache" record the form that the caches had: the font outlines follow the same rules today.
A table of drawn glyphs: for each scale (1, 2, 3) and each character of two ranges and a list: ASCII 32 to 126, the Latin-1 Supplement U+00A0 to U+00FF, and the added characters (Glossary: Added character), today the euro sign U+20AC. Each table keyed a character by its character index (Glossary: Character index): 0 to 94 for ASCII, 95 to 190 for the Latin-1 Supplement, 191 for the euro sign. Its format, version 4 of a contract that left with it: a header of 128 bytes, a size entry of 16 bytes for each scale, a glyph entry of 12 bytes for each character, position and scale, the advance of each character and scale, the pairs of each scale by character index, then the words; a glyph keeps only its rows with ink. Fixed capacity: 3 sizes, 192 characters, 3 positions, 36 864 pairs. A cache holds the 192 characters, no fewer: the build refuses a font that lacks one. A text is UTF-8; each character outside the cache, and each invalid sequence, draws the replacement glyph, which code draws and no cache holds (Glossary: Replacement glyph). All zero is valid: a process with no cache draws Spleen.
One format for the two kinds of font (section 12.4). The tool writes every cache again at each build, so no reader keeps an older version:
| A monospace cache (Paper Mono) | A proportional cache (B612) | |
|---|---|---|
| Positions of each scale | 1 | 3 at scale 1, 1 at the scales 2 and 3; 3 for the bold weight at scale 1 |
| A glyph | its full cell: left 0, width the width of the cell | the box of its ink: left from the origin (it can be negative), width its columns |
| The advance of each character | the width of the cell, in 1/64 of a pixel | the advance of the font, in 1/64 of a pixel |
| Pairs | none | the pairs of kern between two characters of the cache, in 1/64 of a pixel, sorted |
validate checks each new part as hostile input, as the rest: the positions (1 to 3), the first glyph of each scale (after the glyphs of the scale before), the width (at most 64) and the left side (-16 to 64) of each glyph with its words inside the file, each advance (0 to 64 pixels), and each pair (two characters of the cache, sorted with no pair twice, at most 64 pixels). The draw of a glyph reads left and width of the glyph in place of the width of the cell: the same pixels for a monospace cache. The private glyph cache keeps this form of a glyph (text_rendering.Glyph_Entry). The header says which kind of cache it is: FLAG_PROPORTIONAL. A cache with no such flag is monospace, and validate requires its form: one position, no pair, each glyph with left 0 and width at most the width of the cell, each advance the width of the cell; the damage of a grid of text cells depends on a glyph that stays in its cell. validate also refuses a flag that it does not know, a filter past the three of src/library/modus/vector_font, and a font name that is not printable bytes with a zero byte at its end. The modus tool validates each cache that it writes, monospace or proportional.
Who can write a cache
Each process validates its glyph caches once, then the drawing code reads the counts and the offsets of a cache again at each glyph, with no bounds check. So the bytes of a cache must not change after validate, and the place of a cache must not be a choice of another process. Both hold:
- The address of each cache is a fixed range (
src/library/modus/contract/fixed_addresses), a constant of the process. It is not read from the settings page. - Mapped or not: the value 20 of the context (
CONTEXT_VALUE_FIXED_RANGES_MAPPED) is a set of bits, one for each fixed range. The root service sets the bit of each cache that it maps, and only then. A process reads nothing at a range whose bit is clear (settings.glyph_cache_opengivesNot_Mapped), so a process never reads a range where nothing is mapped. - The size of each cache is in its own header:
file_size.validate_atof the contract of the cache read the header at the fixed address, refuses a size under the header or over the span of the range, then validates the whole file, which checksfile_sizeagain. The header is always mapped: a mapping has whole pages, and the root service gives a cache only whenvalidateaccepts the bytes of the resource, so the resource is never shorter than its header and its header states the size of the resource. The modus tool validates each cache that it writes. No size goes through the context. The address and the size are not fields of the settings page. The processsettingswrites that page: with them, it could point every later process at memory that it controls, and change that memory after the validation. - The bytes: the root service maps each cache from the boot image with no flag, so with the right Read only, for every process that receives it, the process
settingsand the compositor included (text_settings_give). The one handle of the boot image, which the kernel gives the root service, has the rights Read and Give and no right Write (src/modulus/main.odin). So no process, the root service included, writes the bytes of a cache after the root service checked their hash. The limit of this rule: a process trusts its starter. A starter writes the values of the context of its child and chooses its mappings, so a starter that maps memory that it keeps with Write at a fixed range of a cache could change it after the validation. It gains nothing that it does not have already: it chooses the grants, the display ring and the budget of its child. A starter can also lie about a range: a set bit with no mapping, or a mapping shorter than the size that the header states, makes its child fault at its first read there. The root service is the starter of each process with a surface, and it gives each cache read-only from the boot image, with its bit, aftervalidateaccepted it; the other starters (the console,errors,locks, ...) give no settings page and no cache. - The font outlines follow the same rule. The root service maps them read-only from the boot image after it checked their hash and their format, and a process validates their header once (section 13).
- What
settingsstill chooses through the page, and the worst that each field does to another process:
| Field | Its worst value | What it does to another process |
|---|---|---|
values[font] | any number | a value that the setting does not have refuses the whole page (settings.choice_of_values): each reader takes the defaults, as for a page that never stays stable, and the root service and the process date act on nothing. Else the vector font or Spleen, a look |
values[subpixel_order] | any number | the same refusal; else one of three orders of the stripes, a look |
values[pointer_theme] | any number | the same refusal; else one of the two theme files that the compositor validated, a look |
values[grid_fit] | any number | the same refusal; else one of the two caches that the process validated, a look |
values[keyboard_layout] | any number | the same refusal, which gives the layout of the United States; else the input service gives each key the character of one of its two layouts |
values[appearance] | any number | the same refusal; else one of the three values, a look |
appearance_in_force | any number | a word that names no appearance in force refuses the whole page, as above |
values[6..7] | any number | no reader |
zone_offset_minutes | any number | a zone that is not from -720 to +840 by 15 reads as 0, UTC (settings.zone_offset_minutes_valid). The process date copies the zone into the date page: the bar shows another local time, and auto takes the other appearance. A look, and the hour that the bar shows |
change_count | odd for ever, or changed with no end | a reader gives up after 64 reads and takes the defaults (settings.read). The compositor tells the windows only when the values differ from the values that it told last (settings.values_differ): a new count with the same values sends no record into the ring of a window, which also carries its keys. Values that change with no end make the windows draw again: a cost of time, which the process settings also pays |
reserved | any number | no reader |
Where it lives: three places weighed
| In each process, at run time | Shared, filled at run time by a service | Built by the modus tool, a resource of the boot image | |
|---|---|---|---|
| The time to fill ASCII 32 to 126 at 3 scales | 3.7 to 4.0 ms for each process (measured by vector_glyphs for each candidate) | The same, once | 0 at run time; the same work once in the build |
| Memory | 390 624 bytes in each process (JetBrains Mono) | One copy, shared read-only | One copy: the pages of the boot image, mapped read-only |
| The font file at run time | In each process (14 to 21 KB) | In the service | None: the system draws from the cache only |
| Property 11 | The cache is not a fact of the system description | The same | The cache is a function of the font file (its BLAKE3 in the header) and of the renderer version; the boot image names it by its hash |
| Hostile input | Each process reads the font file | One service reads it | The modus tool reads it at build time; each process validates the cache once (one pass over its tables, 7 us in root) |
Chosen first: built at build time, a resource of the boot image. It served three sizes only, and the scale factor of the screen needs the sizes between them. Chosen now: in each process at run time, with a private glyph cache that keeps each glyph once drawn, at any size, and the font outlines as the one resource of the text (sections 13 and 14; Text rendering: one module for text at any size: The glyph caches of the boot image and the demand cache: removed in the repository). The root service no longer checks the hash of five caches at start (796 to 966 us for 390 624 bytes, about 3 ms for all), and the boot image is more than 1.3 MB smaller. The first frame of a window draws its glyphs once.
vector_glyphs opens each candidate as the font of the cells of a font set of its own (text_rendering.font_file_open), and draws it through the face of the cells of that set (graphics.character_of_set): the rasterizer and the blend of the text of the system, with no glyph kept. The time of the open of each candidate is on its log.
The cost of a text draw
| Measure (machine test, the least of 50 batches) | The fixed-point renderer | The floating-point prototype |
|---|---|---|
| One glyph of Spleen 8x16 | 35 ns | 30 ns |
| One glyph from the glyph cache, scale 1 | 309 ns | |
| One glyph from its outline, in fixed point, with the stripes: scale 1 / 2 / 3 | 3 874 / 10 607 / 20 613 ns | 5 373 ns at 13 px |
On the host (glyph_draw_cost, which now draws the glyphs of the face of the cells from their words): 333 to 362 ns from the glyph cache, before it left, against 33 to 44 ns for Spleen. The target was "the same order as Spleen": a glyph from the cache costs 9 times a glyph of Spleen. Four changes brought it from 921 ns: a loop for each order of the stripes (a constant), no bounds check after the one validation of the cache, the squares of the pixel under kept from one pixel to the next, a shift in place of a division. What stays: about 40 pixels of a glyph have a partial coverage, and each needs three blends in linear light. Section 9 has the effect on whole frames, which is small.
Where the time goes, and the fast blend
Measured on the host, where the same code runs, with -o:speed, pinned to one core with taskset, each number the least of 3 000 batches of the line compositor 12.4 ms 2 418 pages {fill} [rings] gi Rb 0O 1lI (60 glyphs), and the least over four cores (host test text_speed_parts, src/library/modus/graphics/text_speed_test.odin). Each batch draws over a fresh background, outside the time.
- The words of one cell (128 pixels at scale 1), on the mean: 64.4 pixels in rows with no ink (never read), 19.2 words of zero coverage (skipped), 1.0 word of full coverage (a store), 43.4 words of partial coverage. So the time is in the partial pixels: each needs three blends in linear light (two squares, a sum, a shift and a load of the table of square roots for each channel). A walk over the words alone costs 11.2 ns a glyph.
- The fast blend (
graphics.blend_glyph_rows, inblend.odin): for one text color over one pixel color, each channel of the result is a function of its coverage only. A blend table keeps the 3 x 256 results for one pair, in the memory of the process (Blend_Tables: 8 tables, 24 KiB, replaced in turn; a value is computed on first use with the formula of the reference, and a new table clears nothing: it takes a new generation in the high byte of each value). The choice is made for each row of a glyph: a row whose two end pixels have one color takes the table of that color, each pixel of that color in the row is three loads and a store; any other pixel takes the reference blend. Bit for bit: the host testfast_blend_is_the_referencedraws each character at each scale, each order of the stripes, five colors, over a flat color, the gradient of a card, a gradient across and noise, two passes (the second over the first), and compares with the reference: 0 pixels differ. A row that no table holds (its two ends differ: a gradient across, a picture) takes the form of the target,blend_coverage_row_in_form_of_target(SSE2 on amd64), not the scalar form; a lone pixel of another color inside a row stays scalar (the SSE2 form gives a lone pixel to the scalar form anyway). The host testthree_blends_give_the_same_bytes_for_each_facecompares the table blend, the SSE2 form alone and the scalar form alone, byte for byte, with the glyphs of the facesCells(Paper Mono),Cells_Bold(Paper Mono SemiBold) andInterface(B612, glyphs that overlap), at the scales 1, 2 and 3 and each position, over the four backgrounds. The tests of the blend take these glyphs from the face, copied out of the private glyph cache (src/library/modus/graphics/face_glyphs_test.odin). The host testtext_speed_of_each_blendgives the time of one glyph in each of the three, over a flat color, a gradient across and noise, for the choice of one path for the flat case; it has not run on a quiet host yet. The expectation: the table blend stays faster over a flat color, because a partial pixel there is three loads from a table where the SSE2 form still takes the square roots one channel at a time; if the SSE2 form comes within about 10 % of it, one path (the SSE2 form) is better than two, and the blend tables (24 KiB for each process) go. - Not taken: a run-length or a mask for each row in the cache (the zero words are skipped already, and the walk is 11 ns of 109); 16 bytes at a time (the partial pixels need three table loads each, which the processor does not gather); the tables filled whole when made (89 to 93 ns against 103 to 110 ns, but 768 square roots for each new pair of colors, which a gradient across pays at each row).
| One glyph, the least on the host | Scale 1 | Scale 2 | Scale 3 |
|---|---|---|---|
| Spleen 8x16 (at scale 2 and 3: its pixels enlarged) | 33.8 ns | 253 ns | 286 ns |
| The reference blend, over a flat color | 181 ns | 424 ns | 712 ns |
| The fast blend, over a flat color (the console, the cards) | 109 ns | 285 ns | 497 ns |
| The fast blend, over the gradient of a card (top to bottom) | 110 ns | ||
| The fast blend, over a gradient across (a title bar) | 178 ns (the reference: 188 ns) | ||
| The fast blend, over noise (a picture) | 188 ns (the reference: 193 ns) |
At scale 1, a glyph from the cache over a flat color or a card costs 3.2 times a glyph of Spleen (5.4 times with the reference blend). At the scales 2 and 3 the vector font costs 1.1 and 1.7 times the enlarged Spleen, for a glyph drawn from its outline at that size. The rest of the time is the 43 partial pixels: a cell has 43 blends that Spleen does not do. The target "the same order as Spleen" is near at scale 1 and met at the scales 2 and 3; the machine measures of this part were taken at a load of 28 to 31 and are not valid.
The blend of a glyph now has an SSE2 form beside this scalar form, with the same bytes: Vector forms: SSE2: The blend of a glyph (src/library/modus/graphics) and Vector forms: SSE2: How to measure on the machine, says what it computes in vectors and how to measure it against the numbers above.
6. The font file
The font of the cells must be monospace, have clear forms at 8 x 16 pixels, and have a license that allows a subset inside the system. Six candidates were read and compared; Paper Mono is the font of the system.
Six candidates, each read from the build input of flake.nix (the packages of nixpkgs, pinned by flake.lock). Their license texts were read at the source on 2026-11-11.
| Candidate | License, as read | Outlines | Source | ASCII subset | Glyphs made of glyphs |
|---|---|---|---|---|---|
| JetBrains Mono 2.304 | SIL OFL 1.1, no Reserved Font Name: "Copyright 2020 The JetBrains Mono Project Authors [...] This Font Software is licensed under the SIL Open Font License, Version 1.1." (github.com/JetBrains/JetBrainsMono/OFL.txt) | glyf | 268 544 bytes | 14 164 bytes | 4 |
| DejaVu Sans Mono 2.37 | Bitstream Vera license, DejaVu changes in the public domain: "The Font Software may be modified [...] only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera"." (github.com/dejavu-fonts/dejavu-fonts/LICENSE) | glyf | 343 096 | 17 688 | 0 |
| IBM Plex Mono 1.1.0 | SIL OFL 1.1 "with Reserved Font Name "Plex"" (github.com/IBM/plex/LICENSE.txt): the subset is named "IBM Mono ASCII" | glyf | 155 940 | 15 224 | 3 |
| Fira Mono 3.2 | SIL OFL 1.1: "Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A." (github.com/mozilla/Fira/LICENSE); the name table of the file: "Licensed under the Open Font License, version 1.1 or later" | glyf | 174 632 | 13 424 | 0 |
| Commit Mono 1.143 | The name table of the font file: "This Font Software is licensed under the SIL Open Font License, Version 1.1"; the repository (github.com/eigilnikolajsen/commit-mono/LICENSE): MIT. The two differ; the subset keeps the text of the file | glyf | 377 980 | 13 024 | 0 |
| Iosevka 34.3.0 | SIL OFL 1.1, no Reserved Font Name: "Copyright (c) 2015-2026, Renzhi Li" (github.com/be5invis/Iosevka/LICENSE.md) | glyf, a collection of 18 faces (the first is read) | 50 041 356 | 20 944 | 5 |
| Source Code Pro 2.042 | SIL OFL 1.1 "with Reserved Font Name 'Source'" (github.com/adobe-fonts/source-code-pro/LICENSE.md) | CFF only in nixpkgs | not made |
- A glyph made of glyphs is read with two limits: at most 4 levels (
COMPOSITE_DEPTH) and at most 64 parts in all its levels together (COMPOSITE_PART_LIMIT). A part can be an empty glyph, which adds no point, so the limit of points does not bound the work: with no limit of parts, a glyph of 21 000 parts in four levels gives 21 000 to the power 4 calls. The host testa_composite_of_many_empty_parts_ends_at_oncebuilds that glyph. The composites of the candidates have 2 parts. A face number past the faces of a collection is the problemNo_Face. - CFF (Source Code Pro): its outlines are Type 2 charstrings, a small stack machine with cubic curves. The reader needs that interpreter (about 40 operators, subroutines, hints to skip) and the cut of cubic curves. Not built: five candidates have
glyf. - A subset is a Modified Version of the font under the OFL (OFL FAQ 2.6: "Removing any parts of the font [...] is considered modification. This is permitted by the OFL but would not normally allow the use of RFNs."). So a font with a Reserved Font Name is renamed in its subset ("IBM Mono ASCII"). Each subset keeps the copyright and the license text of its source in its name table and in a
.licensefile beside it;resources/fonts/OFL.txtandBITSTREAM_VERA_LICENSE.txthave the full texts. - The subset command:
modustool vector_fontsreadsVECTOR_FONT_SOURCES(the development shell sets it), writes for each candidate.notdef, the characters 32 to 126, the characters U+00A0 to U+00FF and the added characters as simple glyphs with no instructions (a glyph made of glyphs, as é, is made simple with its offsets and its scale in integers), in the order of their character index. A font that lacks U+00A0 (the space with no break) or U+00AD (the soft hyphen) draws it with the glyph of U+0020 or U+002D, its standard equivalent, and the command writes one line for each such character ("paper_mono has no glyph for U+00AD: its subset draws it with the glyph of U+002D"); Paper Mono has no soft hyphen. Each other character that a font lacks stops the command, the euro sign too: a glyph of E or C would show a wrong currency. Each source font of the system has its own glyph for U+20AC. The command writes the tablesOS/2(of the source),cmap(two segments of characters, one segment for each added character, and the last segment of the format),glyf,head,hhea,hmtx,loca,maxp,name,post, with their checksums. It uses no time and no random value: the same input gives the same bytes. The subsets are in the repository, as the output ofmodustool fontis: a build needs no build input. - A wider range costs at most 4 bytes for each pixel of a cell, at three scales: 4 x (8 x 16 + 16 x 32 + 24 x 48) = 7 168 bytes for each character with ink in each row; about 4 100 bytes for each character on the mean with only the rows with ink. The 96 characters of the Latin-1 Supplement are in each cache: an estimate of about 390 KB more for each cache of three scales before the build; the coordinator of the build measures the sizes in
build/fonts.
JetBrains Mono is the reference font of the host tests of the renderer. The default font is one line, DEFAULT_VECTOR_FONT in tools/modustool/resources/vector_fonts.odin. The qualities of JetBrains Mono: at 8 x 16 its zero has a dot and its O does not, 1, l and I differ, its x-height (550 of 1000) gives 7 rows like Spleen, its stems are even at the three scales, and the OFL with no Reserved Font Name lets the subset keep its name. DejaVu Sans Mono is close; Iosevka has the largest letters (its advance is half its em, so its em is 16 pixels) and the most condensed forms; Fira Mono is the heaviest; IBM Plex Mono needs a new name.
Paper Mono, the font of the system
Paper Mono (<https://github.com/paper-design/paper-mono>, SIL OFL 1.1, no Reserved Font Name: "Copyright 2025 The Paper-Mono.Git Project Authors [...] This Font Software is licensed under the SIL Open Font License, Version 1.1", read in OFL.txt of the repository; its name table says the same) is the default vector font: the font of the cells, for the console, the terminal and the values of every window (section 12.6). Its SemiBold is the bold weight of the titles in the font of the cells. DEFAULT_VECTOR_FONT is paper_mono, EMPHASIS_VECTOR_FONT is paper_mono_semibold. JetBrains Mono stays a candidate; the host tests of the renderer keep it, so that a change of the default changes no golden hash.
The cap height and the x-height of Paper Mono (the pinned files, both weights): OS/2 gives 710 and 509 units, and the tops of the outlines of H, E, F, T, Z, I are all 710, of x, z, v, w all 509. So the path of the monospace fonts, which takes them from the tops of H and x, gives the values that the font states.
The source: Paper Mono is not in nixpkgs. flake.nix fetches fonts/ttf/PaperMono-Regular.ttf and PaperMono-SemiBold.ttf at the commit 74fc5537cc1f7b39aa8cccfa7dd3822e17143cca, each with its hash (106 088 and 106 900 bytes).
The zero of Paper Mono: the slashed zero. The default zero of Paper Mono looks like its capital O, so the system draws the slashed zero. What the pinned files hold, read in their tables:
| Paper Mono Regular | Paper Mono SemiBold | |
|---|---|---|
The glyph of '0' in cmap | 294: 2 contours, 24 points (the capital O, glyph 78: 2 contours, 24 points) | 294: 2 contours, 26 points |
The feature zero of GSUB | lookup 158: type 1 (a single substitution), one subtable of format 1 (a delta of 10), a coverage of format 1 with one glyph, 294 | the same |
| Its substitute | 304, named zero.zero in post: 3 contours, 32 points, the advance 606 of every glyph | 304: 3 contours, 32 points |
| The other forms of the zero | numr 335, dnom 325, sinf and subs 356, sups 366; the stylistic set ss01 reaches the zero through a contextual lookup (type 6) only | the same |
The script DFLT and the script latn each have the feature zero in their default language system. So the slashed zero is the feature zero, a single substitution, and no stylistic set and no name of post is needed to find it.
- The subset: the table of the fonts of the tool (
vector_fonts.odin) gives each font a form of the zero,.Of_The_Fontor.Slashed. For.Slashedthe tool reads the featurezerowithvector_font.single_substitutionand draws its substitute for the character '0' in the subset; the subset holds noGSUB. A font with no such feature keeps its zero, and the tool prints a line that says so. Paper Mono Regular and SemiBold are.Slashed; the.licensefile of a subset says which glyph is its zero. - The reader of
GSUB(src/library/modus/vector_font/substitution.odin) reads the version (1.0 or 1.1), the script list (DFLT, else latn, its default language system), the feature list, the lookup list, a lookup of type 1 or 7 (an extension that holds a type 1), a subtable of format 1 or 2, and a coverage of format 1 or 2. It is hostile input: each offset is checked against the table, the work is bounded (16 features of one tag, 64 lookups, 64 subtables, a binary search in each coverage), and the substitute must be a glyph of the font. - The tests:
the_zero_feature_of_paper_mono(the modus tool) reads both pinned files throughVECTOR_FONT_SOURCES, which the check of the flake also sets;the_zero_of_the_paper_mono_subsetsreads the subsets;a_single_substitution_in_each_formanda_damaged_substitution_tablebuild a tableGSUBin memory. - The effect: every picture with a 0 in the text of the system shows the slashed zero. The golden hashes of the renderer are of JetBrains Mono, which keeps its zero: they do not change.
What its tables say, read on its files, against JetBrains Mono:
| Paper Mono Regular and SemiBold | JetBrains Mono | |
|---|---|---|
| Outlines | glyf (TrueType), 800 glyphs | glyf |
| Units for one em | 1000 | 1000 |
| Advance of each ASCII character | 606: one for all, monospace | 600 |
| The scale on the grid of 8 | 8 / 606: an em of 13.2 pixels | 8 / 600: 13.3 pixels |
Ascender, descender (hhea, also the typo values of OS/2) | 955, -245 | 1020, -300 |
| Ink of ASCII 33 to 126, top and bottom | 803, -194: 13.2 pixels of height, in 16 rows | |
Baseline (glyph_style_of) | row 12: the ink from about row 1.4 to row 14.6 | row 12 |
| x-height, cap height | 509, 710: 6.7 and 9.4 pixels; the grid fit gives 7 and 9 rows | 550, 730: 7 and 10 rows |
| Glyphs of ASCII made of glyphs | i and j (a stem and the dot glyph 559, placed by x and y offsets, flags ROUND_XY_TO_GRID and USE_MY_METRICS): the reader takes them, and the subset makes them simple | 4 |
| Pair spacing | GPOS only (3.9 KB), no kern: a monospace font on the grid uses none | GPOS |
| Box drawing U+2500 to 257F, block elements U+2580 to 259F | all 128 and all 32 |
- Its capitals are one row shorter than those of JetBrains Mono at scale 1 (9 rows against 10) and its letters are 1 % narrower in the em. Its line is the same 16 rows.
- The box-drawing characters of Paper Mono, its block elements and its five Greek letters are in its subset past the 192 characters, and each window draws them (section 13).
build/fonts/candidates.pngand the picturefont_candidatesshow it beside the others.
The picture of the choice: font_candidates (the process vector_glyphs: the same line in Spleen and in the six fonts, the large number at scale 2, a word enlarged 4 times), and build/fonts/candidates.png (modustool vector_fonts: the same lines at scales 1, 2 and 3 in each candidate and in Spleen, the default with and without the grid fit, a word of each enlarged 5 times; drawn on the host by the same src/library/modus/graphics). Each draws a candidate through the face of the cells of a font set that holds that candidate as its font of the cells (text_rendering.font_file_open, graphics.character_of_set): the rasterizer, the grid fit and the blend of the text of the system, as if the candidate were the font of the system. No glyph of a candidate is kept: each is drawn band by band at each draw.
A bold weight for the titles
The titles of the cards (the card of src/library/modus/interface) are drawn in the emphasis weight of the font of the system: Paper Mono SemiBold (resources/fonts/paper_mono_semibold.ttf; Paper Mono has no Bold). The SemiBold has the same cells, and its face is Cells_Bold, from the font outlines. In the draw record of the interface package, the field weight of a text record is the weight of a text (0 regular, 1 bold). Bold with Spleen, or with no bold face, is the regular weight; the width of a text does not change.
7. The setting
The principal chooses the font, the order of the stripes, the pointer theme, the grid fit, the layout of the keyboard, the appearance, the scale factor, the time zone and the language list in the process settings. The choice is one shared page whose values only settings writes; every window reads it and draws again when it changes, and the choice survives a stop of the machine.
The settings are the smallest form that keeps the properties:
- Where it lives: one page, the settings page (
src/library/modus/contract/settings). The root service creates it at start. The page holds the choices only (the change count and one value for each setting): it holds no address, no size and no hash of a font file, because the processsettingswrites it (section 5, "Who can write a cache"). The processsettingsreceives it with Write (the roleSettingsof the root service: the one writer). Each process with a surface, each terminal and the compositor receive it read-only at the fixed rangeSettings_Page(settings.PAGE_ADDRESS), with its bit in the value 20 of their context, as the font outlines (P20: a grant of the root service, read-only; P9: no shared file). The root service writes the defaults into the page that it creates: the vector font,rgb, the scale 1.25. An all-zero page is refused, as the word 0 names no scale. - A change while processes run:
settingswrites the page (the change count is odd during the write) and wakes the threads that wait on the change count. The compositor waits on it: it gives the new choice to its own text, draws its whole screen again, and sends the display eventSettings_Changedto each window.src/library/modus/displaygives the new font tosrc/library/modus/graphicswhen the process reads the event, between two frames;src/library/modus/interfacedraws the whole window at the next frame (each draw record is the same, each pixel of text is not). A process draws again as it does for any event. The event is not enough alone: the compositor tells only the windows that have a surface, and a window that read the page before the boot pass ofsettingsand made its surface after it gets no event. Sointerface.window_frame_beginreads the choice at each frame (display.text_settings_apply, which says when the font, the order, a face or the appearance changed), as the drawing module does at each draw, and the terminal at each turn of its loop: the measure of an interface text decides its font from it, and a stale font would measure it in B612 over the settingspleen. The terminal writesterminal: console draws its interface text in the font of the cells(orin the interface font) at each change, which the machine test waits for. - The settings (one value of the page and one enum of
src/library/modus/contract/settingseach; the window shows the names ofsettings.descriptions, and the export takes the enums, whose members its module file names):font(.vector,.spleen),subpixel_order(.red_green_blue,.blue_green_red,.none),pointer_theme(.of_the_owner,.of_the_system),grid_fit(.on,.off),keyboard_layout(.united_states,.french) andappearance(.auto,.dark,.light). Value 0 of each is its default. The window names themrgb,bgr,owner,system,us. The module gives display texts for the members whose name is not the word that a principal reads, which the palette and the completion show:RGB,BGR,owner,system,US, and1.25to2for the scale (Module contract: The display text of a member). A line types the name.- The pointer theme: the root service gives the compositor both pointer theme files of the boot image (
pointer_theme_choiceinsrc/modules/system/root/resources.odinis the one place of their order: the values 6 and 7, then 18 and 19); the compositor validates each once and the setting chooses one live (pointer_theme_choose, a log line "the pointer theme in use"). - The grid fit: the setting chooses the face of the cells,
Cellswith the fit orCells_Without_Grid_Fitwithout it (display.cell_faces); each draws from the same font file, and the grid fit is in the key of the private glyph cache, so a change draws the glyphs of the other face once and keeps both. The picturefont_without_grid_fit. - The layout of the keyboard: the root service maps the settings page, read-only, in the input service, which reads the value at each key: a change holds from the next key. The two layouts are the United States (QWERTY) and France (AZERTY). A key record carries its character as a code point: the layout of France gives é, è, ç, à and ù from their keys, and â, ê, î, ô, û, ë, ï, ü and ÿ from its two dead keys,
^and¨(Glossary: Dead key; the rules are in The layout of the keyboard in the repository). AltGr, the right Alt key, gives its third level:#,{,[,|,\,^,@,],},¤and€from the keys of the row of the digits, of$and ofe, and the dead keys of the tilde and of the grave accent, which give ã, ñ, õ, à, è, ì, ò, ù and their capitals (Glossary: AltGr). AltGr withegives the euro sign €, which each font draws. The tables are insrc/library/internal/input/keyboard_layout. The input service holds no other right for it: the page is the one thing that it reads. - The appearance:
appearance(auto,dark,light) chooses the colors of the whole desktop (The design rules: The appearances; the design is The appearance in the repository). The page holds, beside the values, the appearance in force:darkorlight. Withauto, the light appearance holds from 07:00 to 19:00 of the local time and the dark one at night, by the date page and its time zone; a system with no date is dark. The processsettingsis the sole writer of the settings page: it writes the appearance in force with each change of the values, on date-page updates, and at 07:00 and 19:00 of the local time, with no wake between them. A process reads it at each frame, and the compositor sendsSettings_Changedto each window when it changes. The log says why: "settings: the appearance in force is light: the setting light". - The scale factor:
scale(.eight_eighths, 1, to.sixteen_eighths, 2;.ten_eighths, 1.25, is the default) is the count of pixels of the screen for one logical pixel, in eighths: the word of the page is the count itself, so its first word is 8 and not 0 (settings.word_of_value). Each window lets its surface go, makes its surface at the scale that the compositor names from its own budget, and draws again; the log has the line "display: <window>: the surface of 715x880 at 11 eighths" when the compositor takes it. Between the two surfaces the compositor draws the frame of the window with the background. Each member is a scale that the principal sets; a window whose budget cannot pay the scale declines it and shows its frame only, and the window of settings says how many did. A kept record of the six settings before the scale reads with the scale 1.25. The design is From the desktop of today to a light web browser: The reference screen in the repository. - The time zone:
time_zoneis not a row ofsettings.descriptions, because its value is a number and not a name of a list: a fixed offset from UTC, from-12:00to+14:00by quarters of an hour, with no summer time;+00:00, UTC, is the default (settings.set_time_zone("+08:00"), andsettings.time_zone()gives it). The page holds it beside the values (zone_offset_minutes). The processdatecopies it into the date page and wakessettings, which then moves the appearance in force ofautowhen the local time asks for it; the bar shows the local time. The design is The time zone in the repository. The log: "settings: time zone +08:00; kept in the store", then "date: the time zone of the date page is +08:00, from the setting time_zone". - The language list:
languagesis not a row ofsettings.descriptionseither: it is the languages that the principal reads, the first first, as at most 8 records oflanguage_tag.Locale(Glossary: Language list). The page holds them beside the values (language_count,languages); an empty list, the zeros of a new page, is English.settings.language_list_validis its border: a count past 8, a damaged record, the root localeund, a language twice or a record past the count refuses the whole page, as a word that names no value does. The design is The interface in the language of the principal: The identity of a language in the repository. The log: "settings: languages fr-CA, en; kept in the store". - The scheduling strategy is not a setting. The right
Schedulebelongs toscheduler. The settings service must not get a kernel right to pass it on (property 20: a service does not combine its own access with the request of a caller), and askingschedulerneedsschedulerto run as a service at boot with that right. The principal changes the strategy throughscheduler, the process that holds the right: in its window, or with its exportstrategy_set, which the console runs asstrategy(name)and the palette as an entry, and which serves only a caller that acts for the principal (Scheduling strategies: The change at run time). The process does not run at boot: it must be started. A strategy that survives a stop needs the root service, which holds the machine with each right, to read a record at boot. This is not built: it needs its own grant decision.
- The pointer theme: the root service gives the compositor both pointer theme files of the boot image (
- The process
settings: a resizable window of the interface package, from 400 × 320 to 1024 × 800 logical pixels, whose sections reflow in one column, or two from a width of 720, with a scroll bar when they do not fit (the design is The window of settings in the repository). Four cards: Display (the scale, the appearance, the font, the color stripes, the grid fit), Pointer, Keyboard, and Region and language. Each setting has its name, one line that says what it does, and its values as buttons with words for a reader (Spleen 8x16,None (gray),French (AZERTY)); the value in force is the marked button (the pointer and the keyboard: Tab, then Enter). The scale is a track of one stop for each member, 100 % to 200 %, each selectable; a line under it counts the windows whose budget declined the scale in force. The time zone is a list of the 38 offsets that the earth uses, each with places that keep it as their standard time (UTC+05:30 India, Sri Lanka), the zone in force chosen. The languages are the list in its order, each line with its name,UpandRemove, thenAddand the common languages that the list does not hold: English, French, French (Canada), German, Spanish, Japanese and Arabic. The window is the preview of the font, the appearance and the scale: it draws again at once in the new choice. Exports with descriptions (P19):settings.set(font, subpixel_order, pointer_theme, grid_fit, keyboard_layout, appearance, scale): one optional argument for each setting, of the enum of its setting, so a line gives the settings that it changes by their names:settings.set(keyboard_layout = .french),settings.set(font = .spleen, grid_fit = .off)(Module contract: Enum parameters). The console completes the members and refuses one that the enum does not have before the call. The result is 1, or an error record:No_Grant-1 for a caller that does not act for the principal,Absent-2 for a call that gives no setting,Bad_Value-3 for a value that names no member,Refused-4 when the store did not keep the values.- A getter for each setting, which the parameter of the same name of
setnames in the module file:settings.font()gives.vectoror.spleen, and so dosubpixel_order(),pointer_theme(),grid_fit(),keyboard_layout(),appearance()andscale(). The palette calls them when it opens, to mark the member in use of each row. settings.set_time_zone(zone)andsettings.time_zone(): the zone as a text,+08:00.settings.set_languages(languages): a table of 0 to 8language_tag.Localerecords, the first first;language("fr-CA")of the console reads a tag into its record. The result is 1, or an error record, and no language changes:Too_Long-3 for more than 8 records,Out_Of_Range-3 for a count past the capacity of the table,Bad_Value-3 for a record that is not a canonical locale or is the root locale (value: theLocale_Problem; found: the record, from 1),Exists-3 for a language twice,Refused-4 when the store did not keep the list.settings.languages()gives one row for each language: its canonical tag, its language, its script and its region.settings.repeat(count): count records kept, one commit each: the case of the loss of power. The console calls them afterconnect("settings"), and the palette shows one row of buttons for each setting from then;modustool callcalls them throughremote.
- The settings survive a stop.
settingskeeps the values as one record of 440 bytes (Kept_Settings: a magic, the version 3, a count, 8 values, the time zone, the count of the language list and its 8 records) in one object of its private store (P9): a change writes the record (one commit) first, then the page. At boot the root service startssettingsfor a boot pass (the context value 17): it reads the record, writes the page, wakes the compositor and stops, with no window. The log has one line of it,settings: the boot pass: ...; in N us. The storage service and the block service of the data disk start at boot for it. A record of another version, or none, gives the defaults. The boot pass writes the defaults in place of a record of another version, so a disk of an older system loses its settings once, and the next boot reads a valid record. - The boot display reads no setting: its text is Spleen in each drawer (The boot display at the scale of the screen in the repository). The first frames of the windows use the defaults (the vector font,
rgb) until the boot pass, as the root service reads no store; then the compositor sees the change of the page and each window draws again with the kept settings (its first loop compares with a change count of 0, so a window that read the page before the boot pass is told too). The boot pass takes 23 ms in the machine test with a new disk. - A loss of power (
modustool test power, the casepower_loss_settings_run):settings.repeat(1000)writes 1000 records, and the disk loses its power at the write of a root. Each of 306 images that a loss can leave (72 with a torn write) gives the durable record or the record in flight, never a mix, and each record is valid; the second machine starts on the hard image and its boot pass writes the durable record on the page.
8. Fallback
- No font outlines, or outlines that their validation refuses: the process draws Spleen 8x16, and its log has one line ("display: no font outlines: the text is Spleen 8x16" or "display: the font outlines are refused: <sentence>, value <n>: the text is Spleen 8x16"). Outlines that lack the first font of a face: that face draws nothing, its text is Spleen or the font of the cells, and the log names the count of the fonts that the chains lack.
- Outlines whose hash is wrong: the root service does not map them (one line on the log), and no process has them.
- A damaged font file at build time: the tool stops the build with the problem (
vector_font.Font_Problem). The reader checks each read (host testhostile_files: the file cut at each 211 bytes, 48 files with 64 changed bytes, each glyph drawn at the three scales: no fault). - The boot display uses no font file: the boot program has none before it checked the boot image, so the boot program, the root service and the process
bootdraw it in Spleen at the size of its scale, the same pixels in each (The boot display at the scale of the screen in the repository). - A character that the font lacks: each font of the system holds ASCII 32 to 126, the Latin-1 Supplement and the euro sign, and each candidate has all of them (the subset command refuses a font without one). Spleen 2.1.0 has them too (
modustool font). A text is UTF-8: the drawing decodes it, gives each character one cell, and draws each other character, and each invalid sequence, as the replacement glyph, the outline of a box (graphics.character_replacement), in both fonts and at each scale. A process with the font outlines draws the Greek letters of B612 in a text of the interface font, and the box-drawing characters, the block elements and the five Greek letters of Paper Mono in a cell of the vector font, each into its private glyph cache (section 13).
9. Measures
Each pair was measured in the same hour with the same tool: Spleen at the commit c909390, the vector font rebased on cacaf48 (the frame caches are between: they do not draw). The load of the host was 15 to 37 during each run (uptime in the log of the run): above 8, so by the rule of the project these numbers are not valid measures of speed. They show the order; a run on a quiet host is needed.
| Measure | Spleen (c909390) | The vector font |
|---|---|---|
flood: lines in one second (the terminal draws a full window at each picture) | 3 925 316 | 4 302 808 (other runs: 1 594 054 and 2 629 205 at load 30 to 45) |
| The terminal: pictures in one second | 62 | 62 |
| A full frame of the desktop with 16 windows, measured on a screen of 1024 x 768 (the reference screen is 1920 x 1080) | 1 683 to 3 424 us | 1 523 to 2 653 us |
interface_elements: the whole frame / the next frame in its damage | 402 / 119 us | 637 / 158 us (875 / 209 us at load 45) |
time_page: one picture, the mean of 10 | 19.9 us | 31.5 to 46.3 us (211.7 us in one run) |
| The boot image | 3 566 097 bytes (cacaf48) | 3 778 016 bytes: +390 624 the glyph cache, +64 193 settings, -231 953 vector_glyphs (the 343 KB file of DejaVu out, six subsets in) |
| The glyph cache | 390 624 bytes; its hash checked by the root service in 796 to 966 us |
The console stays fast: the producer writes into the terminal ring, and the terminal draws at most 62 pictures in one second whatever the font; a picture of the window of flood (about 2 500 characters that are not spaces) costs about 0.7 ms more with the vector font (2 500 times 274 ns), under 5 % of a processor at 62 pictures in one second. The full frame of the compositor copies surfaces: the font does not enter it.
10. Gaps
- One glyph from the cache costs 3.2 times a glyph of Spleen at scale 1 over a flat color, and 5.3 to 5.6 times over a gradient across or a picture, where the blend tables do not apply (section 5).
- No grid fit of each stem; no stem darkening (
gui_toolkitthickens the stripes by 0.2 pixel; not tried here). - The first frames use the default settings until the boot pass of
settings(section 7). - The scheduling strategy is not a setting and does not survive a stop (section 7).
- The glyph caches hold no character past the Latin-1 Supplement but the euro sign. Past them, each window draws the Greek letters of B612, the box-drawing characters, the block elements and the five Greek letters of Paper Mono, and Π, ρ, the Cyrillic letters and Latin Extended-A of Noto Sans, in its labels, its titles and its cells (section 13). A character joins the list of the added characters when each font draws it (Text encoding: UTF-8 in every contract in the repository). A monospace cache has no subpixel position; the proportional font and its pairs are in section 12.
- The order of the stripes of the screen is not detected: under QEMU it is the panel of the host, which the system cannot read.
- The measures of section 9 were taken on a host with a load above 8.
11. Open decisions
- 1. The font file: Paper Mono (section 6). Another candidate is one line,
DEFAULT_VECTOR_FONT. - 2. The grid fit by default: on (now) or off. It is now a setting of the principal (both caches are in the boot image); the decision is only which value is 0.
- 3. The order of the stripes by default:
rgb(now), ornoneuntil the system can know the panel. - 4. The interface font: the size of B612 (an em of 13.33 pixels: capitals of 10 rows), and the positions of its cache (3 at scale 1 and 1 at the scales 2 and 3: 509 340 bytes measured with the Bold titles; or 3 everywhere: about 2.45 MB, estimated), section 12.
- 5. The scheduling strategy across a stop: a record that the root service reads at boot, or none (section 7).
12. The interface font and the text shaping module
Words that name things (titles, labels, buttons, menus) read better in a proportional font, where each letter has its own width. The system has one, B612, beside the font of the cells. A proportional font needs shaping: the place of each glyph comes from its advance and from the pair that it forms with the next one.
B612 (<https://github.com/polarsys/b612>, version 1.008, the package b612 of nixpkgs; SIL OFL 1.1 with no Reserved Font Name: "Copyright 2012 The B612 Project Authors [...] This Font Software is licensed under the SIL Open Font License, Version 1.1", read in OFL.txt of its repository) is the font of the interface: the titles, the bar, the menus, the labels, the cards. It is proportional. Paper Mono stays the font of the text that is monospace (section 6). The system needs a module of text shaping and pair spacing for it. This section is the design; 12.8 says which parts are written.
12.1 What B612 has, read in its files
| B612 Regular | B612 Bold | |
|---|---|---|
| Outlines | glyf (TrueType), 593 glyphs; no glyph of ASCII is made of glyphs | the same |
| Units for one em | 2000 | 2000 |
| Advances of ASCII 32 to 126 | 19 different values from 400 to 2000 units, the mean 1148; the space 700; i and I 600; m, M 1800; W 1900 | the same advances |
| Digits | each 1300: digits are tabular, a column of numbers aligns | the same |
Ascender, descender (hhea, typo of OS/2) | 1930, -500; the ink of ASCII from -517 to 1720 | 1930, -500 |
x-height, cap height (OS/2 sxHeight, sCapHeight) | 1100, 1500. The flat tops of E, T, Z are at 1500; the stems of H, I, L end with an angle at 1520, and x reaches 1117 | 1100, 1500; the top of H is 1527 |
| Ink beyond the advance box | at most 61 units left of the origin (j), none past the advance | 126 left (j), 52 past the advance (K) |
| Pair adjustment | kern version 0, one subtable of format 0: 1017 pairs; GPOS with one lookup of type 2 (pair adjustment, subtables of format 1 and 2), feature kern | kern: 1061 pairs; GPOS the same form |
| Substitution | GSUB with no feature: no ligature, no contextual form | the same |
| Box drawing | none | none |
- For ASCII,
kernandGPOSgive the same pairs: 232 pairs in Regular and 239 in Bold whose two glyphs are ASCII, each with the same value in both tables, none in one table only (read on the files with a script outside the system, not with code of the system). The values are -200, -150, -100 and +100 units in Regular, and also -50 and +50 in Bold: at the size below, -1.33 to +0.67 pixel. Examples: "To", "LT", "Ty" -100; "LV" -150; "Wa" -100 in Bold only. "AV" has no pair in either weight: B612 spaces "A" and "V" by their advances alone. - So the first version reads
hmtxandkernformat 0 only. It reads noGPOSand noGSUB, and has no ligature and no other script. A font whose pairs are only inGPOSneeds theGPOSreader later, behind the same contract.
12.2 The size on the grid
- The line stays 16 pixels at scale 1 (32, 48 at the scales 2 and 3), so a label sits in a line of the grid as text does now.
- The em of B612 at scale 1 is 13.33 pixels (2000 units to 13.33 pixels, one unit is 1/150 of a pixel): its cap height is then 10 pixels and its x-height 7.33 (the grid fit of section 2 gives 7). The cap height and the x-height are the values that the font states in
OS/2(1500 and 1100), not the tops of the outlines ofHandx(1520 and 1117 in Regular, 1527 and 1124 in Bold), which the monospace path uses (section 2): the flat tops of the capitals must sit on whole rows, and both weights get one scale. A host test checks that E, T and Z have ink on rows 2 to 11 exactly. Its ink, from -517 to 1720 units, is 14.9 pixels: inside 16 rows, with the baseline on row 12. - Its mean advance in ASCII is 7.65 pixels: a label in B612 is about as wide as in Paper Mono (8 pixels), narrower for lowercase text, wider for capitals (
M12 pixels).
12.3 The text shaping module
A module (property 10: shared code with exports), with batch exports whose parameters are tables (Module contract: Tables and bytes as parameters). Its name: text_rendering. Each process compiles the shaping of the package src/library/modus/text_rendering in (section 14); the library module src/modules/libraries/text_rendering gives the same work to a caller that does not compile the package, as interface_module does for src/library/modus/interface.
As written:
| Export | Parameters | Result |
|---|---|---|
shape_text | the font outlines (Bytes, Read), the face, the text size, the text (Bytes, Read), the placed glyphs (Append), the error record | the count of placed glyphs of the full answer, or -1 |
measure_texts | the font outlines, the face, the text size, one table of bytes (Read), the ranges (Change: start, count, and width that the export writes), the error record | the count of ranges, or -1 |
break_text | the font outlines, the face, the text size, the text (Bytes, Read), the room in 1/64 of a pixel, the lines (Append, one Text_Range for each line), the error record | the count of lines of the full answer, or -1 |
- The font outlines are bytes of the caller: the resource
font_outlinesthat its starter mapped, or a copy of it, on 8 bytes. Each call opens the fonts of those bytes on its stack (about 16 KiB), measures with them, and keeps nothing. So an isolated call receives the outlines in the call region like the text, and gives the answer of a direct call. - The face is a number of
text_rendering.Facefrom 1 to 5. The export refuses each other number, andNone, withBad_Value. The text size is the height of a line in 1/64 of a pixel: a size under 256 is refused withToo_Small, a size past 16 384 withBad_Value. Outlines thatfont_outlines.validaterefuses giveBad_Valuewith the problem as the value; outlines with no first font of the face giveAbsentwith the font as the value. - Hostile bytes: the caller can change its bytes during the call. The header and the records of the outlines are copied once and checked; the parser checks each read of a font file against its bytes;
font_openrefuses a character map whose segments pass its subtable or whose end codes do not grow strictly, soglyph_offinds a segment by halves, not in a line of up to 32 767 segments; each advance and each pair is kept in its bound at its read (an advance from 0 to one line, a pair within half a line, at any size). A changed byte gives other numbers, never a read out of the bytes, and the x of each glyph holds in ani32. - A character that no font of the chain has (and a control character, and an invalid sequence of UTF-8) is placed as
REPLACEMENT_GLYPH, with the advance of0and no pair, and the reader draws the replacement glyph there, so a reader sees that the font does not draw it. Each placed glyph has the first byte of its character as its cluster. - The widths in a table of ranges: the width is a field of each range record, which the export writes (the direction Change), as
sumin the records ofsample.sum_words.
The design before the code:
- Input: the font (a record: its kind, its scale, its weight) and a table of characters: the bytes of a text of UTF-8, with glyphs for ASCII 32 to 126, the Latin-1 Supplement and the euro sign.
- Output: a table of placed glyphs, one for each character, in memory of the caller. A placed glyph is 16 bytes: the glyph (its index in the glyph cache), x (its origin from the origin of the run, in 1/64 of a pixel), the advance in 1/64 of a pixel (with the pair adjustment that follows it), and 4 bytes that are zero (a cluster number for a full shaper later).
- The measure of a text is the sum of its advances: one export
text_widththat gives it with no output table, for the layout. - Many texts in one call: a second form takes a table of runs (each a start and a count in one table of bytes) and fills one table of placed glyphs and one table of widths: a window measures all its labels in one call.
- What it reads: this first design read the advances and the pairs of the glyph cache, which the tool wrote at each scale. The shaper now reads the font file at each measure (section 14.7): the advance of the table
hmtxand the pair of the tablekern(878 pairs in B612 Regular and 914 in Bold), at any size. - The work for one character: one lookup of its glyph in the character map of each font of its chain until one has it, one advance, and one search of the pair with the next glyph in the sorted pairs of its font (10 compares).
- The same contract takes a full shaper later: characters in, placed glyphs out. A shaper with ligatures gives fewer glyphs than characters and uses the cluster number; the callers already read the count of the output.
12.4 The glyph cache with subpixel positions
- Positions: a glyph of a proportional font does not start on a whole pixel. With the subpixel bands, the finest step that the screen shows is one third of a pixel: the cache keeps each glyph at 3 positions, 0, 1/3 and 2/3 of a pixel. The draw rounds the x of a placed glyph (in 1/64) to the nearest third, so the error is at most 1/6 of a pixel; the shaper keeps the exact sum, so errors do not add up along a run.
- The cell of a glyph is its ink box, not the cell of the grid: its width is the ink width plus the spread of the filter (two thirds of a pixel on each side) plus the position, its left side at a stated bearing from the origin. The glyph entry gains this width and this bearing (
left,width). It was one format of the glyph cache file, for the monospace caches too (section 5): fewer paths than two formats. The file left the system; the private glyph cache keeps the same box of each glyph (text_rendering.Glyph_Entry). - The renderer (
vector_font.glyph_render_placed): the glyph is drawn in a work row of 64 pixels with its origin at column 4 plus the position (one third of a pixel for each step), then cut to the box of its ink. A glyph whose ink reaches a side of the work row is refused. The size on the grid: the cap height is 10 rows at scale 1 (PROPORTIONAL_CAP_HEIGHT_ROWS), so 1 200 units of B612 are the 8 pixels of a cell (the stated cap height of 1 500 units times 8 / 10). The advances and the pairs are scaled the same way and rounded to 1/64 of a pixel, each on its own, to the nearest integer, a half toward plus infinity, the same rule for a negative value: "A" 1 300 units is 554.67, so 555/64 of a pixel at scale 1; "To" -100 units is -42.67, so -43/64; "LV" -150 units is -64/64 exactly. - The rule of the sum: the cache keeps the rounded advance and the rounded adjustment, and the shaper adds these integers. So the advance of a glyph followed by a pair is round(advance) + round(adjustment), not round(advance + adjustment): "T" before "o" is 512 - 43 = 469. The two rules can differ by 1/64 of a pixel for one pair; the x of each glyph is the exact sum of the integers before it, so no error adds up along a text beyond the rounding of each term (at most 1/128 of a pixel each).
- Size, measured (
modustool vector_fonts, 2026-11-11): B612 Regular with 3 positions at scale 1 and 1 at the scales 2 and 3, 408 524 bytes; B612 Bold at scale 1 with 3 positions, 100 816 bytes; together 509 340 bytes. These two were measured with the cap height taken fromH(1 520 units), before the correction above: with 1 500 the glyphs are 1.3 % larger on each axis, so a new run gives a few percent more. The table below is the estimate from the boxes of the glyphs, made before the build; it was 10 % (Regular) and 18 % (Bold) above the measures:
| Cache | 1 position | 3 positions at each scale | 3 positions at scale 1, 1 at the scales 2 and 3 |
|---|---|---|---|
| B612 Regular, scales 1 to 3 | 376 KB | 1 165 KB | 452 KB |
| B612 Bold, scales 1 to 3 | 415 KB | 1 288 KB | 497 KB |
| B612 Bold, scale 1 only (the titles) | 39 KB | 123 KB | 123 KB |
| Today: the cache of the monospace font | 390 624 bytes |
- Built: B612 Regular with 3 positions at scale 1 and 1 position at the scales 2 and 3, and B612 Bold at scale 1 with 3 positions: 509 340 bytes measured (575 KB estimated) more in the boot image. At the scales 2 and 3 a glyph on a whole pixel is at most half a pixel from its place in a glyph of 26 to 40 pixels. With 3 positions everywhere, 2.45 MB.
12.5 What changes in src/library/modus/interface
- A font kind:
Font_KindgainsInterface(B612), besideCells_8x16(the monospace font). The weight is the fieldweightof a text record. - The text record: the kind
Textwith the fontInterface. Its box is the measured box widened by the ink margin of the font on each side: 2 pixels for B612 (its ink passes the box by at most 126 units, 0.84 pixel, and the filter by two thirds of a pixel). Its origin is a place in 1/64 pixel on a third of a pixel, the margin right of the left edge of its box, because the cache has 3 positions only (The interface of the processes: Draw record). So the damage stays exact. - The draw:
executeasks the module for the placed glyphs of the run, then draws each glyph from the cache at its third of a pixel. The glyphs of one run can overlap by their margins: the blend reads the pixel under, so an overlap is drawn right. - The spacing tokens place the elements, not the letters: the space between a card, a button and a line of a table is a token or a sum of tokens (The design rules: Spacing); the text inside starts at the inner place of the element, and its width is what it is. A size of a column that came from a count of characters (
characters(n)) stays n times 8 for the monospace font;measured_size(text)gives the width of a text in the interface font, with no round up. - Elements that change: the title and the caption of a card, a label of
label_value_line, a button, a line of a list, the bar and the menus of the compositor, the title bar of a window. The values oflabel_value_linethat are numbers stay monospace (the rule below).
12.6 Which text stays monospace
A rule that a process can follow:
- Monospace (Paper Mono): each text that is a grid of cells (the terminal, the console,
Text_Gridrecords); each text that a reader compares character by character or copies (hashes, addresses, names of exports, code, the text of a log record); the columns of a table whose values align by character. - Interface (B612): each text that names or explains: titles, captions, labels, buttons, menus, the bar, the title of a window, sentences of help.
- Numbers: in either. The digits of B612 are tabular (1300 units each), so a column of numbers aligns in B612 too, at the right of its column (The design rules: Text).
12.7 The cost for each glyph, against today (estimated, not measured)
- Shaping: one advance and one pair for each character: a few nanoseconds, against 0 today (the advance of a monospace font is a constant).
- Drawing: the box of a glyph at scale 1 holds about 100 words with 3 positions, against about 64 words in the rows with ink of a cell today; the partial pixels are about the same (the ink is the same). Expected about 1.2 times the fast blend of today (109 ns on the host at scale 1 over a flat color).
- The measure of a label: one call of the module for all the labels of a frame; today
text_widthis a multiplication.
12.8 The parts, each one working
Each part below is written. Part 2 also writes the two caches of B612 in build/fonts at each modustool vector_fonts. Parts 4 and 5 come with the process interface_font.
- 1. The shaping data in the tool:
modustool vector_fontssubsets B612 Regular and Bold (ASCII, simple glyphs,kernformat 0 kept as a sorted pair table) toresources/fonts; host tests: the advances and the pairs of the subset against the font file, and the pairs ofkernagainst those ofGPOS(the check of 12.1, as code). - 2. The glyph cache version 2: a glyph entry with its box width, its bearing and its positions; the advances and the pair table of each scale; its validation; the builder in
src/library/modus/vector_font; host tests: the bit-for-bit test of each position against a render at that offset, the golden hashes, damaged fields. - 3. The shaping module, now the library module
text_rendering, with its exports over the font outlines of the caller (12.3); host tests: the three ways to call give the same records; each argument of a hostile caller is refused with its argument named; the bounds hold at the largest size. - 4.
graphics.text_proportional: draw a table of placed glyphs with the fast blend at thirds of a pixel; host tests bit for bit against the reference blend; the measure of section 5 for B612. Written:graphics.text_proportional(canvas, place, y, placed, face, scale, color):placeis the x of the origin of the text in 1/64 of a pixel. Each glyph goes to the nearest third of a pixel (text_rendering.position_of), from the private glyph cache of the process (text_rendering.glyph), through the blend of the text of cells (glyph_words_draw: the table blend, with the form of the target as its fallback), cut to the canvas. The glyphREPLACEMENT_GLYPH, and a glyph that no font of the chain draws, draw the replacement glyph at their place. A glyph past the character indices that is no fallback glyph, a glyph far outside the canvas, a scale out of 1 to 3 and a face that is not proportional draw nothing.- The ink margin: the ink of a text passes the box that its measure gives by at most
PROPORTIONAL_INK_MARGIN(2 pixels at scale 1) on each side. The host testthe_ink_lies_inside_the_measured_boxdraws 200 texts at places with a fraction of a pixel and counts the pixels of ink outside the box and its margin. - The host test
proportional_text_gives_the_same_bytes_in_each_blendcompares the table blend, the SSE2 form and the scalar form for three texts, three places, each order of the stripes and four backgrounds. - The text of cells refuses a proportional face (
graphics.text_faces_use): its glyphs pass their cells, so the damage of a grid of text cells would leave stale pixels. - The process
interface_font(pictureinterface_font): a paragraph in B612 Regular, a line in B612 Bold, "To", "LT", "Ty" at scale 3 with and without the pair adjustment, one word at 0, 1/3 and 2/3 of a pixel enlarged 4 times, numbers at the right of two columns, and the time of one line (shaping and drawing, the least of 50 batches, and the first draw, which draws each glyph from its outline, on its log and in its window). It takes its two faces from the font outlines (part 5).
- 5. The faces of the interface font:
InterfaceandInterface_Boldfrom the font outlines, which the root service maps read-only for each process with a surface, each terminal and the compositor; a fallback to the font of the cells when the outlines lack B612. Written.display.interface_font_opengives the two faces when this process opened them (display.interface_faces_opened). When they are absent, the processinterface_fontsays so and stops. The fallback to the font of the cells is insrc/library/modus/interface(part 6). The two glyph caches of B612 that the boot image held before left it. - 6.
src/library/modus/interface: the font kindInterface, the text record with its origin fraction and its margin,measured(text); the card, the label, the button, the list in B612; the damage tests with overlapping glyphs. Written:- The font kind
InterfacebesideCells_8x16, and the text record in that font (aTextwhose font field isInterface): its box is the measured box grown by the ink margin, its origin in 1/64 pixel on a third of a pixel. The execution shapes the text and draws it withgraphics.text_proportional. - The font is the font of the table:
Draw_Table.interface_font, whichwindow_frame_begintakes fromdisplay(found once atopen). A text is measured in the font that draws it (font_in_use): with no interface font, or with the setting Spleen 8x16, each element draws in the font of the cells with the same rules. text_measured_width,texts_measure(the lines of a list, in one call),measured_size(a column as wide as its text) andtext_fit(the longest start that fits): each element cuts each text to its box, in either font.- The elements: names, titles, labels, buttons, lists, headers in the interface font; values in the font of the cells (The interface of the processes: Text).
- Host tests:
damage_of_interface_text_equals_the_whole_frame(200 pairs of frames, byte for byte against a whole frame),no_element_passes_its_box_in_either_font,the_font_of_a_text_is_the_font_of_its_measure,hostile_interface_text_records_draw_nothing; in the drawing module (src/modules/libraries/drawing),hostile_interface_text_records. - The module
interface_modulefinds the interface font of the process that runs it: in a direct call the caller's (the font outlines, which its copy of the text rendering opens to measure), in an isolated call none (the call host has no font outlines), so its elements draw in the font of the cells there. - The drawing module (The interface of the processes: Where it lives: the elements in each process, the drawing in a module) draws the text of each process that imports it. It loads the text settings and the interface font of the process at its first draw, from the context of the process, into its own data: the same font outlines at the same fixed range, opened a second time by the copy of the code in the module, which draws each glyph into its own private glyph cache. It reads the choice of the settings page again at each draw. The process measures a text from the font files that its own copy of the text rendering opened (section 14.7).
- The measure:
interface_elementslogs the time of one whole frame, built and drawn, in each font (the least of 20). Not measured yet.
- The font kind
- 7. The compositor: the bar, the menus, the title bars, the palette in B612. Written:
- The compositor loads the interface font as each process does (
display.interface_font_load): the root service gives it the font outlines and their bit with the settings page, before it starts. No change of the start order. - Names in B612: the lines of the two menus and their headings, the names of the window plates and the labels of the tray, the titles of the windows (cut in their font before the close button), the names, the hints, the headings and the sentences of the palette. Values in the font of the cells: the clock and the date, the text that is typed, the counts of the menus and of the palette. The cross of the close button stays a cell.
- The bar layout (
bar.Layout): the widths ofstart,windowsand the widest name, measured in the font that draws the bar. Each place ofsrc/library/internal/compositor/bartakes it: a button is its label and a padding; a column of the start menu is the widest name and a padding, with no round up; the menu of the windows keeps a room of 256 pixels for a title, the room of its 32 cells, so it has one width in both fonts.bar.button_at,bar.line_atandbar.windows_line_atmap a point to an entry; host tests check each entry in four layouts, B612 among them. - The compositor writes
compositor: the bar is in the interface font: start N pixels, windows N, the widest name N(or... in the font of the cells) at its start and at each change. The modus tool reads the last such line, measures the layout from the font outlines of the build (build/fonts/font_outlines.bin), and refuses a step when its numbers differ from the line. - Damage: a title is written once, when its surface is created, and is in the damage of its window. A change of the bar layout damages the bar and the places of the old and of the new menus.
- The measure:
compositor: the bar and the start menu, built and drawn (the least of 20), in each font, once after the first frame of a measure run (system.measure_run): never on the path to the first frame. - The boot display: not in B612. The boot program holds no font file, so the display is in Spleen in each drawer, the root service too, at the size of its scale (The boot display at the scale of the screen in the repository). The design rules: Text, writes the rule.
- The compositor loads the interface font as each process does (
- 8. The design rules: Text: the rule of the two fonts of 12.6 is a design rule. Written.
12.9 Where this design is least sure
- The interface font is a choice of each table: a process that builds its own tables (the compositor, the measures) keeps the font of the cells unless it names the font. A record of the interface font drawn by a process with no interface font is drawn in the font of the cells, cut to its rectangle: a module in an isolated call never meets this, because it measures in the font that it has.
- The ink margin of 2 pixels at scale 1 is the bound that the test of 200 texts of
graphicsmeasured for B612; another interface font needs its own margin. - The sizes of 12.4 of the two caches that are built are measured; the other columns of its table are estimates from the glyph boxes, which were 10 % to 18 % above the measures.
- The cost of 12.7 is an estimate; the fast blend tables need two pixel colors at the two ends of a row of a glyph, which holds for a label on a card, not for a title bar with a gradient across (the reference blend there, as today).
kernandGPOSagree for ASCII in B612 1.008; a later version of the font, or another interface font, can have pairs inGPOSonly.- 3 positions and not 4: the step of the stripes is a third; a finer step is invisible with the subpixel bands and costs one more copy of each glyph.
13. Glyphs past the glyph cache
Each font of the system holds 192 characters, and some hold more. A character takes the glyph of the first font of its fallback chain that has it. Each process draws each glyph itself, the 192 characters and those past them, from the font outlines of the boot image, into its private glyph cache. No process asks another for a glyph, and no shared memory holds a glyph that a process drew. The boot image carries the outline of a character, not its drawn words at each size. The intent of this design is Glyphs past the glyph cache in the repository; the glyph caches of the boot image left with Text rendering: one module for text at any size in the repository.
13.1 The parts
| Part | Where | What it does |
|---|---|---|
| The font outlines | the resource font_outlines, src/library/modus/contract/font_outlines, the fixed range Font_Outlines | The font files of the faces (B612 Regular and Bold, Paper Mono, Paper Mono SemiBold), each with its name and its BLAKE3 hash. The root service maps it read-only beside the settings page; a process validates its header once. |
| The text rendering | src/library/modus/text_rendering | In each process and in the drawing module: the fonts of the outlines opened once, the faces, the chains by script, the advance of a character from its font file at a text size, the shaping, the breaks of the lines, the rasterizer at any size, and the glyph of a character from the private glyph cache (section 14). |
| The faces | text_rendering.Face | Interface (B612 Regular), Interface_Bold (B612 Bold), Cells and Cells_Without_Grid_Fit (Paper Mono with and without the grid fit), Cells_Bold (Paper Mono SemiBold). A face draws once the outlines hold its first font (face_opened); display gives graphics the face of the cells of the setting grid_fit and Cells_Bold. |
| The private glyph cache | text_rendering.Private_Cache | 262 144 words (1 MiB) in runs of 32 to 16 384 words, and 4 096 entries by face, font, glyph index, text size and position, in the memory of the process. A new glyph that finds no room evicts the glyphs used the longest time ago, counted in frames (text_rendering.frame_begin), never a glyph of the frame in progress. |
| The root service | src/modules/system/root/text_settings.odin | Checks the font outlines, and maps them with the settings page in each process that gets them (each process with a surface, each terminal, the compositor, a process from a disk). It keeps no handle for each process. |
| The compositor | display.script_coverage_tell | Writes what each fallback chain lacks, once at each boot. |
| The shaper and the draw | text_rendering.Spacing, graphics.text_proportional, text_scaled, text_bold, character | A character of the 192 is the placed glyph of its character index; a character past them that the chain has is FALLBACK_GLYPH_FIRST plus its code point; each has the advance of its font file. The draw takes each glyph from text_rendering.glyph. |
13.2 What a process does
- 1. At its start,
display.text_settings_loadopens the font outlines that the starter mapped (text_rendering.open), and gives graphics the faces of the cells. The drawing module does the same in its own copy at its first draw. - 2. A spacing names a face and a text size (
text_rendering.spacing_of). The shaper places each character with the advance and the pairs of its font file (section 14.7); a character past the 192 that the chain has is a fallback glyph. Another one is the replacement glyph, with the advance of0. The measure never depends on a cache, so the measure and the draw of a frame agree. A process uses the interface font only when it opened both of its faces (display.interface_faces_opened): with no outlines, its elements draw in the font of the cells. - 3. Each frame starts with
display.text_frame_begin:interface.window_frame_begin, the drawing module anddisplay.presentcall it, so a process that draws text by hand gets its glyph memory at its first picture. - 4. The draw takes each glyph from the private glyph cache, where it draws it at its first use: 3 to 46 µs, in the frame.
The process never waits for another process. With the setting font at spleen, a cell past the characters of Spleen draws the replacement glyph: a glyph of Paper Mono does not stand beside the glyphs of Spleen 8x16.
13.2.1 What a terminal does
A terminal draws its cells through the drawing module, which draws each glyph into its private glyph cache. A cell of a box-drawing character, a block element or one of the Greek letters Λ, Ω, λ, μ and π draws its glyph of Paper Mono, in the weight and the grid fit of the cells beside it. A Greek letter that Paper Mono lacks draws its glyph of B612, the second font of the chain of the cells, in the frame of Paper Mono: in its cell, on the baseline of the cells. A Cyrillic letter, Π, ρ and a letter of Latin Extended-A draw their glyph of Noto Sans, the last font of the chain, in the same frame. Its log has one line for each font of the first and the last such characters of its view, and one line for a character that no font has:
terminal: console shows the character 945 in its cells, drawn by this process from the font b612 of its fallback chain, which the main machine test waits for aftercharacter(945) + character(1046)in the console;terminal: console shows the character 1046 in its cells, drawn by this process from the font noto_sans of its fallback chain, after the same;terminal: console shows the character 1120 in its cells as the replacement glyph: no font of its fallback chain has it, aftercharacter(1120);terminal: console shows the character 9472 in its cells, drawn by this process from the font paper_mono of its fallback chain, aftercharacter(955) + character(9472).
13.2.2 What the caches tell a process
The private glyph cache of a process is in its own memory, and its evictions are inside the process. The font outlines are pages of the boot image that no process writes. So a process learns from no cache what another draws (Kernel properties: No ambient access: the other holes to close, row 17). No process sends a request, so the time of an answer tells nothing either.
13.2.3 The fallback chains, and what they lack
The chains are data (text_rendering.scripts): one row for each script, with the fonts of each face in order. A character takes the first font of its chain that has its glyph; a character of no row takes the default chain of its face.
| Script | Interface | Cells |
|---|---|---|
| Greek (U+0391 to U+03C9, 49 letters) | B612, Paper Mono, Noto Sans | Paper Mono, B612, Noto Sans |
| Cyrillic (U+0400 to U+045F, 96 letters) | Noto Sans | Noto Sans |
| Box drawing and block elements (U+2500 to U+259F) | Paper Mono | Paper Mono |
| Each other character, Latin Extended-A too | B612, Paper Mono, Noto Sans | Paper Mono, B612, Noto Sans |
The bold weights follow the same rows with B612 Bold and Paper Mono SemiBold first. Noto Sans has one weight: a bold Cyrillic letter, Π, ρ or a bold letter of Latin Extended-A draws in its regular weight. A glyph of a font that is not the first of its face is drawn in the frame of the first font: its outlines are scaled so that its cap height is the cap height of the first font, on the baseline of the first font; in a face of cells it is cut to its cell.
The compositor writes one line for each script at its start, with what the chains draw:
compositor: the script greek: the chain of the interface draws 49 of its 49 characters, the chain of the cells 49;compositor: the script cyrillic: the chain of the interface draws 96 of its 96 characters, the chain of the cells 96;compositor: the script box drawing: the chain of the interface draws 160 of its 160 characters, the chain of the cells 160.
The process interface_font shows the Greek letters of B612, box-drawing characters from Paper Mono in the interface font, and writes interface_font: each Greek letter of B612 is drawn by this process: 47 letters: as it must, interface_font: the box-drawing characters come from paper_mono, the second font of the chain of the interface: 7 characters: as it must and interface_font: 3 characters that no font of the chain has draw the replacement glyph: as it must.
13.3 What stays built at build time
The subsets, the font outlines, Spleen 8x16 and the boot display are built at build time. No glyph is: the first frame of the compositor, of the terminal and of each window draws its glyphs from the outlines, in its own process, and needs no service.
13.4 The subsets
The subset of B612 Regular holds the Greek letters that its character map has, after the characters of the glyph cache (font_outlines.interface_past_cache_ranges, written by modustool vector_fonts): 47 characters, U+0391 to U+039F, U+03A1, U+03A3 to U+03A9, U+03B1 to U+03C0 and U+03C2 to U+03C9. B612 1.008 has no capital pi (U+03A0), no small rho (U+03C1), no Cyrillic and no Latin Extended-A. The window interface_font shows each of these letters, and its line interface_font: each Greek letter of B612 is drawn by this process: 47 letters: as it must is a line of the machine test.
The subsets of Paper Mono and of Paper Mono SemiBold hold 165 characters past the glyph cache, after the characters of the glyph cache (font_outlines.cell_past_cache_ranges): the box-drawing characters U+2500 to U+257F, the block elements U+2580 to U+259F, and the five Greek letters of Paper Mono, U+039B, U+03A9, U+03BB, U+03BC and U+03C0. Paper Mono has no other Greek letter: a cell of α draws the α of B612, the second font of the chain of the cells. The box-drawing characters of Paper Mono pass their advance by 5 units on each side; the cell cuts them, as it cuts each glyph of the cache of cells.
The subset of Noto Sans, "Noto Sans LGC" (resources/fonts/noto_sans.ttf, SIL OFL 1.1), is the last font of each chain: it holds the 192 characters, whose outlines give its measures, then 273 characters past the glyph cache (font_outlines.script_fallback_past_cache_ranges): Latin Extended-A, U+0100 to U+017F; the 49 Greek letters, U+0391 to U+03A1, U+03A3 to U+03A9 and U+03B1 to U+03C9; the 96 Cyrillic letters, U+0400 to U+045F. Its source is the variable font NotoSans.ttf of the package noto-fonts of nixpkgs: the subset holds the outlines of its default instance, the regular weight, with its 196 glyphs made of glyphs made simple. It has no table kern, so its glyphs have no pair. It is 87 172 bytes.
The 192 characters keep their glyph indices: the characters past them come after them in each subset.
13.5 Who can write the font outlines and the private glyph cache
- The font outlines are pages of the boot image, whose one handle has no right Write, mapped with the right Read only, after the root service checked their hash and their format (
font_outlines.validate). Each record names the hash of its font file. - The private glyph cache is memory of the process: only the process writes it, and only the process reads it.
13.6 The pixels
A glyph has the bytes that the build gives to the same character from the same font file: the same style, the same renderer, the same positions. The host test the_glyphs_past_the_192_characters_keep_their_golden_hashes (src/library/modus/text_rendering) draws the 47 Greek letters of B612 for the face Interface and the 165 characters past the 192 of Paper Mono and Paper Mono SemiBold for the faces Cells, Cells_Without_Grid_Fit and Cells_Bold, at the sizes and positions that the demand cache held, and compares the hash of their boxes and words with the stored hash (section 14.5, the golden hash). The hashes come from the first build without the demand cache, whose rasterizer a host test of the build before compared with the demand cache, word for word. The host test a_text_of_a_face_draws_the_pixels_of_its_glyphs (src/library/modus/graphics) draws a text of the face Interface, and each of its glyphs of the face by hand at its third of a pixel, compares the pixels at each third of a pixel, and checks that one changed word of a glyph changes the pixels; a_cell_of_a_face_draws_its_glyph does the same for a cell at each scale, and checks that the ink of a box-drawing character of Paper Mono and of a Greek letter of B612 stays in its cell. The golden hashes prove the words of these glyphs.
13.7 Measures
Host: AMD Ryzen 7 5800X, one core (taskset), -o:speed, each time the least of 200 batches (host test private_glyph_measure, src/library/modus/vector_font; the ideographs with MODUS_MEASURE_DENSE_FONT naming WenQuanYi Micro Hei, a TrueType font of the host, as no font of resources/fonts has a dense script).
| One glyph drawn by a process | Scale 1 | Scale 2 | Scale 3 | Words at scale 1, mean and most |
|---|---|---|---|---|
| Latin of B612, placed | 16.2 µs | 32.4 µs | 40.2 µs | 83, 182 |
| Greek of B612, placed | 16.5 µs | 31.8 µs | 46.3 µs | 97, 135 |
| Latin of Paper Mono, in cells | 4.1 µs | 10.3 µs | 21.1 µs | 74, 104 |
| Box drawing of Paper Mono, in cells | 3.3 µs | 9.7 µs | 19.7 µs | 90, 128 |
| 500 ideographs, placed | 18.0 µs | 29.5 µs | 43.1 µs | 198, 224 |
| A working set, with 48 bytes of entry for each glyph | 300 glyphs | 3 000 glyphs | 10 000 glyphs |
|---|---|---|---|
| Latin of B612, scale 1 | 112 KiB | 1 117 KiB | 3 723 KiB |
| Ideographs, scale 1 | 247 KiB | 2 466 KiB | 8 222 KiB |
| Ideographs, scale 3 | 1 743 KiB | 17 430 KiB | 58 101 KiB |
| Measure | Value |
|---|---|
The private glyph cache, in each copy of text_rendering that draws a glyph | 1 MiB of words, 4 096 entries of 48 bytes, a Swiss table index of 340 groups (5 440 slots, 16 344 bytes) and the blocks, and about 150 KiB of render memory: about 1.4 MiB (354 pages), one memory object that the process takes from its budget at the frame after its first such glyph (section 14.4) |
The globals of each copy of text_rendering | about 25 KiB: the memory of one outline (13 KiB), which the measure needs too, a band of one row (11 KiB), and the state; a copy that only measures carries the outline and the state |
| The font outlines | the five subsets: about 282 KB in the boot image |
These measures are of the rasterizer that drew the glyph cache files that left the system (vector_font.glyph_render_placed, which the host test private_glyph_measure still measures): there a placed glyph costs about four times a glyph of cells, because glyph_render_placed clears and filters a work row of 64 pixels whatever the width of the glyph. The rasterizer of each process has a work row as wide as the glyph (section 14.3); its measures are in section 14.6.
13.8 What is left
A TrueType font for the CJK ideographs, with a cell of two columns; the shaping of complex scripts in the process: ROADMAP.md.
14. Text at any size
The package src/library/modus/text_rendering draws each glyph of a face at any text size, into the private glyph cache of the copy that draws: every glyph of the system, the 192 characters too. A draw record carries the text size of its text and of its text grid (The interface of the processes: Text); the elements of the desktop still give the sizes 16, 32 and 48. The intent of this design is Text rendering: one module for text at any size in the repository.
14.1 The text size
The text size is the height of the line of a face, in 1/64 of a pixel: a line of 16 pixels is the size 1 024, and the scales 1, 2 and 3 are the sizes 1 024, 2 048 and 3 072 (size_of_scale). A size from 256 (a line of 4 pixels) to 16 384 (a line of 256 pixels) is valid. size_check refuses 0 (Zero), a size below 256 (Too_Small) and a size past 16 384 (Too_Large); it never clamps. A refused size gives no advance and no glyph. The border of the draw record refuses the same sizes in a text and in a text grid (draw_record.TEXT_SIZE_MINIMUM, draw_record.TEXT_SIZE_LIMIT), and a constant check ties the two bounds.
A cell of a face of cells at a size is half the size wide, rounded to a whole pixel with a half up (cell_columns), and a line of the cells is two cells high: 7 by 14 at a size of 14, 8 by 16 at 16, 12 by 24 at 24. graphics.text_sized draws a text of the cells at any size, in the regular or the bold weight; with Spleen it draws each glyph at the largest whole scale whose line is not above the line of the cell, 1 under it, in the middle of the cell. The replacement glyph is the box of the body grown with the cell (graphics.character_replacement_sized), so at a whole scale it is the box of before.
14.2 The frame of a face
| Face | Its frame | At the size 1 024 |
|---|---|---|
| A face of cells (Paper Mono, Paper Mono SemiBold) | The advance of the font is half the line | 606 units are 8 pixels |
| A face of the interface (B612, B612 Bold) | The cap height of the font is 10/16 of the line | 1 500 units are 10 rows |
A length of the font at a size is units * size / (2 * units of a cell) in 1/64 of a pixel, rounded to the nearest integer, a half up (units_at_size): at the sizes of the glyph caches it is the advance of the glyph caches. A cell of a face of cells is half the line, rounded to whole pixels, a half up (cell_columns). The baseline puts the middle of the ink of the first font at the middle of the line (baseline_of).
14.3 The rasterizer
The exact area in integers of section 4, with the filter of five taps, the words 0xGGRRGGBB and the grid fit of section 2 at each size. Two changes from the rasterizer of the glyph caches, which change no word:
- The work row is as wide as the glyph. The points of the outline give the columns that the ink can touch, with the spread of the filter and one pixel more on each side. The box is computed in 64 bits from the placement. A glyph is refused as hostile when it is wider than 512 pixels, when a point is placed past 2^29 subunits from its origin, or when its columns pass an i16 from its origin, the bound of the left side of a glyph entry.
- The rows are drawn in bands of 8 rows. Each band adds the whole outline, moved up by whole rows, so the memory has a bound at any size.
The outline keeps the placement of the glyph caches; each move is added to the ends of each segment after the points are computed (vector_font.Accumulation, move_x and move_y), because the point between two points off the curve rounds toward zero and would round the other way at a negative coordinate.
A proportional glyph is at the nearest third of a pixel at each size: three positions. A glyph of cells is at a whole pixel, cut to its cell. The ink of a glyph is cut to its line.
14.4 The private glyph cache
| Bound | Value |
|---|---|
| The words | 262 144 words (1 MiB), in runs of 32 to 16 384 words that split and join by halves |
| The entries | 4 096, in a table of 8 192 places |
| The key | 64 bits: the face (4 bits), the font of the chain (4), the glyph index in that font (16), the text size (16), the position (2); a glyph index past 0xFFFF has no key and no glyph |
| The memory | The glyph memory: the cache and the render memory, about 1.4 MiB (354 pages, display.TEXT_MEMORY_PAGES), no global. The first glyph of a copy is drawn band by band through a band of one row (Glyph_Source.Banded); the next display.text_frame_begin takes one memory object of those pages from the budget of the process and gives it (text_rendering.memory_give). A refused reservation is not tried again: each glyph is then drawn band by band, and a process writes one line on its log. Each stated budget of a process that draws text holds 354 pages for each copy that draws: the drawing module, and the own copy of a process that draws by hand |
A new glyph that finds no room evicts the glyphs of the oldest frames. A glyph of the frame in progress is never evicted: when the glyphs of one frame fill the cache, each other new glyph of that frame is drawn into the render memory, blended, and not kept (Glyph_Source.Not_Kept). Its pixels are right; the frame costs more time. The first such frame of a copy in a process writes one line on the log of the process, at the start of the next frame (display.text_not_kept_tell, which interface.window_frame_begin and the terminal call). The line:
text_rendering: the glyphs of one frame fill the private glyph cache: <n> glyphs drawn and not kept
The copy in the drawing module counts its glyphs and writes no line: the parts of a line of the log hold the addresses of their texts, and a library module holds no table of addresses.
A glyph larger than 16 384 words (a glyph of 128 by 128 pixels) is never kept (Glyph_Source.Banded): the draw takes its rows band by band (glyph_bands, band_next) and blends each band.
14.5 The proof of the pixels
The golden hash. The host test the_192_characters_keep_their_golden_hashes (src/library/modus/text_rendering) draws the 192 characters of each face at the sizes that its glyph cache of the boot image held (1 024, 2 048 and 3 072; 1 024 for the bold weights), at each position (three for a face of the interface), computes the BLAKE3 hash of the box of each glyph (four numbers of 32 bits) and of its words, all in little endian, by their character index, and compares it with the hash stored in the table golden_hashes of the test: 21 rows. The hashes of the 192 characters come from the last build that had the glyph caches, whose test compared each word with the code that built them. A hash that differs fails with the face, the size and the hash found. The test the_glyphs_past_the_192_characters_keep_their_golden_hashes does the same for the characters past them (section 13.6). Each prints its lines, text_rendering: the golden hash of <Face> at the size <n>: <hash> and text_rendering: the golden hash of <Face> at the size <n>, past the 192 characters: <hash>. The tests build no glyph cache: these hashes are the proof that the pixels did not change. The host test a_golden_hash_refuses_and_sees_one_pixel checks the proof itself: a face that names no member, the face None, a size that the text rendering refuses and a size that no row names give no hash, and one changed pixel of the 192 characters of Cells at the size 1 024 gives another hash than the stored one.
The faces of the interface draw at three positions at each size: at 2 048 and 3 072 the caches of the boot image held one, so a text of the interface font at the scales 2 and 3 now stands at most 1/6 pixel from its place, not 1/2.
The host test the_measure_is_the_draw checks, for each face at six sizes, that the x of each placed glyph is the sum of the advances of the font file before it, and that the fit of a room is the start whose measure is that room.
14.6 Measures
Each one is a measure, never a test.
| Measure | Command |
|---|---|
| The raster of one glyph of each face at the lines of 16, 20, 24 and 32 pixels, the least of 200 | nix develop -c taskset -c 2 odin test src/library/modus/text_rendering -vet -collection:modus=src/library/modus -o:speed -define:MEASURE=true -define:ODIN_TEST_NAMES=text_rendering.the_raster_time_of_one_glyph |
| The glyphs of the frame that fills the cache | the same, with ODIN_TEST_NAMES=text_rendering.a_frame_larger_than_the_cache |
| The measure of 100 lines of B612 from the font file, the least of 200 | the same, with ODIN_TEST_NAMES=text_rendering.the_measure_time_of_a_hundred_lines |
One call of shape_text of the library module on a label, the open of the fonts of its face included, the least of 200 | nix develop -c taskset -c 2 odin test src/modules/libraries/text_rendering -vet -collection:modus=src/library/modus -o:speed -define:MEASURE=true -define:ODIN_TEST_NAMES=text_rendering_module.the_time_of_one_call |
The start of a window, from Process_Start to its first frame: the first frame draws each glyph of the window from its outline | nix develop -c modustool measure, then grep "compositor: measure: the start of the window" build/test_output_measure.txt; for interface_elements and settings, the same line in build/test_output.txt after nix develop -c modustool screenshots |
The draw table of processor_frame with a warm cache (one frame before the 21 counted draws each glyph) | nix develop -c modustool measure, then grep "processor_frame: measure: " build/test_output_measure.txt |
| The start of the machine: the hash check of each resource by the root service | grep "root: the resource" build/test_output.txt after nix develop -c modustool screenshots; the five glyph caches had a line each, the font outlines have one |
| One line of B612 drawn, its first draw (each glyph from its outline) and the least of 50 after it | grep "interface_font: one line of" build/test_output.txt after nix develop -c modustool screenshots |
The measures of time run only with -define:MEASURE=true: a normal run of the host tests skips them and prints no time.
14.7 The measure from the font file
Each number of a measure comes from the font file of the face, at the text size of the spacing (text_rendering.spacing_of(face, size)), never from a glyph cache:
- The advance of a glyph is the advance of the table
hmtxof its font, scaled to the frame of the face and rounded once to 1/64 of a pixel. A face of cells gives each character half the line. - The pair of two glyphs that follow each other is the pair of the table
kern(format 0) of their font, scaled and rounded the same way, when both glyphs come from one font of the chain of a proportional face. Two glyphs of two fonts, and a face of cells, have no pair. A spacing withwithout_pairsplaces a text with its advances alone. - The bounds hold at any size. An advance is kept from 0 to one line, and a pair within half a line on each side: the widest advance of the fonts of the system is 2 000 units of B612 against a line of 2 400, and the largest pair 200 units. A font that states more is hostile; its numbers are kept in these bounds, so the x of the last glyph of a text of 65 536 bytes at the largest size stays in an
i32. - The same numbers as the glyph caches. At the sizes of the scales 1, 2 and 3, the sizes that the glyph caches held, the host test
the_measure_of_the_font_file_is_the_measure_of_the_gridcompares each advance of the 192 characters and each pair of two of them, in B612 Regular and Bold, with the length that the arithmetic of the grid gives from the units of the same font file,units * 8 * scale * 64 / units of a cell, rounded once: the arithmetic that drew the tables of the glyph caches. No place of a text moves. - Past the 192 characters, a pair of a character of the glyph cache and one past it counts when both are in one font: a Greek letter of B612 beside a Latin letter of B612 takes the pair of the file, when the file has one.
The boot image holds no glyph cache: each glyph of the system comes from the private glyph cache of the process that draws it. The glyph cache file, its builder and the tests that take it as their reference are in ROADMAP.md.
