ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
reflow_layout_internal.h
Go to the documentation of this file.
1
26
27#pragma once
28
29#include <stddef.h>
30#include <stdint.h>
31
32#include "ra8_attributes.h"
33#include "ra8_err.h"
34#include "reflow.h"
35#include "reflow_internal.h"
36#include "stb_truetype.h"
37
38/* ===========================================================================
39 * Internal sizing constants (no magic numbers).
40 * ===========================================================================
41 */
42
55
56/* ===========================================================================
57 * Layout cursor
58 * ===========================================================================
59 */
60
65typedef struct {
66 int32_t x;
67 int32_t y;
68 int32_t line_top;
69 uint16_t line_height_px;
70 uint16_t active_font_px;
71 uint8_t active_style;
72 uint16_t indent_px;
77 uint8_t align;
78 uint8_t reserved8[2];
80
81/* ===========================================================================
82 * Cross-TU layout helpers (defined in reflow_layout.c unless noted).
83 * ===========================================================================
84 */
85
104RA8_PRIV void priv_reflow_layout_byte_zero(uint8_t* dst, size_t n);
105
123RA8_PRIV ra8_err_t priv_reflow_layout_init_font(const reflow_t* engine, stbtt_fontinfo* out_font);
124
142RA8_PRIV uint16_t priv_reflow_layout_line_height(uint16_t font_px);
143
163RA8_PRIV int32_t priv_reflow_layout_glyph_advance(const stbtt_fontinfo* font,
164 uint16_t font_px,
165 int32_t cp);
166
200 int32_t x,
201 int32_t y,
202 int32_t cp,
203 uint16_t font_px,
204 uint8_t style,
205 uint32_t color,
206 uint8_t link_id);
207
225
253RA8_PRIV bool priv_reflow_layout_newline(reflow_t* engine, priv_cursor_t* cur, bool allow_justify);
254
277 priv_cursor_t* cur,
278 const stbtt_fontinfo* font,
279 const reflow_token_t* tok);
280
307RA8_PRIV void priv_reflow_layout_build_link_rects(reflow_t* engine, const stbtt_fontinfo* font);
308
332RA8_PRIV bool
334
369 priv_cursor_t* cur,
370 const stbtt_fontinfo* font,
371 uint32_t start,
372 uint32_t* out_next);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
Test-access surface for reflow internal helpers (MC/DC).
bool priv_reflow_layout_apply_image(reflow_t *engine, priv_cursor_t *cur, const reflow_token_t *tok)
Apply an <img> token: real image when a loader is bound, else a placeholder.
bool priv_reflow_layout_newline(reflow_t *engine, priv_cursor_t *cur, bool allow_justify)
Wrap to a new line, finishing a page if the bottom margin is hit.
int32_t priv_reflow_layout_glyph_advance(const stbtt_fontinfo *font, uint16_t font_px, int32_t cp)
Measure a single ASCII code point's advance width in pixels.
void priv_reflow_layout_build_link_rects(reflow_t *engine, const stbtt_fontinfo *font)
Post-layout pass: group link-tagged glyphs into tappable rects.
ra8_err_t priv_reflow_layout_apply_token(reflow_t *engine, priv_cursor_t *cur, const stbtt_fontinfo *font, const reflow_token_t *tok)
Dispatch one parsed token through the layout cursor.
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)
Push one positioned glyph into the engine glyph pool.
bool priv_reflow_layout_finish_page(reflow_t *engine, priv_cursor_t *cur)
Finalise the current page and start a new one.
void priv_reflow_layout_byte_zero(uint8_t *dst, size_t n)
Bounded zero-fill used in place of memset(0).
ra8_err_t priv_reflow_layout_init_font(const reflow_t *engine, stbtt_fontinfo *out_font)
Initialise an stbtt_fontinfo from engine->font_data.
priv_layout_consts_t
Internal sizing knobs for the layout pass.
@ k_priv_row_gap_px
Vertical gap between table rows.
@ k_priv_min_chapter_pages
Floor for non-empty input.
@ k_priv_min_word_w_px
Minimum word width before forcing a break.
@ k_priv_hr_thickness_px
Pixel thickness of an <hr> (placeholder).
@ k_priv_cell_pad_px
Left/right inset inside a table cell.
@ k_priv_image_placeholder_px
Side length of <img> placeholder.
uint16_t priv_reflow_layout_line_height(uint16_t font_px)
Compute the line height in pixels for a given font size.
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.
Mutable state carried through the layout loop.
uint32_t page_first_image
First image-box index of the active page.
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.
uint16_t active_font_px
Active font size (body or heading).
uint32_t page_first_glyph
First glyph index of the active page.
int32_t x
Pixel column for next glyph.
uint32_t line_first_glyph
First glyph index of the active line.
uint16_t line_height_px
Active line height in pixels.
int32_t y
Pixel row baseline for next glyph.
uint8_t align
Active block alignment (reflow_align_t).
uint8_t reserved8[2]
Padding.
uint16_t indent_px
Active left indent (li, blockquote).
uint8_t active_style
Active inline-style stamp.
Reflow / pagination engine state.
One parsed token in the engine's token stream.