Does SKPaint own the associated SKTypeface #3127
Unanswered
DanTravison
asked this question in
Q&A
Replies: 2 comments
-
The paint object does not own the typeface. Typeface are typically singleton objects that can live forever if need be. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks, that answers my question. I assume that dispose pattern should be honored when switching between fonts, correct? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a collection of glyphs that I want to measure and cache for rendering. A given glyph as a font family and point size.
At render time, I need the glyph width and bounding box, the associated SKTypeface and selected values from SKFontMetrics.
The user controls the placement and number of glyphs so the OnPaintSurface call will be switching between typefaces for each glyph render.
Ideally, I'd like to cache the SKTypeface at measure time and use it at render time but it's not clear if this is safe to do because the docs don't indicate ownership of the SKPaint.Typeface value. In other words, does disposing the SKPaint also dispose the SKPaint.Typeface?
So, do I need to create an SKTypeface whenever I need an SKPaint or can I cache the SKTypeface at measure time and use it at render time?
I'm currently using SkiaSharp.Views.Maui.Controls 2.88.9.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions