feat(pdf): searchable text layer with per-style subset font embedding

Real BT/Tj text objects ride alongside the vector outlines (Tr 3,
zero visual change): runs preserved at layout time, TTF styles embedded
as allsorts subsets with ToUnicode, width-matched Tm, clip-culled.
WireModel literals moved to ..Default::default() tails.
This commit is contained in:
Karim Jerbi committed 2026-10-01 23:30:35 +01:00
1 parent 443b935a3f
commit 02c470aac7
44 files changed
+1534 -127

No files matched your search

+28 -2
View File
@@ -147,6 +147,7 @@ pub fn apply_along(
// Embedded linetype text (LtSeg::Text) renders as SDF glyph quads collected
// here; emitted as one extra text-carrying WireModel at the end.
let mut text_verts: Vec<crate::scene::pipeline::text_gpu::TextVertex> = Vec::new();
let mut searchable: Vec<crate::scene::model::wire_model::SearchableTextRun> = Vec::new();
let mut elem_idx: usize = 0;
let mut elem_consumed: f32 = 0.0;
@@ -269,7 +270,7 @@ pub fn apply_along(
// SDF: glyph quads at the insert point (rotation baked in by
// layout_glyph_quads), collected for the text wire.
if let Ok(mut atlas) = crate::scene::text::sdf_atlas::text_atlas().lock() {
let quads = crate::scene::text::glyph_quads::layout_glyph_quads(
let (quads, pen_adv) = crate::scene::text::glyph_quads::layout_glyph_quads(
&mut atlas,
*tx_scale,
fwd_angle,
@@ -291,6 +292,28 @@ pub fn apply_along(
color,
0.0,
);
{
use crate::scene::model::wire_model::{
clean_searchable_text, SearchableTextRun,
};
let visible = clean_searchable_text(&resolved);
if !visible.is_empty() {
searchable.push(SearchableTextRun {
text: visible,
origin: [
insert[0] as f64,
insert[1] as f64,
insert[2] as f64,
],
height: *tx_scale,
rotation: fwd_angle,
color,
bold: false,
font: style.to_string(),
adv_width: pen_adv,
});
}
}
}
elem_idx += 1;
@@ -342,7 +365,9 @@ pub fn apply_along(
plinegen: true,
fill_tris: vec![],
fill_tris_low: Vec::new(),
})
..Default::default()
})
.collect();
// Embedded linetype text (SDF): one extra wire carrying the glyph quads,
@@ -376,6 +401,7 @@ pub fn apply_along(
dash_from_start: false,
dash_align_end: None,
text_verts,
searchable_text: searchable,
name: name.to_string(),
points: Vec::new(),
points_low: Vec::new(),