36#include "stb_truetype.h"
121 int32_t bw = (iw < col_w) ? iw : col_w;
122 int32_t bh = (int32_t)(((int64_t)ih * (int64_t)bw) / (int64_t)iw);
125 bw = (int32_t)(((int64_t)iw * (int64_t)bh) / (int64_t)ih);
127 *out_w = (bw < 1) ? 1 : bw;
128 *out_h = (bh < 1) ? 1 : bh;
157 const uint8_t* bytes =
nullptr;
169 if ((col_w < 1) || (avail_h < 1)) {
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_ok
Success – operation completed with all postconditions satisfied.
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
Zero-heap raster image decode + scale + blit for reflow (#106).
ra8_err_t ra8_img_probe_size(const uint8_t *bytes, size_t len, int32_t *out_w, int32_t *out_h)
Probe an image's intrinsic dimensions without a full decode.
Test-access surface for reflow internal helpers (MC/DC).
bool priv_reflow_internal_right_overflow_break(int32_t cursor_x, int32_t advance, int32_t right_limit, uint8_t line_has_content)
Decide whether a glyph emission would overflow the right margin AND the current line already has cont...
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.
bool priv_reflow_layout_finish_page(reflow_t *engine, priv_cursor_t *cur)
Implementation of priv_reflow_layout_finish_page() – flush + reset cursor.
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.
static bool internal_apply_image_placeholder(reflow_t *engine, priv_cursor_t *cur)
Apply an <img> token without a bound loader: placeholder advance.
static void internal_image_record(reflow_t *engine, priv_cursor_t *cur, const reflow_token_t *tok, int32_t bw, int32_t bh)
Record a laid-out image box and advance the cursor below it.
static void internal_image_fit(int32_t iw, int32_t ih, int32_t col_w, int32_t avail_h, int32_t *out_w, int32_t *out_h)
Scale an intrinsic image size to fit the text column (no upscaling).
static bool internal_place_image(reflow_t *engine, priv_cursor_t *cur, const reflow_token_t *tok)
Lay out a real <img> as a block: size it, page-break, record it.
static bool internal_image_resolve_size(reflow_t *engine, const reflow_token_t *tok, int32_t *out_w, int32_t *out_h)
Resolve an image token to a column-fitted box size via the loader.
static bool internal_page_has_content(const reflow_t *engine, const priv_cursor_t *cur)
True iff the page under construction already holds glyphs or images.
Cross-TU shared declarations for the reflow layout engine.
@ k_priv_image_placeholder_px
Side length of <img> placeholder.
@ k_reflow_max_images
Max laid-out <img> boxes.
@ k_reflow_paragraph_gap_px
Vertical gap after a block.
@ k_reflow_margin_px
Page edge inset, pixels.
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.
uint32_t page_first_glyph
First glyph index of the active page.
int32_t x
Pixel column for next glyph.
uint16_t line_height_px
Active line height in pixels.
int32_t y
Pixel row baseline for next glyph.
uint16_t indent_px
Active left indent (li, blockquote).
One laid-out <img> rectangle (decoded + blitted at render time).
uint32_t src_len
Href slice length, bytes.
int32_t y
Page-local top edge, pixels.
int32_t x
Page-local left edge, pixels.
uint32_t page_index
Page this image belongs to.
uint32_t reserved
Padding to 32-byte stride.
int32_t w
Scaled box width, pixels.
uint32_t src_off
Href slice offset into text pool.
int32_t h
Scaled box height, pixels.
Reflow / pagination engine state.
uint32_t page_count
Pages used.
reflow_image_loader_fn img_loader
<img> byte loader (NULL = off).
ra8_img_arena_t * img_arena
Decode scratch (NULL = off).
uint32_t glyph_count
Glyphs used.
uint8_t text_pool[k_reflow_text_pool_bytes]
Text bytes.
void * img_loader_ctx
Opaque context for img_loader.
uint16_t viewport_w
Viewport width, pixels.
uint16_t viewport_h
Viewport height, pixels.
reflow_image_box_t image_boxes[k_reflow_max_images]
Laid-out images.
uint32_t image_box_count
Image boxes used.
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.