Skip to content

fix(render): integrate Vietnamese legacy transcoding and respect text width metrics - #1

Merged
vantruong-dang merged 2 commits into
feature/pr1-vietnamese-fontsfrom
feature/vietnamese-legacy-transcoder
Oct 24, 2026
Merged

vantruong-dang merged 2 commits into
feature/pr1-vietnamese-fontsfrom
feature/vietnamese-legacy-transcoder

Conversation

@vantruong-dang

Copy link
Copy Markdown
Owner

Summary

This PR is stacked on top of PR storytold#1877 (Fonts). It completes the integration of the legacy Vietnamese transcoder (cadcraft-fonts::vietnamese) into the rendering pipeline.

Previously, TextFont::resolve mapped legacy font names (e.g., .VnTime, VNI-Helve) to modern Unicode faces, but raw strings were passed unchanged to the shaper, causing mojibake (e.g., B¶n vÏ instead of Bản vẽ). Additionally, legacy text suffered from overlap issues because text style width_factor (DXF group 41) was ignored in layout calculations.

Key Changes

  1. Render Pipeline Integration:

    • crates/render/src/lib.rs: Wrapped place_text_entity, layout_mtext_entity, and dim_text with transcode_vietnamese(value, hint) and dynamic font resolution.
    • Preserve entity width_factor multiplied by TextStyle.width_factor (twf * swf) and combine oblique angles (t.oblique + ts.oblique).
  2. Table & Dimension Layout:

    • crates/render/src/table.rs: Transcodes table cell text and resolves Vietnamese font hints.
    • crates/render/src/dim.rs: Transcodes user dimension text overrides and DIMPOST strings.
    • crates/render/src/linetype_text.rs & tolerance.rs: Added transcoding for complex linetype texts and geometric tolerance callouts.
  3. Integration Tests (crates/render/src/tests.rs):

    • place_text_entity_transcodes_legacy_vietnamese: Verifies TCVN3 and VNI TEXT entities shape into proper Unicode glyphs.
    • text_width_factor_compresses_bounding_box: Proves width compression and style factor multiplication prevent text overlap.
    • mtext_segments_transcode_legacy_vietnamese: Tests multiline MTEXT with \P paragraph breaks.
    • table_cell_transcodes_and_renders_vietnamese: Tests table cell rendering in DisplayList.
    • dimension_override_transcodes_vietnamese: Tests dimension override strings.

Quality Gates

  • cargo test -p cadcraft-render: 96/96 tests pass (100%).
  • cargo test -p cadcraft-fonts: 71/71 tests pass (100%).
  • cargo xtask layers: 16/16 crates compliant, no violations.

…factor

- Connect transcode_vietnamese in place_text_entity, layout_mtext_entity, and table cells
- Preserve entity width_factor multiplied by TextStyle width_factor (twf * swf)
- Combine entity oblique with TextStyle oblique for precise text column layout
- Resolve text fonts dynamically using style name and font name hints
…yout metrics

# Conflicts:
#	crates/render/src/dim.rs
@vantruong-dang
vantruong-dang force-pushed the feature/vietnamese-legacy-transcoder branch from 514cdfa to 1e8c71c Compare October 23, 2026 08:10
@vantruong-dang
vantruong-dang merged commit 1e8c71c into feature/pr1-vietnamese-fonts Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants