34#include "stb_truetype.h"
70 const uint8_t tag = engine->
tokens[start].
tag;
72 for (uint32_t i = start + 1U; i < limit; ++i) {
74 if (tok->
tag != tag) {
181 uint32_t i = start + 1U;
189 for (uint32_t j = i + 1U; j < tr_end; ++j) {
240 const stbtt_fontinfo* font,
255 if (base[i] == (uint8_t)
' ') {
258 if ((*cx > cell_x) && ((*cx + adv) <= cell_right)) {
265 uint32_t word_end = i;
267 while ((word_end < len) && (base[word_end] != (uint8_t)
' ')) {
271 if (((*cx + word_w) > cell_right) && (*cx > cell_x)) {
276 while (i < word_end) {
319 const stbtt_fontinfo* font,
327 const int32_t cell_right = cell_x + cell_w;
328 const uint16_t font_px = engine->
font_px;
332 for (uint32_t t = tstart; t < tend; ++t) {
335 internal_cell_text(engine, font, tok, cell_x, cell_right, font_px, color, &cx, &cy, &lines);
372 const stbtt_fontinfo* font,
382 uint32_t i = tr_start + 1U;
390 const int32_t cell_w = col_w - (2 * pad);
391 const uint32_t lines =
435 const stbtt_fontinfo* font,
444 const uint32_t glyphs_before = engine->
glyph_count;
446 int32_t row_h = (int32_t)row_lines * line_h;
454 row_h = (int32_t)row_lines * line_h;
462 const stbtt_fontinfo* font,
478 const int32_t col_w = content_w / (int32_t)cols;
480 uint32_t i = start + 1U;
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
Test-access surface for reflow internal helpers (MC/DC).
bool priv_reflow_layout_newline(reflow_t *engine, priv_cursor_t *cur, bool allow_justify)
Implementation of priv_reflow_layout_newline() – align, advance, page-break.
int32_t priv_reflow_layout_glyph_advance(const stbtt_fontinfo *font, uint16_t font_px, int32_t cp)
Implementation of priv_reflow_layout_glyph_advance() – scaled hmetrics.
bool priv_reflow_layout_push_glyph(reflow_t *engine, int32_t x, int32_t y, int32_t cp, uint16_t font_px, uint8_t style, uint32_t color, uint8_t link_id)
Implementation of priv_reflow_layout_push_glyph() – append + bounds check.
bool priv_reflow_layout_finish_page(reflow_t *engine, priv_cursor_t *cur)
Implementation of priv_reflow_layout_finish_page() – flush + reset cursor.
uint16_t priv_reflow_layout_line_height(uint16_t font_px)
Implementation of priv_reflow_layout_line_height() – scaled integer ratio.
Cross-TU shared declarations for the reflow layout engine.
@ k_priv_row_gap_px
Vertical gap between table rows.
@ k_priv_cell_pad_px
Left/right inset inside a table cell.
static uint32_t internal_layout_cell(reflow_t *engine, const stbtt_fontinfo *font, int32_t cell_x, int32_t cell_w, int32_t top_y, uint32_t color, uint32_t tstart, uint32_t tend)
Lay out one cell's text tokens within a fixed column box (left-flow).
static uint32_t internal_match_block_end(const reflow_t *engine, uint32_t start, uint32_t limit)
Find the block-end token matching the block-start at start.
static uint32_t internal_layout_row(reflow_t *engine, priv_cursor_t *cur, const stbtt_fontinfo *font, uint32_t tr_start, uint32_t table_end, int32_t col_w)
Lay out one table row, page-breaking before it if it would overflow.
static void internal_cell_text(reflow_t *engine, const stbtt_fontinfo *font, const reflow_token_t *tok, int32_t cell_x, int32_t cell_right, uint16_t font_px, uint32_t color, int32_t *cx, int32_t *cy, uint32_t *lines)
Flow one text token inside a cell box, wrapping at the column edge.
static uint32_t internal_table_columns(const reflow_t *engine, uint32_t start, uint32_t end)
Column count = the maximum number of cells in any row of the table.
static bool internal_is_cell_start(const reflow_t *engine, uint32_t i)
True iff token i opens a table cell (<td> or <th>).
static bool internal_is_row_start(const reflow_t *engine, uint32_t i)
True iff token i opens a table row (<tr>).
static uint32_t internal_row_cells(reflow_t *engine, const stbtt_fontinfo *font, uint32_t tr_start, uint32_t tr_end, int32_t col_w, int32_t row_y)
Lay out every cell of one row at row_y; return the row's line count.
ra8_err_t priv_reflow_layout_table(reflow_t *engine, priv_cursor_t *cur, const stbtt_fontinfo *font, uint32_t start, uint32_t *out_next)
Lay out a <table> token range as an equal-column grid.
@ k_reflow_tag_th
Table header cell.
@ k_reflow_tag_td
Table cell.
@ k_reflow_tag_tr
Table row.
@ k_reflow_paragraph_gap_px
Vertical gap after a block.
@ k_reflow_margin_px
Page edge inset, pixels.
@ k_reflow_align_left
Left (default, ragged right).
@ k_reflow_tok_block_end
Close of a block-flow element.
@ k_reflow_tok_text
Text run (slice into pool).
@ k_reflow_tok_block_start
Open of a block-flow element.
Mutable state carried through the layout loop.
uint8_t line_has_content
1 once any glyph landed on this line.
int32_t line_top
Pixel row of the current line's top.
int32_t x
Pixel column for next glyph.
uint32_t line_first_glyph
First glyph index of the active line.
int32_t y
Pixel row baseline for next glyph.
uint8_t align
Active block alignment (reflow_align_t).
uint16_t indent_px
Active left indent (li, blockquote).
Reflow / pagination engine state.
uint32_t glyph_count
Glyphs used.
uint8_t text_pool[k_reflow_text_pool_bytes]
Text bytes.
uint32_t token_count
Tokens used.
uint16_t font_px
Body font size in pixels.
uint16_t viewport_w
Viewport width, pixels.
reflow_token_t tokens[k_reflow_max_tokens]
Parsed tokens.
uint16_t viewport_h
Viewport height, pixels.
uint32_t body_color
Body text colour (0xRRGGBB).
One parsed token in the engine's token stream.
uint32_t text_off
Byte offset into the text pool.
uint32_t text_len
Byte length within the text pool.
uint8_t kind
reflow_token_kind_t.
uint8_t tag
reflow_html_tag_t (0 if N/A).