Skip to content

Conversation

ebraminio
Copy link
Collaborator

@ebraminio ebraminio commented Nov 1, 2018

Closes #1304

@ebraminio ebraminio force-pushed the feat branch 4 times, most recently from 42a50fc to ea64bc0 Compare November 1, 2018 12:05
@ebraminio
Copy link
Collaborator Author

PTAL

Copy link
Collaborator

@drott drott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. Some feedback on naming and documentation.

Copy link
Member

@behdad behdad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an initial review. Didn't validate the API itself. Am heading to read 'feat' table now and be back with commets on that.

@ebraminio
Copy link
Collaborator Author

Applied just no strong preference yet whether we need to return default index or default value (currently).

@behdad
Copy link
Member

behdad commented Nov 1, 2018

A couple side-issues:

  • I currently merge multiple feature settings for the same setting when applying features. Looks like some features are non-exclusive and hence should not be merged? Or I can just remove the merge logic...

  • This API is not quite useful without mapping from AAT features to OpenType tags. Do we expose that?

@ebraminio
Copy link
Collaborator Author

This API is not quite useful without mapping from AAT features to OpenType tags. Do we expose that?

Maybe a separate issue, you said Chrome doesn't need that right now.

@behdad
Copy link
Member

behdad commented Nov 1, 2018

This API is not quite useful without mapping from AAT features to OpenType tags. Do we expose that?

Maybe a separate issue, you said Chrome doesn't need that right now.

Right. But I want to have the full picture laid out before adding anything. I don't want to find later that we should have done this differently.

@behdad
Copy link
Member

behdad commented Nov 1, 2018

It occurs to me that it's also possible to get user set AAT features using feature codes directly, by, eg, passing HB_TAG(" 1") to mean feature type 1, and the value will be the selector. I think we should hook these up in addition to the current OpenType to AAT feature mapping.

@behdad
Copy link
Member

behdad commented Nov 1, 2018

HB_TAG(" 1")

Of just (hb_tag_t) 1.

@behdad
Copy link
Member

behdad commented Nov 1, 2018

Of just (hb_tag_t) 1.

Yeah I like this one better.

@behdad
Copy link
Member

behdad commented Nov 1, 2018

Read 'feat' table. So, the proposed API completely misses the part about enumerating features themselves. I don't like that. I think there should be a first layer API to list all features and get their name_id's and look up feature's index, then the second layer takes a feature_index and lists the settings.

@ebraminio
Copy link
Collaborator Author

I think there should be a first layer API to list all features and get their name_id's and look up feature's index, then the second layer takes a feature_index and lists the settings.

Done. But I liked the first layer just was fetching features and fetching name_id on second layer.

It occurs to me that it's also possible to get user set AAT features using feature codes directly, by, eg, passing HB_TAG(" 1") to mean feature type 1, and the value will be the selector.

So reverting enum thing?

@ebraminio ebraminio force-pushed the feat branch 3 times, most recently from 31b5054 to 29694b6 Compare November 6, 2018 17:08
src/hb-aat.h Outdated
HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_CJK_ROMAN = 1,
HB_AAT_LAYOUT_SELECTOR_DEFAULT_CJK_ROMAN = 2,
HB_AAT_LAYOUT_SELECTOR_FULL_WIDTH_CJK_ROMAN = 3
} hb_aat_layout_feature_setting_t;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess "setting" or "selector" should only be used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Pick one and only use that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either "feature_setting" or "feature_selector". Selector sounds less confusing.

const SettingName* setting = (SettingName*) hb_bsearch (&key, feat+settingTableZ,
nSettings,
SettingName::static_size,
SettingName::cmp);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good idea to have an UnsizedSortedArrayOf (or SortedUnsizedArrayOf?) and move the logic there. COLR/CPAL needed that IIRC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.

@behdad
Copy link
Member

behdad commented Nov 19, 2018

I like us to map out other API that interacts with this, before merging it. So far, things that have been discussed:

  • If feat feature is missing, dig into the morx table and extracted list of features?
  • API to convert AAT-style features into OT-style. And back?
  • If GSUB is missing, convert back feat table features to OT style and return from hb-ot-layout API.
  • Allow user specifying AAT features directly (without going through OT equivalents) in hb_feature_t, by using tag names like ' 12' for feature number 12.

@ebraminio
Copy link
Collaborator Author

ebraminio commented Nov 19, 2018 via email

@drott
Copy link
Collaborator

drott commented Nov 22, 2018

Coming back here. behdad@, I think I got confused: I asked you whether I can retrieve the CTFont from hb_coretext_font, but IIUC, after moving to HarfBuzz AAT we won't have a CTFont or hb_coretext_font anymore, so I won't have a good way of accessing the CTFont we have up in SkTypeface in the case-mapping/small-caps processing code except for changing a bunch of plumbing above, so some exposing feat HarfBuzz in HarfBuzz becomes more essential.

@ebraminio
Copy link
Collaborator Author

You can have access to CTFont even after HB AAT, you should just not pass coretext-aat after using hb_shape_full but better to not go there, Behdad concerns are understandable, maybe we can have this behind some compiler flag enabled only for Chromium and only on macOS for now (so no gentoo/chromeos packaging issue I guess) if just merging it is not a good idea.

@drott
Copy link
Collaborator

drott commented Nov 22, 2018

You can have access to CTFont even after HB AAT, you should just not pass coretext-aat after using hb_shape_full but better to not go there [...]

I will not be passing a CTFont based hb_font to HarfBuzz anymore after switching to HarfBuzz AAT, so I don't think there is an underlying CTFont anymore.

@behdad
Copy link
Member

behdad commented Nov 22, 2018

maybe we can have this behind some compiler flag enabled only for Chromium and only on macOS for now

Why not finish it?

@ebraminio
Copy link
Collaborator Author

ebraminio commented Nov 22, 2018 via email

@behdad
Copy link
Member

behdad commented Nov 22, 2018

I don't know what to do :)

I listed:

* If `feat` feature is missing, dig into the `morx` table and extracted list of features?

This is easy. But if you don't want to get into it, that's fine for the first round, since doesn't have API implications.

* API to convert AAT-style features into OT-style.  And back?

Propose API for this. It's close to trivial. We have an internal API that converts one to another. Model two APIs based on that (just type here, DON'T send a patch) and we discuss it from there.

* If `GSUB` is missing, convert back `feat` table features to OT style and return from hb-ot-layout API.

If you do the conversion API, this part is also easy, but also not required initially since no API implications.

* Allow user specifying AAT features directly (without going through OT equivalents) in `hb_feature_t`, by using tag names like `'  12'` for feature number 12.

Also easy. Also not required initially since no API implications.

@behdad
Copy link
Member

behdad commented Nov 23, 2018

* API to convert AAT-style features into OT-style.  And back?

Propose API for this. It's close to trivial. We have an internal API that converts one to another. Model two APIs based on that (just type here, DON'T send a patch) and we discuss it from there.

Even this doesn't have to be implemented before merging this work. I just want to know we have a plan and discuss the API, to avoid any surprises and blind spots later.

@behdad
Copy link
Member

behdad commented Nov 23, 2018

One more item to add to TODO list: enum for OpenType features.

@behdad
Copy link
Member

behdad commented Nov 23, 2018

I studied this more and I'm comfortable merging it. We can expose something along the lines of hb_aat_layout_find_feature_mapping() and inverse later.

unsigned int settings_count = nSettings;
if (count && *count)
{
unsigned int len = MIN (settings_count - start_offset, *count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ported to use hb_array_t and sub_array().

unsigned int feature_count = featureNameCount;
if (count && *count)
{
unsigned int len = MIN (feature_count - start_offset, *count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same re using hb_array_t and .sub_array().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about this before, no sub_array on UnsizedArrayOf, and doesn't worth to IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnsizedArrayOf should not be used directly. Maybe I remove operator[] from it. Idea is you bind it with a length to get a hb_array_t and use that, which has a sub_array().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnsizedArrayOf::as_array().

} hb_aat_layout_feature_setting_t;

HB_EXTERN unsigned int
hb_aat_layout_get_features (hb_face_t *face,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix namespacing. Again, you have all under "hb_aat_layout" namespace, ie. they all start with "hb_aat_layout_get". We want more fine-grained namspacing.

This one is fine, get_features.

src/hb-aat.h Outdated
hb_aat_layout_feature_setting_t *settings /* OUT. May be NULL. */);

HB_EXTERN hb_ot_name_id_t
hb_aat_layout_get_feature_setting_name_id (hb_face_t *face,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hb_aat_layout_feature_setting_get_name_id or, feature_selector

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we did this in ot-layout, and in general do these things, is to have find_feature or something, take feature type and return a feature index. The subsequent API entrypoints then take that index, to avoid having to look up the feature entry again and again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Understandable as did once for hb_ot_layout_feature_get_characters


inline hb_ot_name_id_t get_feature_name_id () const { return nameIndex; }

inline hb_ot_name_id_t get_feature_setting_name_id (const feat *feat,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions taking feat table look weird. I think things can be done differently, but I need to pull down the code and take a deeper look than just reading the patch.

@behdad
Copy link
Member

behdad commented Nov 23, 2018

This part of the spec:

"""For feature types that don't have exclusive settings, there will always be a pair of values. One value turns a selector on and a second value turns the selector off. The on setting must be even and the off setting must be one greater than the corresponding on setting. The off setting is therefore always odd. As a result, only the on setting should have an entry in the setting name array."""

needs at least to go into documentation...

@codecov
Copy link

codecov bot commented Nov 23, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@e3a1a83). Click here to learn what that means.
The diff coverage is 94.36%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1346   +/-   ##
=========================================
  Coverage          ?   76.36%           
=========================================
  Files             ?      134           
  Lines             ?    16372           
  Branches          ?        0           
=========================================
  Hits              ?    12503           
  Misses            ?     3869           
  Partials          ?        0
Impacted Files Coverage Δ
src/hb-aat-map.hh 58.82% <ø> (ø)
src/hb-aat-layout.hh 100% <ø> (ø)
src/hb-aat-map.cc 38.09% <0%> (ø)
src/hb-aat-layout-feat-table.hh 100% <100%> (ø)
src/hb-aat-layout.cc 85.71% <100%> (ø)
src/hb-aat-layout-morx-table.hh 90.25% <71.42%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3a1a83...2243f42. Read the comment docs.

hb_aat_layout_feature_setting_t
hb_aat_layout_feature_get_selectors
hb_aat_layout_feature_selector_get_name_id
hb_aat_layout_feature_selector_t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type name typically goes before functions using it.

@behdad behdad closed this in 926f512 Nov 25, 2018
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 this pull request may close these issues.

4 participants