Skip to content
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 styles do not work on macOS #404

Closed
achabotl opened this issue Jun 9, 2020 · 2 comments · Fixed by #405
Closed

Font styles do not work on macOS #404

achabotl opened this issue Jun 9, 2020 · 2 comments · Fixed by #405

Comments

@achabotl
Copy link
Contributor

achabotl commented Jun 9, 2020

Italic and bold fonts are no found on macOS. The cause is a case-sensitive check that the filename contains the string italic or bold. Fix incoming.

if sfnt4.find('oblique') >= 0:

Here's a minimal example with the broken code.

from kiva.fonttools import Font
from kiva.image import GraphicsContext
from kiva.constants import ITALIC, BOLD

gc = GraphicsContext((200, 200))

gc.set_font(Font('', size=24))
gc.set_text_position(30, 120)
gc.show_text("Hello World")

gc.set_font(Font('Georgia', size=24))
gc.set_text_position(30, 80)
gc.show_text("Hello World")

gc.set_font(Font('Georgia', size=24, style=ITALIC))
gc.set_text_position(30, 40)
gc.show_text("Hello World")


gc.save('text.png')

text

achabotl added a commit that referenced this issue Jun 9, 2020
This makes style and stretch case insensitive in
`kiva.fonttools.font_manager.ttfFontProperty`. The case sensitivity led
to font styles not being properly detected on (at least) macOS.

The checks on filename were already case insensitive.

Fixes: #404
@corranwebster
Copy link
Contributor

I think this may be a duplicate of #391.

@achabotl
Copy link
Contributor Author

Yes, it's same root cause.

achabotl added a commit that referenced this issue Dec 9, 2020
* FIX: Make style and stretch check case insensitive

This makes style and stretch case insensitive in
`kiva.fonttools.font_manager.ttfFontProperty`. The case sensitivity led
to font styles not being properly detected on (at least) macOS.

The checks on filename were already case insensitive.

For testing, the "TestTTF Italic" font was edited in. FontForge [1]
to have the style "Italic".

[1]: https://fontforge.org/

Fixes: #404

Co-authored-by: Kit Yan Choi <kchoi@enthought.com>
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 a pull request may close this issue.

2 participants