fix(canvas2d): return TextMetrics for empty measureText - #150
Conversation
Pixi 8 CanvasTextSystem reads .width on empty remainder strings when letter-spacing is present. Returning without a metrics object crashes any Pixi Text on NativeScript Canvas.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The red AudioContext jobs are not from this diff.
The last The relevant job for this change is Build Native / Canvas iOS + visionOS. |
Problem
Pixi 8
CanvasTextSystem._drawLetterSpacingalways callscontext.measureText(remainder).width. When the remainder is"", NativeScript Canvas returned without constructing aTextMetricsobject, so.widththrew and anynew Text(...)crashed on iOS/tvOS.Change
Remove the
if (text_utf8_len == 0) return;guard. Empty strings go through the existing text engine/cache and return a metrics instance with width 0, matching browsers.Test plan
measureText("")is an object withwidth === 0Textwith default letter-spacing no longer throws on NativeScript CanvasDoes not include the concentric-radial Skia experiment; two-point conical already fades correctly on this stack.