Skip to content

Commit 47870f4

Browse files
committed
Debug shape example
1 parent 2352c47 commit 47870f4

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

examples/shape.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fn create_example_page(
4040
) -> Vec<Op> {
4141
let mut ops = Vec::new();
4242

43+
/*
4344
// Start with a title
4445
ops.extend(create_title(
4546
doc,
@@ -106,6 +107,7 @@ fn create_example_page(
106107
Pt(20.0),
107108
page_height.into_pt() - Pt(200.0),
108109
));
110+
*/
109111
ops.extend(create_text_with_hole(
110112
doc,
111113
font_id,
@@ -123,6 +125,7 @@ fn create_example_page(
123125
},
124126
));
125127

128+
/*
126129
// Example 5: Multi-column text
127130
ops.extend(create_section_title(
128131
doc,
@@ -171,7 +174,8 @@ fn create_example_page(
171174
"Created with printpdf text shaping API",
172175
page_width.into_pt(),
173176
));
174-
177+
*/
178+
175179
ops
176180
}
177181

src/font.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ impl ParsedFont {
351351

352352
use crate::TextAlign;
353353

354+
let hie = options.holes.is_empty();
355+
354356
let holes = options
355357
.holes
356358
.iter()
@@ -366,6 +368,10 @@ impl ParsedFont {
366368
})
367369
.collect::<Vec<_>>();
368370

371+
if !hie {
372+
println!("holes: {holes:#?}");
373+
}
374+
369375
// Create layout options
370376
let resolved_options = ResolvedTextLayoutOptions {
371377
font_size_px: options.font_size.0,
@@ -381,18 +387,34 @@ impl ParsedFont {
381387
// Split text into words
382388
let words = split_text_into_words(text);
383389

390+
if !hie {
391+
println!("words: {words:#?}");
392+
}
393+
384394
// Use adapter to convert to azul_layout's ParsedFont type
385395
let azul_font = self::azul_convert::convert_to_azul_parsed_font(self);
386396

387397
// Shape words using azul_layout's shaping
388398
let shaped_words = shape_words(&words, &azul_font);
389399

400+
if !hie {
401+
println!("shaped_words: {shaped_words:#?}");
402+
}
403+
390404
// Position words
391405
let word_positions = position_words(&words, &shaped_words, &resolved_options);
392406

407+
if !hie {
408+
println!("word_positions: {word_positions:#?}");
409+
}
410+
393411
// Create text layout
394412
let mut inline_text_layout = word_positions_to_inline_text_layout(&word_positions);
395413

414+
if !hie {
415+
println!("inline_text_layout: {inline_text_layout:#?}");
416+
}
417+
396418
let cs = options
397419
.max_width
398420
.map(|w| w.0)
@@ -425,8 +447,19 @@ impl ParsedFont {
425447
&inline_text_layout,
426448
);
427449

450+
451+
if !hie {
452+
println!("inline_text: {inline_text:#?}");
453+
}
454+
428455
// Extract shaped text from inline text
429-
ShapedText::from_inline_text(font_id, &inline_text, options)
456+
let st = ShapedText::from_inline_text(font_id, &inline_text, options);
457+
458+
if !hie {
459+
println!("shaped text: {st:#?}");
460+
}
461+
462+
st
430463
}
431464
}
432465

tests/font.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn test_custom_font_roundtrip() {
3737
.save(&PdfSaveOptions::default(), &mut Vec::new());
3838

3939
// Save the PDF for inspection if needed
40-
std::fs::write("./test_font_roundtrip.pdf", &bytes).unwrap();
40+
// std::fs::write("./test_font_roundtrip.pdf", &bytes).unwrap();
4141

4242
// Now try to parse the PDF back
4343
let mut warnings = Vec::new();

tests/integration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,12 @@ fn test_html_to_document() {
222222
})
223223
.unwrap();
224224

225+
/*
225226
let _ = std::fs::write(
226227
"./htmltest.pdf",
227228
output.save(&PdfSaveOptions::default(), &mut Vec::new()),
228229
);
230+
*/
229231

230232
assert!(!output.pages.is_empty());
231233
}

0 commit comments

Comments
 (0)