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

Matching TTF fonts isn't working well #391

Closed
1 of 2 tasks
corranwebster opened this issue Feb 16, 2020 · 2 comments · Fixed by #605 or #707
Closed
1 of 2 tasks

Matching TTF fonts isn't working well #391

corranwebster opened this issue Feb 16, 2020 · 2 comments · Fixed by #605 or #707
Labels
ETS Backlog Good issue for ETS team members to look at

Comments

@corranwebster
Copy link
Contributor

corranwebster commented Feb 16, 2020

Several problems with the algorithm:

  • ttfFontProperties looks into the TFFont to find the 'sfnt4' string with styling information. It then does very dumb matching for key phrases, such as "italic", but doesn't normalize case, doesn't account for phrases which are sub-phrases of other phrases (eg. "bold" in "demibold"), and could get mismatches if a phrase is part of the name of the font (eg. "book" or "roman").
  • when matching .ttc files we are only returning the file, not the index of the font in the .ttc file. FreeType2 needs this index to be able to find the correct font. Currently the API has no way of even passing this information through to the Agg/Celiagg.
@jwiggins
Copy link
Member

It'll take some time for this to bubble out, but:

╰$ edm run -- ipython
Python 3.6.9 |Enthought, Inc. (x86_64)| (default, Feb 25 2020, 20:28:43) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from kiva.fonttools import Font                                         

In [2]: Font("Times New Roman", style=0).findfont()                             
Out[2]: '/Library/Fonts/Times New Roman.ttf'

In [3]: Font("Times New Roman", style=1).findfont()                             
Out[3]: '/Library/Fonts/Times New Roman Bold.ttf'

In [4]: Font("Times New Roman", style=2).findfont()                             
Out[4]: '/Library/Fonts/Times New Roman Italic.ttf'

In [5]: Font("Times New Roman", style=3).findfont()                             
Out[5]: '/Library/Fonts/Times New Roman Bold Italic.ttf'

@jwiggins
Copy link
Member

There are still issues with parsing of the styling information. #605 only covered the face index bits of TTC files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ETS Backlog Good issue for ETS team members to look at
Projects
None yet
2 participants