Skip to content

SVG fonts are theme defaults, not the model's: QEA builder drops font_size, elements render Arial 9px/13px instead of EA fonts #53

Description

@ronaldtse

Summary

Emitted SVG text does not use the fonts specified by the model. The emitter always renders theme defaults (observed: Arial 9px, Yu Gothic UI 13px, Calibri 7px mixed in one diagram), while EA's own export applies the per-element font face and size. Font face and size therefore differ from what EA builds.

Mechanism

Ea::Model::DiagramElement models the full font set (font_family, font_size, font_bold, font_italic, font_underline), but:

  1. The QEA builder drops the size. lib/ea/sources/qea/diagram_builder.rb:95-97 maps only font_family, font_bold, font_italic from the style hash — font_size and font_underline are never assigned. The QEA style/font table carries the size (EA stores per-element font size); it is parsed into style_hash and discarded.
  2. FontResolver therefore always misses. lib/ea/svg/ea_emitter/font_resolver.rb:35-43 uses element.font_size only when explicitly set, else falls back to theme.font_size — so every element renders at the theme default instead of its model font.
  3. Serialized diagram shards confirm it: elements carry fontFamily / fontBold / fontItalic but no fontSize key at all.

Result in one rendered CG2 diagram: font-family:Arial; font-size:9px (×42), Yu Gothic UI 13px (×21), Calibri 7px (×1) — a theme mishmash, not the model's fonts, and px units where EA's export uses its own font-size conventions.

Impact

Any consumer comparing our SVG to EA's export sees wrong text metrics: different face, different size, different line wrapping and box overflow. This blocks the parity goal — SVG output must be fully identical to what EA builds — together with #51 (text renderer crash) and #52 (connector source ports).

Suggested direction

  • QEA diagram_builder: map font_size (and font_underline) from the style hash / font table alongside family/bold/italic; consult the QEA font table (t_font) where per-object overrides live.
  • Keep FontResolver's theme fallback, but only for elements that genuinely have no font data.
  • Add font face/size/weight to Ea::Svg::Parity::Checker's measured attributes so regressions are caught against EA reference exports.

Parity acceptance

Parity::Suite (lib/ea/svg/parity/suite.rb) is ready to drive this — it compares our render against per-diagram EA reference SVGs (<eaid>.svg in a reference dir) — but the repository currently ships zero EA reference exports. To "ensure the SVGs built are fully identical to what EA builds", we need a set of EA-exported reference SVGs for a representative diagram subset committed as fixtures, and the suite extended to fail on font/geometry deltas, not just element counts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions