Open SamuelScheit opened 3 weeks ago
Nice, we have some tests for the paragraph API available at https://github.com/Shopify/react-native-skia/blob/main/packages/skia/src/renderer/__tests__/e2e/Paragraphs.spec.tsx Any tests you could suggest that would highlight the bug fix?
I've tried to use the paragraph api on the web, however the paragraph didn't render and show up on the canvas. After debugging I found out that
paragraph.getHeight()
returned0
and thestyle.textStyle.fontSize
was-1
andstyle.textStyle.fontFamilies
was undefined.I've tried to directly create the style using
new CanvasKit.ParagraphStyle(...)
and that returned a style object with correct fontSize/fontFamily and when used also returned the correct paragraph height.That means the issue lies in the
JsiSkParagraphStyle.toParagraphStyle()
function:https://github.com/Shopify/react-native-skia/blob/4a2d7afc0fa547aee9938a0339594b88c3618d20/packages/skia/src/skia/web/JsiSkParagraphStyle.ts#L7-L65
Inside of the
toParagraphStyle()
function I've changed the assignments from strutStyle to textStyle (except forleading
,forceStrutHeight
andstrutEnabled
) and also added some properties liketextDecoration
,backgroundColor
andshadows
.This fixed the issue and now the paragraph correctly renders: