-
Notifications
You must be signed in to change notification settings - Fork 10
GUI: Add font preview to selection combobox #56
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
Conversation
This is awesome!!! The checks are failing because you should specify exactly which type of error you're expecting. It should be as specific as possible, otherwise you risk catching and ignoring the wrong error which is typically catastrophic. What you want should look something like: try:
...
except ValueError as e:
if str(e) != "the font is upside down":
# Unexpected error, reraise
raise e You should replace I don't seem to get any exceptions here, so I don't know what you're encountering. |
It looks like Also, could you please refactor things a bit to keep for font_path in get_available_fonts():
item = make_combobox_item_for_font(font_path)
if item is not None:
fonts_model.appendRow(item)
...
def make_combobox_item_for_font(font_path: Path) -> QStandardItem | None:
... Note that the new-style from __future__ import annotations at the top of the file. |
Thanks @FaBjE! I think this should be straightforward to merge. To fix
you just need to add from __future__ import annotations at the top of the file. |
If I add that, I get two ruff errors:
And a mypy error |
Ah, that's because
That's pretty weird, I'm not able to reproduce that from my side. Why don't you give it another shot by removing |
Done in #59 |
Feel free to merge |
362d6ff
to
899538d
Compare
899538d
to
53545af
Compare
Looks great, thanks @FaBjE! One more thought, it looks like we are dropping fonts whenever they aren't accepted by PyQt. We are rendering the fonts with Pillow, which is different. So PyQt being unable to load a font doesn't necessarily mean Pillow can't load it. I wonder if dropping these missing fonts in the GUI could create confusion? Would it make sense to instead add a non-stylized combo-box entry in this case? |
It passes now. Take a good look at the last commit. I have no clue if the automatic changes are correct. |
Yes, that's correct. |
Ah, wait, I think I'm a bit confused... Under which circumstance can |
My goal was to just show the font name in the default font in case PyQt doesn´t accept it. "If font loads correctly, apply font (family) name". Otherwise it just continues with the bold thingy? |
Ah yes. I just copied your function definition. |
Ya, that's exactly what I'm thinking. And also remove |
Just a tiny thing I cooked up today.
When selecting a font I got a big list of names, but no clue what they looked like.
This PR changes the combo-box so that every font name is shown in the font itself.
Because we don´t rely on system fonts but use our own font directory the handling is a bit "custom" instead of using a standard font selection combo-box.
But for this purpose I think it works very well.
Picture:

Please advise how to handle the empty excerpt error.
I added them because the font handling may fail. But it it is not important at all. Just ignore it.
Same with selecting the default font, that might not be available if the user removes it.