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

CTFeatureOpenTypeTag #307

Merged
merged 20 commits into from Oct 21, 2019
Merged

CTFeatureOpenTypeTag #307

merged 20 commits into from Oct 21, 2019

Conversation

@typemytype
Copy link
Owner

typemytype commented Oct 9, 2019

This should address #281 and #283.

@typemytype typemytype requested a review from justvanrossum Oct 9, 2019
@typemytype

This comment has been minimized.

Copy link
Owner Author

typemytype commented Oct 9, 2019

to problem still to solve:

  1. what is not possible anymore is to get the default settings for opentype feature tags

    but I guess CoreText is using the recommendations listed somewhere
    there are some here https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae in the UI suggestion part...

  2. for core macOS fonts like (Helvetica.ttc, Hoefler Text.ttc) we need to parse the feat table instead according this: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html

@jjgod @folengo

@typemytype

This comment has been minimized.

Copy link
Owner Author

typemytype commented Oct 9, 2019

this works now on 10.15

but no opentype features for fonts with a feat table

a direct download can be dowloaded here: http://static.typemytype.com/drawBot/DrawBot10.15.dmg

@typemytype

This comment has been minimized.

Copy link
Owner Author

typemytype commented Oct 9, 2019

fonts with feat should be supported now

@justvanrossum

This comment has been minimized.

Copy link
Collaborator

justvanrossum commented on drawBot/context/tools/openType.py in c9a513e Oct 14, 2019

TTFont also can be used as a context manager.

@justvanrossum

This comment has been minimized.

Copy link
Collaborator

justvanrossum commented Oct 14, 2019

The output of listOpenTypeFeatures() is not backwards compatible.

Copy link
Owner Author

typemytype left a comment

We must add a test case where a glyph is added that belongs to a calt feature so it would be replace automatically by CoreText... I assume there will be different behaviour on 10.10 and 10.13+

@@ -1777,7 +1780,7 @@ def appendGlyph(self, *glyphNames):
# disable calt features, as this seems to be on by default
# for both the font stored in the nsGlyphInfo as in the replacement character
fontAttributes = {}
fontAttributes[CoreText.NSFontFeatureSettingsAttribute] = [openType.featureMap["calt_off"]]
fontAttributes[CoreText.kCTFontFeatureSettingsAttribute] = [dict(CTFeatureOpenTypeTag="calt", CTFeatureOpenTypeValue=False)]

This comment has been minimized.

Copy link
@typemytype

typemytype Oct 17, 2019

Author Owner

I guess if this needs to work on 10.10 the olde style font attributes must be added too.

This comment has been minimized.

Copy link
@justvanrossum

justvanrossum Oct 17, 2019

Collaborator

Hmm, this oddly enough seems to work as expected on 10.10.

@typemytype typemytype merged commit 75dec60 into master Oct 21, 2019
@typemytype

This comment has been minimized.

Copy link
Owner Author

typemytype commented Oct 21, 2019

cool! building a fresh build later on today

justvanrossum added a commit that referenced this pull request Oct 28, 2019
* use CTFeatureOpenTypeTag to set and get opentype feature information

see #283 and #281

* lazy load ttfont

* adding support for fonts with a feat table

* disable OT fea in with tags and values

* improve setting fea in svg

syntax is "<tag>" <value> like `"liga" 0` to turn it off/on

* we need the values of the attributes

* improve svg test data

* listOpenTypeFeatures is a list

* fix tests to match the new uitcomes

* close the fontTools font object when done

* properly support TTC (don't just take the first font) and .dfont (use ps name as res name)

* no need for index therefore no need for enumerate

* also fall back to empty list when there's no ps fontname

* added newline at the end of the file

* added several bits of fallback code so simulated opentype fesatures keep working for AAT fonts in macOS < 10.13

* don't try to handle file types we don't know about

* better support for dfont and old-school suitcases

* guard against empty feature list

* added comment explaining why we don't raise but return None

* only warn when turning a non-available feature _on_ (or we'll get a warning for appendGlyph() which will unconditionally turn off 'calt')
@typemytype typemytype deleted the CTFeatureOpenTypeTag branch Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.