Skip to content

Raise an error when the requested font is not found#2062

Open
HaozheZhang6 wants to merge 1 commit into
CadQuery:masterfrom
HaozheZhang6:fix/font-not-found-error
Open

Raise an error when the requested font is not found#2062
HaozheZhang6 wants to merge 1 commit into
CadQuery:masterfrom
HaozheZhang6:fix/font-not-found-error

Conversation

@HaozheZhang6

Copy link
Copy Markdown

Closes #1920.

Workplane.text(...) / Shape.makeText(...) silently fell back to the default font when the requested font couldn't be found, so a typo'd font name produced text in the wrong font with no indication.

Using Font_FontMgr.FindFont with Font_StrictLevel_Aliases (instead of the default Font_StrictLevel_Any) returns a null handle when the font can't be resolved, so we raise a clear ValueError instead. Aliased/valid fonts still resolve as before. Applied to both font-loading paths (makeText and the free text function), with a test.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.76%. Comparing base (f69500e) to head (349f572).

Files with missing lines Patch % Lines
cadquery/occ_impl/shapes.py 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2062      +/-   ##
==========================================
- Coverage   95.78%   95.76%   -0.02%     
==========================================
  Files          30       30              
  Lines        9427     9431       +4     
  Branches     1404     1406       +2     
==========================================
+ Hits         9030     9032       +2     
- Misses        242      243       +1     
- Partials      155      156       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

raise error when font is not found

1 participant