fUnderlinePosition, fUnderlineThickness missing in CanvasKit

21 views
Skip to first unread message

Micha

unread,
Mar 4, 2026, 8:30:24 AM (7 days ago) Mar 4
to skia-discuss
Hi all,
in Skia, SkFontMetrics provides underline information:

    SkScalar fUnderlineThickness; //!< underline thickness
    SkScalar fUnderlinePosition;  //!< distance from baseline to top of stroke, typically positive

We use these two scalars to draw underlined text (simply draw a line according to these two scalars) with Skia.
Since our drawing API is cross-platform and becomes implemented by Skia as well as by CanvasKit, we need to draw underlined text using CanvasKit, too. However, CanvasKit does not provide this information:

export interface FontMetrics {
    ascent: number;     // suggested space above the baseline. < 0
    descent: number;    // suggested space below the baseline. > 0
    leading: number;    // suggested spacing between descent of previous line and ascent of next line.
    bounds?: Rect;      // smallest rect containing all glyphs (relative to 0,0)
}

Could FontMetrics interface be extended to provide these two metrics? Is there a workaround to approximate them from font size, ascent and descent?

Thank you for any answer.
Michael

bungeman

unread,
Mar 10, 2026, 1:26:04 PM (21 hours ago) Mar 10
to skia-discuss

Micha

unread,
4:06 AM (6 hours ago) 4:06 AM
to skia-discuss
Thank you a lot,
that was very fast. I guess this fix will be available in the next official CanvasKit npm release?
Then we'll upgrade and use the new metrics provided.

Michael.

Reply all
Reply to author
Forward
0 new messages