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

[graphite] Fix shaping with varying font sizes #357

Merged
merged 2 commits into from
Feb 8, 2017
Merged

[graphite] Fix shaping with varying font sizes #357

merged 2 commits into from
Feb 8, 2017

Conversation

khaledhosny
Copy link
Collaborator

@khaledhosny khaledhosny commented Oct 30, 2016

See https://bugs.documentfoundation.org/show_bug.cgi?id=103403#c7

This is similar to commit 061105e for Core Text.

@khaledhosny
Copy link
Collaborator Author

This patch look big than it is actually it, because I couldn’t find a way to query grfont for its ppm so i had to store the x and y scale in the font user data.
cc @mhosken

ghost pushed a commit to LibreOffice/core that referenced this pull request Oct 31, 2016
Patch sent upstream:
harfbuzz/harfbuzz#357

Change-Id: I245509d386e83970e4b08bd2a4b20a590303025a
@behdad
Copy link
Member

behdad commented Oct 31, 2016

I suggest we create grfont at a fixed font size and scale the output. That's what we do for CoreText. Your current patch uses the font size at the time the grfont is created first. Right?

@behdad
Copy link
Member

behdad commented Oct 31, 2016

I should actually fix harfbuzz to recreate font data when font scale changes...

@khaledhosny
Copy link
Collaborator Author

I suggest we create grfont at a fixed font size and scale the output. That's what we do for CoreText. Your current patch uses the font size at the time the grfont is created first. Right?

Right. I was thinking what about size-specific adjustments (not sure Graphite has any), but then again I’ll be getting arbitrary ones with the current code.

Thinking about it again, may be keep the code in HarfBuzz the way it is and just set the font scale always to EM size at LibreOffice end and scale the output.

@behdad
Copy link
Member

behdad commented Oct 31, 2016

It's still an improvement to fix the code to shape at a fixed size and scale.

@khaledhosny
Copy link
Collaborator Author

I’m just concerned if someone is using this and is expecting size-specific adjustments or metrics, though it might not even be a valid concern. @mhosken what do you think?

@behdad
Copy link
Member

behdad commented Nov 1, 2016

Yeah I don't think graphite does size-specific shaping.

@mhosken
Copy link
Contributor

mhosken commented Nov 1, 2016

Firstly, Graphite doesn't do size related shaping. I think that the only tool in the LIbreOffice suite that would be at all interested in size related shaping is Impress, where screen rendering leads the way. In all other tools, printer rendering leads the way and that means that ideally shaping should use printer metrics rather than screen metrics. I know it renders everything twice (screen and printer), but I think I'm saying we don't need to worry about this.

@khaledhosny
Copy link
Collaborator Author

I now shape at UPEM, then scale the output afterwords. But I’m getting very large glyph advances now, and if I drop the scaling part everything is fine! No idea what is going on.

@khaledhosny
Copy link
Collaborator Author

OK, I think the bad advances I’m getting because hb_graphite2_get_advance() will use the font scale not the UPEM, not sure how to fix this.

@behdad
Copy link
Member

behdad commented Nov 8, 2016

Right... We should fix this properly then. I'll try to find time to do that.

@mhosken
Copy link
Contributor

mhosken commented Nov 8, 2016

If you want to switch hb over to working in design space at upem and then scaling the results, that makes life a tad easier in graphite since you can run without a gr_font. Passing NULL to gr_make_segment returns positions in design space.

@behdad
Copy link
Member

behdad commented Nov 8, 2016

If you want to switch hb over to working in design space at upem and then scaling the results, that makes life a tad easier in graphite since you can run without a gr_font. Passing NULL to gr_make_segment returns positions in design space.

Ok, that would work nicely when I add hb_face_get_canonical_font() [0].

[0] https://lists.freedesktop.org/archives/harfbuzz/2015-October/005174.html

@khaledhosny
Copy link
Collaborator Author

Thanks @mhosken for the suggestion, this seems to work now.

The font data is unused now, except for hb_graphite2_font_get_gr_font(), but I think this function makes no much sense now. Should I mark it deprecated and always return NULL?

@mhosken
Copy link
Contributor

mhosken commented Nov 11, 2016

Yes this looks fine. It's shame there is still all that boilerplate kicking around. If neither coretext nor graphite now have a font object, is it still needed? Just an idea.

@khaledhosny
Copy link
Collaborator Author

@behdad and @mhosken, should I merge this?

@khaledhosny khaledhosny changed the title [graphite] Fix shaping with varying font size [graphite] Fix shaping with varying font sizes Dec 7, 2016
It is unused after previous commit, hb_graphite2_font_get_gr_font()
makes no sense now so deprecating it.
@behdad
Copy link
Member

behdad commented Feb 8, 2017

Is this ready to merge?

@khaledhosny
Copy link
Collaborator Author

Yes.

@behdad behdad merged commit c8dfed8 into harfbuzz:master Feb 8, 2017
@khaledhosny khaledhosny deleted the graphite-scale branch March 22, 2017 22:55
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.

3 participants