textGenerated
Category: Packages · Manifest: use "kernels/";
Text.
Description
Section titled “Description”Text: glyph rows laid out and drawn from a program’s font atlas, text
decoded into rows of letters, the wide glyphs a project’s words use drawn into an
atlas, numbers written with their decimals, a template’s holes filled
with numbers, and text written to a file through an output to files.
Layer: Interaction. Uses: parallel.
use "text.entpkg";Kernels
Section titled “Kernels”kernels/atlas.ent— The wide glyphs a project’s words use (Chinese, Japanese) drawn into the atlas the ui package’s letters read (ui.letters): a font node’s glyphs at any side and density (text.face_atlas, its ascent from the font’s metrics), or a ten-pixel font’s asentelechy importreads them (text.glyph_atlas). Kernels:text.glyph_atlas@1,text.face_atlas@1,text.glyph_codes@1,text.unlettered@1.kernels/glyph.ent— Text as rows, drawn by a Kernel, with no primitive. Kernels:text.layout@1,text.digits@1,text.draw@1,text.label@1.kernels/ink.ent— Text drawn by a Kernel’s own code, pixel by pixel.kernels/number.ent— A number written with decimals: how many characters it takes and each one’s code (number_width,number_code).kernels/letters.ent— Letters. Kernels:text.no_codes@1,text.letters@1,text.rows@1,text.starts@1,text.lettered@1,text.either@1.kernels/wanted.ent— The wide characters a text uses, each once, in order of code: the codes a font node reads. Kernels:text.char_codes@1,text.first_codes@1,text.code_list@1.kernels/template.ent— A template’s holes$0to$9filled with the values they name. Kernels:text.template_widths@1,text.template_filled@1.kernels/writing.ent— The operation an outputto filestakes to write a text at a path. Kernels:text.writing@1.
Graph presets
Section titled “Graph presets”graphs/decode.esn— A text’s rows as letters,widthcells a row.graphs/face.esn— A font’s glyphs as the letters’ grid,sidetexels square atdensitypixels a texel (a denser glyph stands as large, drawn finer and read blended), and the codes the atlas holds: a text’s font is a font node’s path, a side and a density.graphs/letters.esn— The letters’ grid (ui.letters).graphs/wanted.esn— The wide characters a text uses, for a font node.graphs/template.esn— A template filled and written: a world writing its own law, a report, a save.
tests/ holds scenes and their replays, run on every backend:
face.replay, glyphs.replay, rows.replay, template.replay, wide.replay, write.replay. Every
Kernel of the package is reached by one of them.
Used by the collapse, cube-puzzle, level, sound, spells, text, ui, voxel examples.
Kernels
Section titled “Kernels”| Kernel | Mode | Brief |
|---|---|---|
text.char_codes@1 |
map | The code of the character beginning at each byte of a UTF-8 text when it is past ASCII; 0 at an ASCII byte and a character’s following bytes. |
text.code_list@1 |
map | The codes kept, in order: the count first runs’ codes, 0 past them. A node sets domain = max(value(count), 1). |
text.digits@1 |
map | The first value’s magnitude, rounded, as places digit codes, most significant first, leading zeros blank; a node sets domain = places;. |
text.draw@1 |
map | The glyphs painted over under in color. |
text.either@1 |
map | One of two texts’ letters, element by element: second while the chosen number is when, else first. Two languages are one either; more, eithers one after another, each its own when. |
text.face_atlas@1 |
map | The atlas of a font node’s glyphs, side texels square at density pixels a texel, each glyph’s em square centered between the font’s ascent and descent: the baseline as far below a glyph’s top as the ascent where the two are an em apart, and the whole line kept in the square where they are farther. graphs/face.esn places it, sized. |
text.first_codes@1 |
map | Whether the code at k of the codes in order begins a run: a code past ASCII unlike the one before it. |
text.glyph_atlas@1 |
map | The atlas of a ten-pixel font’s imported glyphs, nine a row. A node sets domain = vec2(96.0, 10.0 * floor((count(glyphs) + 8) / 9)). |
text.glyph_codes@1 |
map | The codes the atlas holds, a slot each, in its order. |
text.label@1 |
map | A caption and a number as one row of codes for text.layout: the caption’s codes, a space, and value index of values with places digits before the point and decimals after (none, and no point, at zero), leading zeros blank; a node sets domain = size(caption) + places + decimals + 2; (one less with no decimals). |
text.layout@1 |
map | Codes laid out from origin, advance texels apart at scale; with wrap above zero, that many per line, lines 8 texels apart. |
text.lettered@1 |
map | A text’s rows as letters, width cells a row: its characters a cell each, a wide one the cells its glyphs’ side needs (wide_cells), those after the first -1; one that would cross the row’s end, and the row past its end, spaces. The text is UTF-8 bytes, or codes with utf8 = 0 (text "...", whose rows are one, starts a single 0); its wide letters those of the atlas’s codes. A node sets domain = width * count(starts). |
text.letters@1 |
map | The letters’ grid: the bitmap font, the side and density of the atlas’s glyphs, and the atlas, a grid 96 texels across the scene draws. A node sets domain = vec2(96.0, 49.0) + size(atlas) * vec2(0.0, 1.0) (graphs/letters.esn). |
text.no_codes@1 |
map | The atlas for no wide letters: its codes, none of them a character. |
text.rows@1 |
map | How many rows a text has: its lines, each ended by a new line, and a last one not ended. A text is UTF-8 bytes (bytes "file.txt"). |
text.starts@1 |
map | Where each row of a text begins: after as many new lines as its number. A node sets domain = value(rows, 0) from ui.text_rows. |
text.template_filled@1 |
map | The template filled: each hole $d written as values[d] to places decimals, every other character as it is. ends are the widths laid end to end, total their sum (compact.entries); a node sets domain = value(total). |
text.template_widths@1 |
map | How many characters each of a template’s characters is written as once filled: a hole’s $ the number it holds, the digit after it none, any other character itself. Laid end to end by compact.ends. |
text.unlettered@1 |
map | How many cells of the screen’s words show a ? for a character the atlas lacks; none, while every word is lettered (a project’s check). |
text.writing@1 |
map | The operation an output to files takes to write text at path under its directory, both rows of character codes; a node sets domain = 4 + count(path) + count(text). |
Methods
Section titled “Methods”| Function | Brief |
|---|---|
atlas_side() -> Int |
|
glyph_ascent() -> Float |
|
atlas_columns() -> Int |
|
atlas_ink(glyphs: Rows<Letterform>, outlines: Rows<Vec4>, p: IVec2, n: Int, ascent: Float) -> Float |
Texel p of an atlas of glyphs n pixels square, their baseline ascent pixels below a glyph’s top: ink where the glyph’s outline winds round the texel’s middle. |
text_ink(glyphs: Text, font: Atlas, px: Vec2) -> Float |
|
glyph_ink(font: Atlas, code: Int, x: Int, y: Int) -> Bool |
Whether texel x, y of the glyph of code is ink; a code the font lacks is a ?. |
code_ink(font: Atlas, code: Int, px: IVec2, origin: IVec2, scale: Int) -> Bool |
Whether pixel px is ink of code, its cell’s top left at origin. |
codes_ink(font: Atlas, codes: Codes, first: Int, length: Int, px: IVec2, origin: IVec2, scale: Int) -> Bool |
Whether pixel px is ink of length codes of codes from first, side by side from origin: a word of a text input, say. |
trimmed_length(codes: Codes, first: Int, length: Int) -> Int |
How many of length codes from first there are before the trailing spaces: a word’s length in a table of fixed-width words. |
digit_count(n: Int) -> Int |
How many characters n is written with: its digits, and a - first when it is below zero. |
digit_code(n: Int, i: Int) -> Int |
The code of character i of n written out, most significant first; a space past either end. |
number_ink(font: Atlas, n: Int, px: IVec2, origin: IVec2, scale: Int) -> Bool |
Whether pixel px is ink of n written out from origin. |
letters_atlas_top() -> Int |
|
glyph_side(letters: Grid<Float>) -> Float |
The side of the atlas’s glyphs, as the grid holds it. |
glyph_density(letters: Grid<Float>) -> Float |
The atlas’s pixels a texel of a glyph, as the grid holds it: 1 or more. |
wide_cells(side: Int) -> Int |
How many cells a wide letter takes, its glyphs side pixels: two, or as many more as hold the side. |
atlas_slot(code: Int, codes: Rows<Int>) -> Int |
The slot of a code in the atlas’s codes, in order of code, by bisection; -1 for one it does not hold. |
letter_cover(letters: Grid<Float>, code: Int, local: Vec2) -> Float |
The cover of a letter at local, in texels from its first cell’s top left: of the bitmap font in 0..6 by 0..8, of a wide one in its glyph’s square over the middle of its cells (0..12 by 0..8 for two). |
letter_of(code: Int, codes: Rows<Int>) -> Int |
The letter a character’s code is: itself if printable ASCII, a space for another below 128, 256 and its slot if the atlas holds it, else a ?. |
wide_letter(letter: Int) -> Bool |
Whether a letter is wide, over two cells or more. |
char_at(text: Rows<Int>, i: Int, utf8: Bool) -> IVec2 |
A character of a text at i: its code and how many of the text’s elements it takes, from UTF-8 bytes (utf8) or from codes one an element (text "..."). |
decimal_unit(places: Int) -> Int |
10 to the power places, places from 0 to 9. |
scaled_of(v: Float, places: Int) -> Int |
v scaled to places decimals and rounded, its magnitude: what its digits are read from, held below 2^31. |
number_width(v: Float, places: Int) -> Int |
How many characters v is written with to places decimals: a - when it is below zero and rounds to something, the whole part, and a . and the decimals when there are any. |
number_code(v: Float, places: Int, i: Int) -> Int |
The code of character i of v written to places decimals. |
hole_at(template: Rows<Int>, i: Int) -> Int |
The hole a template’s character i opens, $ followed by a digit: the digit, else -1. |
Types and structs
Section titled “Types and structs”| Name | Syntax |
|---|---|
Letterform |
struct Letterform { code: Int; advance: Int; first: Int; count: Int; lo: Vec2; hi: Vec2; } |
FontMetrics |
struct FontMetrics { units: Int; ascent: Float; descent: Float; gap: Float; } |
Glyph |
struct Glyph { code: Int; origin: Vec2; scale: Float; } |
Text |
type Text = Rows<Glyph>; |
Codes |
type Codes = Rows<Int>; |
Atlas |
type Atlas = Grid<Float>; |
Ink |
struct Ink { next: Int; cover: Float; } |
Graph presets
Section titled “Graph presets”| Name | Interface | Description |
|---|---|---|
decode |
input text: Rows<Int>input codes: Rows<Int>param width: Int = 12param utf8: Int = 1param side: Int = 10output letters <- cells.result |
A text’s rows as letters, width cells a row: its rows counted, where each begins, and each cell’s letter (kernels/letters.ent). The text is UTF-8 bytes (bytes "file.txt"), a row a line, or codes with utf8 = 0 (text "..."); its wide letters those of the atlas’s codes (ui.no_codes for none), each over the cells its glyphs’ side needs (two to 12 pixels, three to 18). node words: graph “text.entpkg/graphs/decode.esn” { text <- words; codes <- none.result; width = 16; } |
face |
input font: Grid<Float>input glyphs: Rows<Letterform>input outlines: Rows<Vec4>input metrics: Rows<FontMetrics>param side: Int = 10param density: Int = 1output letters <- grid.lettersoutput codes <- codes.result |
A font’s glyphs as the letters’ grid (ui.letters): a font node’s glyphs drawn side texels square into the atlas (text.face_atlas), density pixels a texel, under the bitmap font, and the codes the atlas holds, for decode.esn. A glyph stands as large at any density; a denser one is drawn finer and read blended, its edges smooth. A text’s font is its path and its side: node wanted: graph “text.entpkg/graphs/wanted.esn” { text <- words; } node type: font “fonts/x.ttf” { codes <- wanted.codes; } node letters: graph “text.entpkg/graphs/face.esn” { font <- pixels; glyphs <- type.glyphs; outlines <- type.outlines; metrics <- type.metrics; side = 12; } node cells: graph “text.entpkg/graphs/decode.esn” { text <- words; codes <- letters.codes; width = 32; } |
letters |
input font: Grid<Float>input atlas: Grid<Float>param side: Int = 10param density: Int = 1output letters <- grid.result |
The letters’ grid (ui.letters): the widgets package’s bitmap font, then the side of the atlas’s glyphs in texels and their density, then the atlas, a grid 96 pixels across that a scene draws, its glyphs side times density pixels square in order of the codes it gives graphs/text.esn. node letters: graph “text.entpkg/graphs/letters.esn” { font <- font; atlas <- glyphs.result; side = 10; } |
template |
input template: Rows<Int>input values: Rows<Float>input path: Rows<Int>param places: Int = 3output text <- text.resultoutput writing <- writing.result |
A template filled and written: its holes $0 to $9 filled with values, to places decimals, and the operation an output to files takes to write it at path under its directory (a world writing its own law, a report, a save): input template: Rows<Int> = bytes “templates/rule.tmpl”; input path: Rows<Int> = text “rule.ent”; node law: graph “text.entpkg/graphs/template.esn” { template <- template; values <- tuned.result; path <- path; } output laws <- law.writing to files “laws/”; text is the law as filled, for a scene to show or check. |
wanted |
input text: Rows<Int>output codes <- list.result |
The wide characters a UTF-8 text uses (bytes "words.txt"), each once, in order of code: the codes a font node reads. Place it with node wanted: graph “text.entpkg/graphs/wanted.esn” { text <- words; } node type: font “fonts/x.ttf” { codes <- wanted.codes; } |
Kernel descriptions
Section titled “Kernel descriptions”text.char_codes@1
Section titled “text.char_codes@1”The code of the character beginning at each byte of a UTF-8 text when it is past ASCII; 0 at an ASCII byte and a character’s following bytes.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | text: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
text.code_list@1
Section titled “text.code_list@1”The codes kept, in order: the count first runs’ codes, 0 past them. A node sets domain = max(value(count), 1).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | codes: Rows<Int>, order: Rows<Int>, kept: Rows<Int>, count: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
text.digits@1
Section titled “text.digits@1”The first value’s magnitude, rounded, as places digit codes, most significant first, leading zeros blank; a node sets domain = places;.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | values: Rows<Float> |
| Params | places: Int = 3 |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/glyph.ent |
text.draw@1
Section titled “text.draw@1”The glyphs painted over under in color.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | under: Image, glyphs: Rows<Glyph>, font: Grid<Float> |
| Params | color: Vec3 = [1.0, 1.0, 1.0] |
| Outputs | result: Image |
| Source | packages/text.entpkg/kernels/glyph.ent |
text.either@1
Section titled “text.either@1”One of two texts’ letters, element by element: second while the chosen number is when, else first. Two languages are one either; more, eithers one after another, each its own when.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | first: Rows<Int>, second: Rows<Int>, chosen: Rows<Int> |
| Params | when: Int = 1 |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/letters.ent |
text.face_atlas@1
Section titled “text.face_atlas@1”The atlas of a font node’s glyphs, side texels square at density pixels a texel, each glyph’s em square centered between the font’s ascent and descent: the baseline as far below a glyph’s top as the ascent where the two are an em apart, and the whole line kept in the square where they are farther. graphs/face.esn places it, sized.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | glyphs: Rows<Letterform>, outlines: Rows<Vec4>, metrics: Rows<FontMetrics> |
| Params | side: Int = 10, density: Int = 1 |
| Outputs | result: Grid<Float> |
| Source | packages/text.entpkg/kernels/atlas.ent |
text.first_codes@1
Section titled “text.first_codes@1”Whether the code at k of the codes in order begins a run: a code past ASCII unlike the one before it.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | codes: Rows<Int>, order: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
text.glyph_atlas@1
Section titled “text.glyph_atlas@1”The atlas of a ten-pixel font’s imported glyphs, nine a row. A node sets domain = vec2(96.0, 10.0 * floor((count(glyphs) + 8) / 9)).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | glyphs: Rows<Letterform>, outlines: Rows<Vec4> |
| Params | — |
| Outputs | result: Grid<Float> |
| Source | packages/text.entpkg/kernels/atlas.ent |
text.glyph_codes@1
Section titled “text.glyph_codes@1”The codes the atlas holds, a slot each, in its order.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | glyphs: Rows<Letterform> |
| Params | — |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/atlas.ent |
text.label@1
Section titled “text.label@1”A caption and a number as one row of codes for text.layout: the caption’s codes, a space, and value index of values with places digits before the point and decimals after (none, and no point, at zero), leading zeros blank; a node sets domain = size(caption) + places + decimals + 2; (one less with no decimals).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | caption: Rows<Int>, values: Rows<Float> |
| Params | index: Int = 0, places: Int = 2, decimals: Int = 0 |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/glyph.ent |
text.layout@1
Section titled “text.layout@1”Codes laid out from origin, advance texels apart at scale; with wrap above zero, that many per line, lines 8 texels apart.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | codes: Rows<Int> |
| Params | origin: Vec2 = [0.0, 0.0], scale: Float = 1.0, advance: Float = 6.0, wrap: Int = 0 |
| Outputs | result: Rows<Glyph> |
| Source | packages/text.entpkg/kernels/glyph.ent |
text.lettered@1
Section titled “text.lettered@1”A text’s rows as letters, width cells a row: its characters a cell each, a wide one the cells its glyphs’ side needs (wide_cells), those after the first -1; one that would cross the row’s end, and the row past its end, spaces. The text is UTF-8 bytes, or codes with utf8 = 0 (text "...", whose rows are one, starts a single 0); its wide letters those of the atlas’s codes. A node sets domain = width * count(starts).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | text: Rows<Int>, starts: Rows<Int>, codes: Rows<Int> |
| Params | width: Int = 12, utf8: Int = 1, side: Int = 10 |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/letters.ent |
text.letters@1
Section titled “text.letters@1”The letters’ grid: the bitmap font, the side and density of the atlas’s glyphs, and the atlas, a grid 96 texels across the scene draws. A node sets domain = vec2(96.0, 49.0) + size(atlas) * vec2(0.0, 1.0) (graphs/letters.esn).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | font: Grid<Float>, atlas: Grid<Float> |
| Params | side: Int = 10, density: Int = 1 |
| Outputs | result: Grid<Float> |
| Source | packages/text.entpkg/kernels/letters.ent |
text.no_codes@1
Section titled “text.no_codes@1”The atlas for no wide letters: its codes, none of them a character.
| Mode | map |
| Requires | field.write |
| Inputs | — |
| Params | — |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/letters.ent |
text.rows@1
Section titled “text.rows@1”How many rows a text has: its lines, each ended by a new line, and a last one not ended. A text is UTF-8 bytes (bytes "file.txt").
| Mode | map |
| Requires | field.read, field.write |
| Inputs | text: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/letters.ent |
text.starts@1
Section titled “text.starts@1”Where each row of a text begins: after as many new lines as its number. A node sets domain = value(rows, 0) from ui.text_rows.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | text: Rows<Int>, rows: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/letters.ent |
text.template_filled@1
Section titled “text.template_filled@1”The template filled: each hole $d written as values[d] to places decimals, every other character as it is. ends are the widths laid end to end, total their sum (compact.entries); a node sets domain = value(total).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | template: Rows<Int>, values: Rows<Float>, ends: Rows<Int>, total: Rows<Int> |
| Params | places: Int = 3 |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/template.ent |
text.template_widths@1
Section titled “text.template_widths@1”How many characters each of a template’s characters is written as once filled: a hole’s $ the number it holds, the digit after it none, any other character itself. Laid end to end by compact.ends.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | template: Rows<Int>, values: Rows<Float> |
| Params | places: Int = 3 |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/template.ent |
text.unlettered@1
Section titled “text.unlettered@1”How many cells of the screen’s words show a ? for a character the atlas lacks; none, while every word is lettered (a project’s check).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | letters: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
| Source | packages/text.entpkg/kernels/atlas.ent |
text.writing@1
Section titled “text.writing@1”The operation an output to files takes to write text at path under its directory, both rows of character codes; a node sets domain = 4 + count(path) + count(text).
| Mode | map |
| Requires | field.read, field.write |
| Inputs | path: Rows<Int>, text: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
face.replay, glyphs.replay, rows.replay, template.replay, wide.replay, write.replay

