You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thanks for this great library, really enjoying using it!
I'm trying to get the bounding boxes of each glyph in some text and getRectsForRange sounds like it would do exactly what I want:
(method) SkParagraph.getRectsForRange(start: number, end: number): SkRect[]
Returns the bounding boxes of the glyphs in the given range. This method requires the layout method to have been called first.
@param start — Start index of the range
@param end — End index of the range
According to that description I'd thought this function would return an array with the number of elements equivalent to the glyphs in the substring specified by the start and end index params, but instead I get either 1 or 2 array elements.
For example:
const text = 'simple';
const p = Skia.ParagraphBuilder.Make(paragraphStyle, fontMgr)
.pushStyle(textStyle)
.addText(text)
.pop()
.build();
p.layout(width);
const rects = p.getRectsForRange(0, text.length - 1);
// returns a single element array like [{ height: 19, width: 39.02000045776367, x: 0, y: 0.25 }]
Am I using this wrong, or misunderstanding how it's supposed to work? Appreciate anyone taking a look!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First, thanks for this great library, really enjoying using it!
I'm trying to get the bounding boxes of each glyph in some text and
getRectsForRange
sounds like it would do exactly what I want:According to that description I'd thought this function would return an array with the number of elements equivalent to the glyphs in the substring specified by the
start
andend
index params, but instead I get either 1 or 2 array elements.For example:
Am I using this wrong, or misunderstanding how it's supposed to work? Appreciate anyone taking a look!
Beta Was this translation helpful? Give feedback.
All reactions