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

Recover design coords from a hb_font_t #1865

Closed
matthiasclasen opened this issue Jul 25, 2019 · 14 comments · Fixed by #1905
Closed

Recover design coords from a hb_font_t #1865

matthiasclasen opened this issue Jul 25, 2019 · 14 comments · Fixed by #1905

Comments

@matthiasclasen
Copy link
Collaborator

I want to create a ui for font variations.

I have a hb_font_t. From that I can get the hb_face_t, and all the axis infos to set up sliders.

But there is currently no way for me to find the coords of the hb_font_t to set the sliders current value. hb_font_get_var_coords_normalized gives me something, but it does not obviously relate to the min/max/default values in the axis info.

@behdad
Copy link
Member

behdad commented Jul 26, 2019

Need to add hb_font_get_var_coords_design.

This is slightly problematic since in a future with avar2 table, converting back from normalized to design coords might not be unique...

@behdad
Copy link
Member

behdad commented Jul 26, 2019

I think I forced FreeType to add similar API and exposed them to the same dilemma... We don't currently keep the design coords. Got to save them so we can return. And yeah, no idea what to do if user called set_var_coords_normalized and later called get_var_coords_design.

@matthiasclasen
Copy link
Collaborator Author

matthiasclasen commented Jul 28, 2019

Note that the main problem is with initial values. Once I have my ui set up,the changes only flow from the sliders to the font, which is fine. The issue is what to set the sliders to the first time I see the hb_font_t.

In pango, I've reverted to opening the font with freetype and using FT_Get_MM_Var for now. But wanted to get away from that, and just go fontconfig -> fontname -> hb_blob_create_from_file.

Maybe the right answer is to make fontconfig add the design coords to the pattern.

@matthiasclasen matthiasclasen changed the title Recover coords from a hb_font_t Recover design coords from a hb_font_t Jul 28, 2019
@matthiasclasen
Copy link
Collaborator Author

And yeah, no idea what to do if user called set_var_coords_normalized and later called get_var_coords_design.

I would suggest to clear saved design coords when normalized coords are set from the outside, and only return design coords when you have them.

@behdad
Copy link
Member

behdad commented Jul 29, 2019

I would suggest to clear saved design coords when normalized coords are set from the outside, and only return design coords when you have them.

Right. But we don't have a (existing, clean, ..) way to return "not-representable".

@matthiasclasen
Copy link
Collaborator Author

Something like this?
/**

  • hb_font_get_var_coords_design:
  • Returns design coords that have been set with
  • hb_font_set_var_coords_design(). Will return %NULL
  • if normalized coords have been set directly with
  • hb_font_set_var_coords_normalized().
  • Return value is valid as long as variation coordinates of the font
  • are not modified.
  • Returns: (nullable): the design coords of the font
  • Since: 1.4.2
    */
    HB_EXTERN const float *
    hb_font_get_var_coords_design (hb_font_t *font,
    unsigned int coords_length);

@ebraminio
Copy link
Collaborator

ebraminio commented Aug 7, 2019

Do we need a separate API or what is done here #1890 is useful for this also as it is now able to convert back from normalized coordination to design in a hb_font_t?

@ebraminio
Copy link
Collaborator

ebraminio commented Aug 7, 2019

I mean I think we can store original design coordination but do simulation also with the API if we don't have original ones, if what the API promises isn't convenient enough.

@behdad
Copy link
Member

behdad commented Aug 13, 2019

If the transform is reversible, sure would be nice to return it.

@behdad
Copy link
Member

behdad commented Nov 9, 2021

Reopening to finalize this and mark non-experimental.

@behdad
Copy link
Member

behdad commented Nov 9, 2021

I thought about this in reference to #1914.

If we are to inject hb_font_set_ptem into ptsz axis automatically, should that be returned in the return value of this API or not? I feel like it should not, but that would be a user surprise. @matthiasclasen @drott ?

@drott
Copy link
Collaborator

drott commented Nov 10, 2021

If we are to inject hb_font_set_ptem into ptsz axis automatically

ptsz or opsz?

@behdad
Copy link
Member

behdad commented Nov 10, 2021

ptsz or opsz?

Right.

@behdad
Copy link
Member

behdad commented Nov 10, 2021

If we are to inject hb_font_set_ptem into opsz axis automatically, should that be returned in the return value of this API or not? I feel like it should not, but that would be a user surprise. @matthiasclasen @drott ?

Nevermind. See #1914 (comment)

@behdad behdad closed this as completed in 5b87c30 Jan 2, 2022
matthiasclasen pushed a commit to matthiasclasen/harfbuzz that referenced this issue Jan 7, 2022
Any remaining issue with the API will address later by deprecating it.

Fixes harfbuzz#1865
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.

4 participants