Skip to content

scale schematic font sizes to em-height and render image borders - #143

Open
anil08607 wants to merge 1 commit into
tscircuit:mainfrom
anil08607:fix/schematic-font-scaling-and-image-borders
Open

scale schematic font sizes to em-height and render image borders#143
anil08607 wants to merge 1 commit into
tscircuit:mainfrom
anil08607:fix/schematic-font-scaling-and-image-borders

Conversation

@anil08607

Copy link
Copy Markdown
Contributor

Summary

Fixes schematic text sizing overflow and missing image borders in rendered SVGs (specifically observed on sheet 57 of ti-tmds62levm-rev-b around the "SCREW & WASHER FOR PCIe M.2" section):

  1. Schematic Font Size Scaling:

    • In Altium Designer schematic documents, the SIZE parameter defines font cell height / line spacing in 10-mil units ($1.25 \times \text{em-height}$). Direct assignment to SVG font-size resulted in text rendering ~25% larger than in Altium Designer, causing headers such as "SCREW & WASHER FOR PCIe M.2" (SIZE=25) to overflow their bounding boxes.
    • Introduced SCHEMATIC_FONT_SIZE_SCALE = 0.8 in lib/svg-serialization/get-schematic-font.ts to convert Altium cell height into standard SVG typographical em-square font size.
    • Headers, parameter values, and designators now fit cleanly within their intended margins.
  2. Schematic Image Border Rectangle:

    • Altium image records (RECORD=30) specify a border color via the Color field (e.g. Color=128 / #800000 on the washer drawing in Sheet 57).
    • Added border rectangle rendering (<rect data-record="30" ... fill="none" stroke="${color}" stroke-width="${formatSvgNumber(lineWidth)}"/>) in lib/svg-serialization/serialize-altium-sheet-to-svg.ts when COLOR is defined on the record.
  3. Snapshots & Test Coverage:

    • Updated tests/svg/ti-tmds62levm-schematic-sheets.test.ts to include Sheet 57 in snapshot assertions.
    • Updated tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-57.snap.svg and existing affected SVG snapshots.
    • Added tests/svg/schematic-sheet-57-screw-washer.test.ts to guard against regressions for text bounding and washer borders.

Verification

  • bun test: All 228 tests passing across 96 suites (including 57/57 TI TMDS62LEVM schematic sheets).
  • bun run typecheck: Passed with 0 errors.
  • bun run format:check: Passed.
  • bun run build: Clean build.

@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

@anil08607 is attempting to deploy a commit to the tscircuit Team on Vercel.

A member of the Team first needs to authorize it.

@anil08607 anil08607 changed the title fix(schematic): scale schematic font sizes to em-height and render image borders scale schematic font sizes to em-height and render image borders Sep 6, 2026
size: number
}

export const SCHEMATIC_FONT_SIZE_SCALE = 0.8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Font size scales based on the font, and different fonts can be used

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