-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] POC: implementation of a CoreText-based LocalGlyphRasterizer #10572
Conversation
… drawn area, better align to baseline. Includes code to extract glyph metrics, but the results don't match anything I'd expect so I'm not using them.
I wrote code to extract glyph metrics and glyph advances, but I think I must be misunderstanding something about what the I ended up just tweaking the metric "guesses" to work a little better -- I draw on a 40x40px bitmap and adjust the drawing position to get the glyph more in the middle. |
/cc @lilykaiser |
…izer. Thin C++ wrappers on C calls.
… set, it doesn't rasterize glyphs locally.
…y" string, plumb it out as far as the Renderer constructor.
@@ -0,0 +1,27 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing #pragma once
We also typically make sure that header files include all of the symbols they reference. Instead of defining all of the aliases in the header file, we can continue to define them where we need them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Maybe we don't need CFHandle at all? It seems like something we could replace with a portable "unique handle holder" or maybe just std::unique_ptr
with custom deleters?
Add pragma once Move instantiations of CFHandle down to where they're used (although a few are duplicated).
In my tests so far, I have yet to get CoreText to render anything differently based on the font weight changes.
I played around a little bit with passing a font descriptor through the portable code, but didn't end up with any ownership interface that felt right. I ended up falling back to just an optional "font family" string... which is a shame because it's so much more limited than it could be. But at least this approach will give Android/iOS/JS very similar interfaces -- and as limited as the "font family" interface is, it seems to be sufficient so far in the CJK case. I tested loading different fonts by name by just changing the Next I'll try hooking up a darwin equivalent of the font stack/font-weight heuristics we use on JS. I think that should be pretty straightforward. After that, I'll depend on someone more experienced with the iOS SDK to help finalize the bindings. /cc @akitchen |
I hooked up the font weights, but I'm not actually seeing any effect. For instance, I have |
#16253 and mapbox/mapbox-gl-native-ios#189 skirt this issue by relying on Core Text’s font matching API instead of rolling our own. |
This is an experiment in rasterizing glyphs locally using
CTLineCreateWithAttributedString
, for use with TinySDF.The basics seem to work. Look at render test failures on macos or ios to see the appearance of the locally rendered glyphs.
The guess-based glyph metrics I copied over from the JS implementation don't seem to be quite right. Instead of trying to work out a better guess, I'll look into just getting the metrics directly from CoreText.
There are several TODOs before this is ready for production:
image.mm
/cc @1ec5 @boundsj