-
Notifications
You must be signed in to change notification settings - Fork 254
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 fallback #669
Font fallback #669
Conversation
Co-authored-by: Lucas Cimon <[email protected]>
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.
The overall approach seems good to me!
Ping @gmischler if he wants to get a look at this 😊
@@ -1981,6 +1982,12 @@ def set_stretching(self, stretching): | |||
if self.page > 0: | |||
self._out(f"BT {stretching:.2f} Tz ET") | |||
|
|||
def set_fallback_fonts(self, fallback_fonts): |
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.
maybe add_fallback_fonts()
?
That would give the users more flexibility, in case they discover they need to add another font later on.
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.
add_fallback_fonts()
, as I understand it, could be a bit limiting, as it would not allow to remove fallback fonts, for example in some sections of a document.
In that sense set_fallback_fonts()
would provide a bit more control to the users: they could call it with more or less fonts, and even with []
to remove all fallback fonts.
Hi @andersonhc! I hope our feedbacks on this PR did not discourage you 😊 |
I got sidetracked working on #696. |
Co-authored-by: Lucas Cimon <[email protected]>
Co-authored-by: Lucas Cimon <[email protected]>
Co-authored-by: Lucas Cimon <[email protected]>
Co-authored-by: Lucas Cimon <[email protected]>
Co-authored-by: Lucas Cimon <[email protected]>
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.
Great work!
I gave you some final feedbacks / suggestions.
I'll be happy to merge this PR as soon as those points are addressed 😊
test/fonts/test_font_fallback.py
Outdated
txt="hello world 😄 😁 😆 😅 ✌ 🤞 🌭 🍔 🍟 🍕", w=50, new_x=XPos.LMARGIN, new_y=YPos.NEXT | ||
) | ||
pdf.write(txt="hello world 😄 😁 😆 😅 ✌ 🤞 🌭 🍔 🍟 🍕") | ||
assert_pdf_equal(pdf, HERE / "font_fallback.pdf", tmp_path) |
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.
Finally, could you please add a check that the warning you added in #661 is not raised in that scenario?
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 think something along those lines should do the trick:
assert len(caplog.text) == 0
You may want to get rid of |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #669 +/- ##
==========================================
+ Coverage 93.66% 93.75% +0.08%
==========================================
Files 26 26
Lines 6868 7008 +140
Branches 1226 1258 +32
==========================================
+ Hits 6433 6570 +137
- Misses 259 260 +1
- Partials 176 178 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Merged! Thank you @andersonhc ! |
There was a minor bug remaining in this PR when |
The 2 missing glyphs were by design... it was "bold" on markdown and I didn't set any bold emoji font, so they were missing just like it does when you don't have a fallback font. The solution in #712 disregard style, so bold text can be replaced by a non-bold fallback font. |
Oh OK! I did not realize that it was "by design" 😊
Indeed. What would you think about introducing a new (I suggested that we continue this discusion in comments on #712) |
This is a draft PR for handling #637
Sending it now so you can take a look and validate that's the path you want to take.
Checklist:
The GitHub pipeline is OK (green),
meaning that both
pylint
(static code analyzer) andblack
(code formatter) are happy with the changes of this PR.A unit test is covering the code added / modified by this PR
This PR is ready to be merged
In case of a new feature, docstrings have been added, with also some documentation in the
docs/
folderA mention of the change is present in
CHANGELOG.md
By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.