Skip to content

Fix FontFile equality so identical fonts compare equal - #1204

Open
creat3dworld wants to merge 1 commit into
Snapmaker:mainfrom
creat3dworld:fix-1009-fontfile-equality
Open

creat3dworld wants to merge 1 commit into
Snapmaker:mainfrom
creat3dworld:fix-1009-fontfile-equality

Conversation

@creat3dworld

Copy link
Copy Markdown

Closes #1009

Root cause

On macOS, bold/italic variants live as different faces inside one .ttc collection (e.g. Helvetica.ttc index 0 Regular, 1 Bold, 2 Oblique, 3 BoldOblique); WxFontUtils::set_bold()/set_italic() load the file again but nothing sets FontProp::collection_number, so index 0 is always rendered. Two related defects: (a) Emboss::FontFile::operator== compares descent/linegap with == instead of !=, so identical font files are never detected and the synthetic bold/skew fallback never fires; (b) after reload, wxWidgets reports the bold/italic font as "normal" style/weight, so button states are wrong.

Fix (partial)

Defect (a) is verified in source (Emboss.hpp: infos[i].descent == other.infos[i].descent || infos[i].linegap == other.infos[i].linegap — with ==, equal descent/linegap makes the condition true and returns false, so identical fonts are never equal). Fixed to !=. This is a clear, cross-platform correctness fix (inherited from PrusaSlicer).

The main .ttc defect (collection_number never set from the OS-resolved face index) is NOT fixed here — it needs the reporter's macOS Core Text fix (resolve the face index the OS selected and store it in collection_number, plus restoring style/weight from the matched font), which the reporter says they tested and will PR. No open PR for #1009 was found on this repo, so the reporter's PR has not landed yet. This operator== patch is a subset of their fix; if their PR lands first, this one can be dropped in favour of it.

Based on the v2.4.1 tag. Upstream main has moved 25 commits ahead of v2.4.1; this branch is based on v2.4.1, and the files it touches were not changed on main since v2.4.1, so it should merge cleanly.

Verification: the patch was verified to apply cleanly to a fresh v2.4.1 copy (dry-run + byte-compare). It was NOT compile-tested — this VM has no build toolchain for OrcaSlicer.

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.

Set bold” / “Set italic” buttons have no effect on the generated text (macOS, .ttc fonts)

1 participant