The cairo "toy" text API is non-functional through node-gtk's bundled cairo bindings. Context.textExtents() and Context.fontExtents() return an empty object {} (none of the width / height / x_advance / ascent / … fields), so text can't be measured, and showText() renders nothing. PangoCairo works and is currently the only way to measure/draw text.
Minimal repro
import cairo from 'gi:cairo-1.0'
const surface = new cairo.ImageSurface(cairo.Format.ARGB32, 200, 100)
const cr = new cairo.Context(surface)
cr.selectFontFace('sans-serif', cairo.FontSlant.NORMAL, cairo.FontWeight.NORMAL)
cr.setFontSize(24)
console.log('textExtents:', JSON.stringify(cr.textExtents('Hello World')))
console.log('fontExtents:', JSON.stringify(cr.fontExtents()))
Actual
textExtents: {}
fontExtents: {}
showText('Hello') likewise produces no glyphs.
Expected
textExtents('Hello World') returns a cairo_text_extents_t-shaped object with non-zero width / height / x_advance / x_bearing / …
fontExtents() returns ascent / descent / height / max_x_advance / max_y_advance
showText() renders glyphs.
Looks like the cairo_text_extents_t / cairo_font_extents_t out-structs aren't being converted to JS (an empty object is returned regardless of input).
Environment
- node-gtk
3.0.0 (commit 9741a54)
- Node.js
v22.22.3, ESM (node --import node-gtk/register)
- GTK
4.22.4, Linux x86_64
The cairo "toy" text API is non-functional through node-gtk's bundled cairo bindings.
Context.textExtents()andContext.fontExtents()return an empty object{}(none of thewidth/height/x_advance/ascent/ … fields), so text can't be measured, andshowText()renders nothing. PangoCairo works and is currently the only way to measure/draw text.Minimal repro
Actual
showText('Hello')likewise produces no glyphs.Expected
textExtents('Hello World')returns acairo_text_extents_t-shaped object with non-zerowidth/height/x_advance/x_bearing/ …fontExtents()returnsascent/descent/height/max_x_advance/max_y_advanceshowText()renders glyphs.Looks like the
cairo_text_extents_t/cairo_font_extents_tout-structs aren't being converted to JS (an empty object is returned regardless of input).Environment
3.0.0(commit9741a54)v22.22.3, ESM (node --import node-gtk/register)4.22.4, Linux x86_64