From ac61b53c1639c2dd1fa9bf1dba2e06a1047b2291 Mon Sep 17 00:00:00 2001 From: Arno van Liere <46238387+arnovanliere@users.noreply.github.com> Date: Sun, 23 Aug 2026 09:45:47 +0200 Subject: [PATCH] =?UTF-8?q?fix(=F0=9F=90=9B):=20accept=20booleans=20in=20F?= =?UTF-8?q?ont.setSubpixel=20and=20Font.setEmbolden=20(#4011)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both are declared as `(value: boolean) => void` in the TypeScript API, and the CanvasKit backend forwards the boolean straight through. On native they were bound with a `double` parameter, so `JSIConverter` called `asNumber()` on the argument and a real boolean threw: Exception in HostFunction: Value is true, expected a number Binding them as `bool` routes through `JSIConverter`, which uses `asBool()`, matching the two neighbouring boolean setters (`setEmbeddedBitmaps` and `setLinearMetrics`) and the declared API. The `double` parameters date back to the typed-bindings migration (#3965), which preserved the previous `asNumber()` behaviour so as not to change semantics in a mechanical refactor. That kept the JS API unusable on native without casting the argument to a number. Co-authored-by: William Candillon --- packages/skia/cpp/api/JsiSkFont.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/skia/cpp/api/JsiSkFont.h b/packages/skia/cpp/api/JsiSkFont.h index 59a0e12938..23f22b4adf 100644 --- a/packages/skia/cpp/api/JsiSkFont.h +++ b/packages/skia/cpp/api/JsiSkFont.h @@ -161,15 +161,9 @@ class JsiSkFont : public JsiSkWrappingSharedPtrNativeObject { void setSize(double size) { getObject()->setSize(size); } - // The JS API declares booleans here, but the previous implementation read - // the arguments with asNumber() — keep accepting numbers. - void setEmbolden(double embolden) { - getObject()->setEmbolden(static_cast(embolden)); - } + void setEmbolden(bool embolden) { getObject()->setEmbolden(embolden); } - void setSubpixel(double subpixel) { - getObject()->setSubpixel(static_cast(subpixel)); - } + void setSubpixel(bool subpixel) { getObject()->setSubpixel(subpixel); } void setTypeface(std::variant> typeface) { getObject()->setTypeface(