-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font path #453
Font path #453
Conversation
Add the option to specify a path to the font.
Add the option to specify a path to the font.
Fixed argument name mismatch.
Fix inconsistent tabs and spaces
Change whitespace to try and pass automated checks.
Adding a space between comment and function call :/
Codecov Report
@@ Coverage Diff @@
## master #453 +/- ##
==========================================
+ Coverage 93.61% 93.64% +0.02%
==========================================
Files 25 30 +5
Lines 5326 5868 +542
Branches 554 625 +71
==========================================
+ Hits 4986 5495 +509
- Misses 215 234 +19
- Partials 125 139 +14
Continue to review full report at Codecov.
|
Add test for "text" using fontPath keyword argument.
Trying Unix style path.
Try just the current directory.
Try pulling a valid path from elsewhere in the file.
Perhaps the call to os.path.join will allow the tests to run.
The implementation works on my machine. And I haven't been able reproduce the segfault at https://github.com/cactrot/cadquery/blob/00a1329c2ef7a17e94566a6a330780af05098483/tests/test_cadquery.py#L2746 on my machine. Not sure how to proceed, so I guess this is stalled for now. |
Thanks for the contribution @cactrot ! The segfault is reproducible across different platforms, so there is something systematic happening. Are you sure that the file Backtrace for future ref:
|
Add font for testing makeText
Changed directory to point to test data.
Hoping https://fonts.google.com/specimen/Open+Sans#license is a reasonable choice for test data. |
OK, that's progress! Is some safety check for situations when the font is not found? |
It looks like the underlying implementation is already trying to do that. I suppose "os.path.exists" before the call might be a quick fix. Or, catching segfault with the "signal" module. |
We are not using PythonOCC anymore, but rather our own binding (OCP). It looks like a |
Check for non-existent file instead of trying to use it and possibly segfaulting.
Check for non-existent file instead of trying to use it and possibly segfaulting.
Fix type mismatch.
Code from PyOCC expected non-implemented function.
Inverted logic
I added a call to check_font before trying to use the file and coverage tests for a real and non-existent file. |
Use name based on the path for registering
@cactrot I reworked the font registration a bit - custom fonts use the path as their name now. Could you check if it still works well for you? As far as I can tell, this approach does work and will not overwrite existing fonts by accident. |
Just pulled the changes and ran the code. Still appears to work well for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added one question related to using the tempfile module because I've been bitten before when not using that, but otherwise this PR looks good. I appreciate the contribution @cactrot
Thanks again @cactrot ! Merging now since Adam has already approved. |
Thanks for the contribution @cactrot ! |
Add the ability to specify a file path for the font.
Implements #198