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

implement glyph_by_name method #27

Merged
merged 1 commit into from Apr 21, 2019
Merged

Conversation

@srijs
Copy link
Contributor

srijs commented Feb 8, 2019

This change implements looking up glyphs by their name, which is useful when dealing with fonts that may not have a cmap (in my case certain CFF files).

Implementing this outside fontkit, although possible, is quite cumbersome as I basically need to mirror all the platform-specific dependencies and compilation flags.

There's two rough edges at the moment that I'm happy to try and fix up if you're generally interested in this change. One being the FFI binding for CTFontGetGlyphWithName that should probably move into the core-text crate, and the other that there appears to be no simple way to do name-based lookup using the DirectWrite APIs.

Let me know what you think!

@srijs
Copy link
Contributor Author

srijs commented Feb 9, 2019

I've opened a PR against core-text over here: servo/core-foundation-rs#293

@rvolgers
Copy link

rvolgers commented Feb 17, 2019

Some notes for DirectWrite. Indeed it looks like there's no other way than parsing cff yourself...

https://docs.microsoft.com/en-us/windows/desktop/api/dwrite/nf-dwrite-idwritefontface-trygetfonttable

CFF:
https://docs.microsoft.com/en-us/typography/opentype/spec/cff

CFF2 (but these probably also have a cmap, so not relevant to the stated use case):
https://docs.microsoft.com/en-us/typography/opentype/spec/post
https://github.com/harfbuzz/harfbuzz/blob/70a52d6bd8c45630ca90e945fc4d716fe9114010/src/hb-ot-post-table.hh#L140

(Note: this is just a driveby comment since I happened to come across this issue.)

@@ -779,6 +801,11 @@ fn format_to_cg_color_space_and_image_format(format: Format) -> Option<(CGColorS
}
}

#[link(name = "CoreGraphics", kind = "framework")]
extern {

This comment has been minimized.

@pcwalton

pcwalton Feb 28, 2019

Collaborator

Looks like upstream has this method now; can we switch to using it?

This comment has been minimized.

@srijs

srijs Mar 5, 2019

Author Contributor

@pcwalton it's been merged, but it looks like core-text hasn't cut a new release yet. Is that something you could help out with?

This comment has been minimized.

@jdm

jdm Mar 11, 2019

Member

I'll publish a new version when servo/core-foundation-rs#294 is merged.

@srijs srijs force-pushed the srijs:feat/glyph-by-name branch from b2a7688 to fe1c949 Apr 8, 2019
@srijs
Copy link
Contributor Author

srijs commented Apr 8, 2019

@pcwalton updated the PR to use new functionality in core-text. Should be good to merge from my perspective.

@srijs
Copy link
Contributor Author

srijs commented Apr 8, 2019

Just got a report of a problem with the freetype loader over in srijs/rpdf#2, I‘ll have a go at fixing it later today!

@srijs srijs force-pushed the srijs:feat/glyph-by-name branch from fe1c949 to a9e0ea6 Apr 8, 2019
@srijs
Copy link
Contributor Author

srijs commented Apr 8, 2019

Should be all fixed now!

@pcwalton pcwalton merged commit dbe2181 into servo:master Apr 21, 2019
@srijs srijs deleted the srijs:feat/glyph-by-name branch May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.