alexheretic / ab-glyph

Rust API for loading, scaling, positioning and rasterizing OpenType font glyphs
Apache License 2.0
372 stars 24 forks source link

Returning partially clipped glyphs #20

Closed chinedufn closed 4 years ago

chinedufn commented 4 years ago

Last I checked a year ago, if a glyph was partially outside of the bounds for the text section it would not be included when calling process_queued.

I’d like to be able to instead have these partially clipped glyphs returned, with the glyph’s texture and size bounds adjusted to only encompass the part that is within the text bounds.

This would make things such as scrolling windows easier as you wouldn’t need to handle partial clipping at the edges when scrolling yourself.

Would there be any downsides to this design? I can’t think of any but I’m not familiar with the reason that it isn’t done that way currently.

Thanks!

alexheretic commented 4 years ago

I think this isn't relevant to ab_glyph, this lib doesn't provide any concept of sections or layout.

For glyph_brush_layout it already does this vertically, for multi-line layouts it doesn't allow horizontal partial glyphs, which is kind of the job of a paragraph algorithm. For single line layouts you can have horizontal overlap too. Raise an issue in https://github.com/alexheretic/glyph-brush if you'd like to discuss those.

chinedufn commented 4 years ago

Wow I actually thought I opened this in glyph brush, sorry!

chinedufn commented 4 years ago

All I need is vertical so I’m good to go thanks!