Repository navigation
This update replaces fontlibc rendering with a renderer that uses Latin Modern fonts and four coverage levels
It also improves math layout, adds text justification, and corrects viewport cache errors
Applications must use the new font files and configuration fields
The previous font files are not compatible with this renderer
Breaking Changes
- Fonts: Replaced the fontlibc font format with TXF3
- The AppVar names remain TeXFonts and TeXScrpt, but their contents have changed
- Replace both font AppVars when you update an application
- Do not use the previous fontlibc packs with the new renderer
- The main font has a nominal size of 16 pixels, and the script font changes from 12 pixels to 11 pixels
- Fonts: Changed the font loading API
- Removed tex_fonts_load() and TexFontPtr
- Use tex_font_open() to open each font AppVar
- Use tex_font_init() to create a font view from an existing TXF3 payload
- Both functions return false if validation fails
- Font views do not own their data and have no separate close or free operation
- Configuration: Replaced font names and separate foreground/background fields
- Removed TeX_Config.font_pack, color_fg, and color_bg
- Supply validated font views through font_main and font_script
- Supply four palette indices through palette
- The palette order is background, one third ink, two thirds ink, and full ink
TeX_Config cfg = { .palette = { 255, 254, 253, 0 }, .font_main = font_main, .font_script = font_script, };
- Rendering: Removed tex_draw_set_fonts()
- Measurement and drawing now use the fonts in each layout's configuration
- Remove calls to tex_draw_set_fonts()
- Remove fontlibc color and transparency setup that only served libtexce
- Rendering: Changed palette requirements
- All four palette indices must be different
- The renderer uses each pixel's index to identify its coverage level when strokes overlap
- tex_draw() calculates the two intermediate colors from the background and foreground colors
- Clear the drawing area to palette[0] before drawing
- Do not change the intermediate colors while pixels that use them remain visible
- Duplicate palette indices cause TEX_ERR_INPUT
- Ownership: Font data must remain valid for the layout's lifetime
- The layout copies font descriptors, but it does not copy font data
- Keep the source text and font data unchanged at the same addresses until tex_free()
- Destroy affected layouts before an operation that can move or delete their font AppVars
- Open the fonts again after such an operation
- API: Changed the tex_format() declaration
TeX_Layout* tex_format( const char* input, int width, const TeX_Config* config);
- Source text is read only, so string literals are valid inputs
- Applications no longer need a writable source copy solely for tex_format()
- Update function pointer declarations that use the previous signature
- Check tex_get_last_error() after a successful allocation, because a non null layout can contain an error
- Parser: Removed acceptance of some incomplete expressions
- Unclosed groups and unexpected closing braces now cause TEX_ERR_PARSE
- Incomplete required arguments no longer produce nodes with missing children
- Examples include \frac{x}, \binom{n}, \hat, and \overbrace{x}^
- Supply each required argument
- Use an explicit empty group, such as {}, when an empty argument is intentional
- Empty groups, empty matrix cells, and omitted optional root indices remain valid
- Internal API: Changed parser and measurement interfaces
- tex_parse_math() now requires a layout error state and an explicit display style argument
- Pass false for inline math or true for display math
- Removed the separate N_FUNC_LIM node representation
- Internal node structures and font metric interfaces have changed
- Update code that directly uses internal headers
- Build: Changed font dependencies and host requirements
- CE applications now require fileioc for font AppVar access
- Remove fontlibc from the application's dependencies if no other code uses it
- Removed TEX_USE_FONTLIB from the demo and autotest build recipes
- The root CMake project now requires CMake 3.21 and a compiler with C23 support
- Font generation: Replaced the previous command interface
- Removed the export, build, and all subcommands and the --keep-bin option
- Install Pillow and fontTools on the build host
- Use python3 tools/process_fonts.py to generate both font AppVars
- Use --outdir PATH to select another output directory
- Relative output paths now refer to the current working directory
- PortCE: Changed the submodule source and included upstream interfaces
- The submodule now uses Sightem/PortCE, with master as its configured branch
- Synchronize the submodule URL before you update an existing checkout
- Update to the recorded submodule commit
- Code that directly uses removed PortCE memory names must use the current memory access interfaces
- The previous PortCE_Keybinds.h header is no longer available
- Select CMAKE_BUILD_TYPE=Release explicitly when a native Release build is required
Other Changes
Fonts and Visual Quality
- Fonts: Added Latin Modern Roman and Latin Modern Math
- Ordinary text, digits, and named math functions use upright glyphs
- Latin math variables use italic glyphs
- Math expressions use a mathematical minus glyph instead of the text hyphen
- Existing custom symbol byte codes remain unchanged
- Fonts: Added four level glyph coverage
- Glyph bitmaps store two bits per pixel
- The intermediate coverage levels produce smoother glyph edges
- Glyph records include advance width, ink dimensions, baseline offsets, italic correction, and accent attachment positions
- Fonts: Added font derived math metrics
- The generator extracts OpenType MATH constants and stores them in the AppVars
- Layout uses these constants instead of the previous fixed font spacing assumptions
- The calculator does not need an OpenType parser
- Operators: Added separate display glyphs for integrals, sums, and products
- Display math uses larger outlines from the math font
- The generator selects suitable font variants instead of scaling the inline bitmap
- Assets: Added the original font sources and license files
- Added the Latin Modern Roman and Math OTF files under tools/fonts/
- Added the GUST Font License, LPPL text, and upstream font documentation
- These OTF files are inputs to the host generator, and applications do not load them on the calculator
Math Layout
- Spacing: Added contextual spacing between math atoms
- Spacing now depends on the adjacent atom types
- Binary operators, relations, named operators, punctuation, and delimiters receive different spacing
- Unary signs do not receive binary operator spacing
- Script style omits the applicable automatic spaces
- Spacing: Changed explicit math spaces to mu units
- One mu is one eighteenth of the font's em size
- Positive and negative spaces use the same measurement and drawing calculation
- The calculation accumulates spacing before rounding to pixels
- Fractions: Replaced fixed offsets with font metrics
- Rule thickness, vertical shifts, and minimum gaps now come from the font
- Numerators and denominators are centered over the same measured bar width
- Display fractions use display specific spacing and larger child styles
- Scripts: Improved superscript and subscript placement
- Placement accounts for glyph ink bounds and italic correction
- Combined superscripts and subscripts maintain the required vertical separation
- Cramped style changes superscript placement inside applicable expressions
- Limits: Unified limit placement with ordinary script layout
- Display sums, products, and \lim place their limits above and below the operator
- Inline forms place their limits beside the operator
- Integrals keep side limits in both styles
- Integral limit placement accounts for the glyph's slant
- Radicals: Corrected the root sign and overbar geometry
- The root sign now extends around tall or deep contents
- Rule thickness, overbar clearance, index position, and extra ascent use font metrics
- Indexed roots account for the index's measured dimensions
- Accents: Improved placement over individual glyphs
- Applicable accents use the font's top accent attachment position
- Single item groups preserve this attachment behavior
- Tildes use their actual bitmap dimensions and baseline offsets
- Delimiters: Corrected clearance around enclosed content
- Delimiters preserve the selected font's side bearings
- Parentheses no longer use the previous overlap adjustment into their contents
- Measurement includes the bottom stroke pixel
- Matrices use the same delimiter geometry
- Brace labels: Corrected measurement order
- The parser creates labels before their parent decoration node
- Measurement now includes labels that are wider or taller than the enclosed content
- Text lines: Use actual glyph ink bounds
- Lines expand when glyph ink exceeds the font's normal ascent or descent
- Normal font metrics remain the minimum line bounds
- Horizontal placement continues to use glyph advances
Rendering
- Strokes: Added antialiasing to procedural math shapes
- Radicals, delimiters, accents, braces, and contour integral outlines use the same coverage palette as text
- Overlapping strokes retain the higher coverage level
- Clipping: Corrected partially visible glyph rendering
- Glyphs retain their visible pixels when they cross a viewport edge
- Glyphs and procedural strokes respect the active graphx clip region on both axes
- Drawing uses the selected graphx buffer
- Colors: Removed dependence on unrelated graphx drawing color state
- Math strokes use the configured coverage palette
- The renderer changes only the two intermediate palette entries
Text Layout and Scrolling
- Layout: Added optional text justification
- Set TeX_Config.justify to true to expand word spaces on automatically wrapped lines
- Space additions differ by no more than one pixel
- Final lines, explicit newlines, and lines immediately before display equations remain unexpanded
- Lines without word spaces remain unexpanded
- Justification does not change spacing inside math expressions
- Justification does not add hyphenation
- Layout: Unified document measurement and viewport reconstruction
- Both operations now use the same line layout iterator
- This keeps line breaks, baselines, and display math placement consistent
- Checkpoints: Corrected replay after a line wrap
- A checkpoint preserves the original source position of a pending token
- Replay no longer skips the first token on the next line
- This also applies to text with escape sequences
- Cache: Corrected reuse for short documents and final pages
- Cache comparisons use document bounds rather than an interval beyond the document end
- Empty documents can also reuse their cached result
- Cache: Record only the interval that reconstruction completed
- An incomplete window no longer appears complete
- Insufficient node or line capacity reports TEX_ERR_OOM
- Lifetime: Remove cache associations when layouts or renderers are destroyed
- A renderer no longer retains an association with a freed layout
- The application can destroy the renderer and layout in either order
- Fonts: Preserve each layout's font selection
- Drawing activates the font pair stored in that layout
- Operations on another layout no longer leave the wrong fonts active for the next draw
Optimizations and Internal Simplification
- Fonts: Read prepared font data without a decoded font cache
- On the calculator, archived font data remains in flash
- Libtexce reads glyph pixels and metrics directly from that data
- The larger font files do not require a matching decoded bitmap allocation
- Layout: Reuse a measured token after a line wrap
- The shared iterator keeps the pending token instead of reading and parsing it again
- Text: Removed unnecessary writable source copies
- The text demo and autotest harness pass their existing source strings directly to tex_format()
- Spaces: Removed one character string allocations for retained word gaps
- The renderer now represents these gaps with space nodes
- Justification adjusts those nodes without additional allocations
- Lines: Removed repeated ascent scans during drawing
- Each retained line stores its measured ascent
- Drawing uses that value directly
- Checkpoints: Removed repeated searches for the source end
- Formatting records the source end once
- Viewport reconstruction reuses that address
- Matrices: Removed repeated list searches for individual cells
- Drawing now moves forward through the cell list once
- Math: Reuse reserved glyph nodes for ordinary ASCII math atoms
- These expressions no longer need copied text run strings
- This change does not imply lower total memory use for every expression
- Geometry: Removed separate measurement and drawing formulas
- Scripts, fractions, radicals, delimiters, and matrices use shared geometry calculations
- Math spacing uses one cursor implementation in both passes
- Checks: Removed validation of states that callers already exclude
- Removed repeated checks from validated font accessors
- Removed null substitutes for required math children
- Removed impossible list tail recovery paths
- Allocation failures, malformed external payloads, and genuinely optional children retain their checks
- Maintenance: Removed obsolete state and duplicate code
- Removed the separate \lim rendering path
- Removed unused decoration variants and error macros
- Removed redundant renderer initialization and duplicate CE linker setup
- Expanded dense code and clarified local names without adding replacement layers
Build and Font Tools
- CEdev: Added a binutils based build path
- The helper selects this path when the required toolchain layout is present
- The legacy FASMG path remains available
- CEDEV_USE_BINUTILS permits explicit selection
- CEdev: Added assembly, linking, and packaging support for the new path
- Supported inputs include C, C++, .s, and preprocessed .S files
- The path supports optional LLVM LTO, LibLoad processing, CRT generation, and .8xp packaging
- Supported legacy BSS, stack, and load address settings receive equivalent linker symbols
- CEdev: Added CEDEV_PREFER_OS_CRT for the binutils path
- Existing debug, compression, archive, and library options also apply to this path
- CEDEV_DEBUG_CONSOLE controls its debug compiler options independently of CMAKE_BUILD_TYPE
- Fonts: Replaced guided bitmap extraction with direct font generation
- The generator reads the bundled Latin Modern sources
- It calculates glyph bitmaps and math metrics on the build host
- It writes archived AppVars directly
- Font generation no longer requires convfont or convbin
- CE program packaging still uses convbin
- Assets: Removed obsolete font generation files
- Removed the guided main and script bitmaps
- Removed the generated convfont text descriptors
- Autotests: Corrected generator dependencies
- Changes to either embedded template now cause the case generator to rebuild