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

glyph_brush_layout line metrics #165

Open
cjhowedev opened this issue Feb 25, 2023 · 2 comments
Open

glyph_brush_layout line metrics #165

cjhowedev opened this issue Feb 25, 2023 · 2 comments

Comments

@cjhowedev
Copy link

It would be nice to be able to retrieve something similar to DirectWrite's DWRITE_LINE_METRICS from glyph_brush_layout in addition to the actual glyph positions. This would allow us to more easily position inline content within the text, for example, a cursor for a text entry box. Right now, any inline content requires modifying the returned layout to make room for your cursor, and positioning the cursor for text input vertically is impossible.

@alexheretic
Copy link
Owner

With the returned Vec<SectionGlyph> you have positions of each glyph & the section-byte index for the char.

So if you know your cursor's section-byte index you can find a position to draw it. You can also infer various line metrics from same-y glyphs.

I wouldn't normally imagine moving the layout around to make room for a cursor, don't they usually just go between the glyphs? Custom inline non-glyph content, like a arbitrary rect, is not currently supported but I imagine could be added.

@cjhowedev
Copy link
Author

I guess this is just aggregating glyph metrics like ascent and descent across SectionGlyphs for each line. ab_glyph's ScaleFont has the metrics I was looking for, which I should be able to combine with SectionGlyph to calculate the line metrics on my own.

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

No branches or pull requests

2 participants