-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
node-graph/nodes/text/src/path_builder.rs, immediately before building ReadFontsRef and outline_glyphs() inside PathBuilder::render_glyph_run can be cached for better performance.
Current behavior
For each glyph run, the code:
- Collects
normalized_coordsfrom the run into aVec. - Takes
font.data/font.index, constructsReadFontsRef::from_index(...), and callsoutline_glyphs(). - Iterates glyphs and draws outlines via
draw_glyph.
Problem
render_glyph_run can be invoked frequently during text layout and editing. Reconstructing the font reference and outline glyph set for the same underlying font on every call is likely redundant work and may show up in profiling for documents with a lot of text or frequent updates.
Proposed direction
Introduce a cache keyed by something stable for the font instance, such as font data identity plus index, and any other inputs that affect outline access if needed. The cache would store or reuse the equivalent of ReadFontsRef / outline_glyphs() (or another API-appropriate handle) so repeated runs against the same font avoid repeated parsing.
Additional considerations:
- Optionally reduce allocations, for example by reusing a buffer for
normalized_coords, if profiling shows it matters. - Ensure thread-safety and lifetime rules match how
PathBuilderis used in the text node pipeline. - Add a small benchmark or trace comparison before and after, if feasible.
Location
node-graph/nodes/text/src/path_builder.rs — PathBuilder::render_glyph_run, near the TODO at around line 102.
Labels
performance