Closed chinedufn closed 4 years ago
GlyphBrush
implements GlyphCruncher
which provides pixel_bounds
& glyph_bounds
.
Ohhh nice!
One things come to mine - minor so feel free to ignore
GlyphCruncher
nameThe name feels a little cutesy to me and doesn't necessarily describe what it is.
I know it's difficult to name since it's a grab bag of functionality.
I like how specs uses the Ext
suffix in WorldExt
- a trait that provides extra methods on a World
.
https://docs.rs/specs/0.16.0/specs/trait.WorldExt.html
So one idea is to rename GlyphCruncher
to GlyphBrushExt
Again - these are just thoughts that come to mind. I'm a fan of glyph-brush
so feel free to disagree!!
Thanks!!
Yep valid points about the name. We have GlyphCalculator
which can calculate layouts & bounds but isn't interested in vertices/drawing & GlyphBrush
which also does that to but is very much in to vertices.
So I have a trait for the common bits they can both do. Ideally called GlyphCalculator
but I'd already used that. So GlyphCruncher
...
I think of Ext as for additional functionality for certain situations / provided externally. I guess that's why it didn't come to mind. Maybe it's better anyway, I'm not 100% sure.
Open to more suggestions!
I'm looking to be able to look up the top-left and bottom-right corner for a text section.
This will allow me to do collision detection between a section and any other rectangle - such as the current mouse position.
The solution I have in mind (do let me know if you have a better one!) is
Call
process_queued
on all of my text sectionsCalculate the
SectionHash
of a text section that I want to look upLook it up in the
calculate_glyph_cache: FxHashMap<SectionHash, Glyphed<'font, V>>
It appears as if there is no way to access the
calculate_glyph_cache
from outside of theglyph_brush
module - which is problematic for me since I want to be able to access it from my crateQuestions
Is there a better solution to my problem that you have in mind?
If not - would there be any issue with exposing
calculate_glyph_cache
by reference? Happy to submit a PR.