@shopify/react-native-skia 2.8.0 → 2.9.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +10 -4
- package/android/cpp/rnskia-android/OpenGLContext.h +29 -3
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +9 -2
- package/android/cpp/rnskia-android/gl/Context.h +3 -0
- package/android/cpp/rnskia-android/gl/Surface.h +1 -1
- package/cpp/api/JsiSkiaContext.h +4 -0
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +330 -0
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/include/dawn/dawn_version.h +41 -0
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +86 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +369 -0
- package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2844 -0
- package/cpp/dawn/include/tint/tint.h +90 -0
- package/cpp/dawn/include/webgpu/webgpu.h +4987 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +10080 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/rnskia/RNSkView.h +6 -0
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
- package/lib/commonjs/Platform/Platform.js +5 -2
- package/lib/commonjs/Platform/Platform.js.map +1 -1
- package/lib/commonjs/Platform/Platform.web.js +8 -7
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/skia/core/Font.d.ts +21 -6
- package/lib/commonjs/skia/core/Font.js +24 -4
- package/lib/commonjs/skia/core/Font.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.d.ts +5 -4
- package/lib/commonjs/skia/types/Data/Data.js +7 -1
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +43 -2
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/Platform/Platform.js +6 -3
- package/lib/module/Platform/Platform.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +9 -8
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/skia/core/Font.d.ts +21 -6
- package/lib/module/skia/core/Font.js +26 -5
- package/lib/module/skia/core/Font.js.map +1 -1
- package/lib/module/skia/types/Data/Data.d.ts +5 -4
- package/lib/module/skia/types/Data/Data.js +5 -0
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/module/skia/web/JsiSkFont.js +44 -3
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Data/Data.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Data/Data.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/src/skia/core/Font.d.ts +21 -6
- package/lib/typescript/src/skia/types/Data/Data.d.ts +5 -4
- package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -1
- package/libs/.graphite +1 -0
- package/package.json +13 -7
- package/react-native-skia.podspec +18 -10
- package/src/Platform/Platform.ts +6 -7
- package/src/Platform/Platform.web.tsx +9 -8
- package/src/skia/core/Font.ts +34 -13
- package/src/skia/types/Data/Data.ts +14 -4
- package/src/skia/web/JsiSkFont.ts +48 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_Skia","_types","_Platform","_Typeface","defaultFontSize","useFont","font","size","onError","typeface","useTypeface","useMemo","Skia","Font","exports","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","FontSlant","Italic","Oblique","Upright","weight","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","families","Set","i","countFamilies","add","getFamilyName","Array","from","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","map","typefaceToLoad","Data","fromURI","Platform","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","useState","useEffect","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\nconst defaultFontSize = 14;\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size = defaultFontSize,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface) {\n return Skia.Font(typeface, size);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\
|
|
1
|
+
{"version":3,"names":["_react","require","_Skia","_types","_Platform","_Typeface","defaultFontSize","useFont","font","size","onError","typeface","useTypeface","useMemo","Skia","Font","exports","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","FontSlant","Italic","Oblique","Upright","weight","FontWeight","Normal","Bold","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","families","Set","i","countFamilies","add","getFamilyName","Array","from","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","map","typefaceToLoad","Data","fromURI","Platform","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","useState","useEffect","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant, FontWeight } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\nconst defaultFontSize = 14;\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size = defaultFontSize,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface) {\n return Skia.Font(typeface, size);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\n/**\n * React Native style font slant, as found in the `fontStyle` property of\n * `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.\n */\nexport type RNFontSlant = \"normal\" | \"italic\" | \"oblique\" | FontSlant;\n\n/**\n * React Native style font weight, as found in the `fontWeight` property of\n * `TextStyle`. Numeric weights such as the {@link FontWeight} enum values\n * used by the Paragraph API are accepted as well.\n */\nexport type RNFontWeight =\n | \"normal\"\n | \"bold\"\n | \"100\"\n | \"200\"\n | \"300\"\n | \"400\"\n | \"500\"\n | \"600\"\n | \"700\"\n | \"800\"\n | \"900\"\n | FontWeight;\n\n/**\n * Font style accepted by {@link matchFont}.\n * `fontStyle` and `fontWeight` accept both the React Native string values\n * and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same\n * values can be shared with the Paragraph API.\n */\nexport interface RNFontStyle {\n fontFamily: string;\n fontSize: number;\n fontStyle: RNFontSlant;\n fontWeight: RNFontWeight;\n}\n\nconst defaultFontStyle: RNFontStyle = {\n fontFamily: \"System\",\n fontSize: defaultFontSize,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n};\n\nconst slant = (s: RNFontSlant): FontSlant => {\n if (typeof s === \"number\") {\n return s;\n } else if (s === \"italic\") {\n return FontSlant.Italic;\n } else if (s === \"oblique\") {\n return FontSlant.Oblique;\n } else {\n return FontSlant.Upright;\n }\n};\n\nconst weight = (fontWeight: RNFontWeight): FontWeight => {\n switch (fontWeight) {\n case \"normal\":\n return FontWeight.Normal;\n case \"bold\":\n return FontWeight.Bold;\n default:\n return typeof fontWeight === \"number\"\n ? fontWeight\n : (parseInt(fontWeight, 10) as FontWeight);\n }\n};\n\nexport const matchFont = (\n inputStyle: Partial<RNFontStyle> = {},\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const fontStyle = {\n ...defaultFontStyle,\n ...inputStyle,\n };\n const style = {\n weight: weight(fontStyle.fontWeight),\n width: 5,\n slant: slant(fontStyle.fontStyle),\n };\n const typeface = fontMgr.matchFamilyStyle(fontStyle.fontFamily, style);\n return Skia.Font(typeface, fontStyle.fontSize);\n};\n\nexport const listFontFamilies = (\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const families = new Set<string>();\n for (let i = 0; i < fontMgr.countFamilies(); i++) {\n families.add(fontMgr.getFamilyName(i));\n }\n return Array.from(families);\n};\n\nconst loadTypefaces = (typefacesToLoad: Record<string, DataModule[]>) => {\n const promises = Object.keys(typefacesToLoad).flatMap((familyName) => {\n return typefacesToLoad[familyName].map((typefaceToLoad) => {\n return Skia.Data.fromURI(Platform.resolveAsset(typefaceToLoad)).then(\n (data) => {\n const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data);\n if (tf === null) {\n throw new Error(`Couldn't create typeface for ${familyName}`);\n }\n return [familyName, tf] as const;\n }\n );\n });\n });\n return Promise.all(promises);\n};\n\nexport const useFonts = (sources: Record<string, DataModule[]>) => {\n const [fontMgr, setFontMgr] = useState<null | SkTypefaceFontProvider>(null);\n\n useEffect(() => {\n loadTypefaces(sources).then((result) => {\n const fMgr = Skia.TypefaceFontProvider.Make();\n result.forEach(([familyName, typeface]) => {\n fMgr.registerFont(typeface, familyName);\n });\n setFontMgr(fMgr);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return fontMgr;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AAGA,IAAAI,SAAA,GAAAJ,OAAA;AATA;;AAWA,MAAMK,eAAe,GAAG,EAAE;;AAE1B;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CACrBC,IAAqB,EACrBC,IAAI,GAAGH,eAAe,EACtBI,OAA8B,KAC3B;EACH,MAAMC,QAAQ,GAAG,IAAAC,qBAAW,EAACJ,IAAI,EAAEE,OAAO,CAAC;EAC3C,OAAO,IAAAG,cAAO,EAAC,MAAM;IACnB,IAAIF,QAAQ,EAAE;MACZ,OAAOG,UAAI,CAACC,IAAI,CAACJ,QAAQ,EAAEF,IAAI,CAAC;IAClC,CAAC,MAAM;MACL,OA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AAIG,KAAK,CAAC,gCAAgCZ,UAAU,EAAE,CAAC;QAC/D;QACA,OAAO,CAACA,UAAU,EAAES,EAAE,CAAC;MACzB,CACF,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOI,OAAO,CAACC,GAAG,CAAClB,QAAQ,CAAC;AAC9B,CAAC;AAEM,MAAMmB,QAAQ,GAAIC,OAAqC,IAAK;EACjE,MAAM,CAACrC,OAAO,EAAEsC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAgC,IAAI,CAAC;EAE3E,IAAAC,gBAAS,EAAC,MAAM;IACdzB,aAAa,CAACsB,OAAO,CAAC,CAACT,IAAI,CAAEa,MAAM,IAAK;MACtC,MAAMC,IAAI,GAAG/D,UAAI,CAACgE,oBAAoB,CAACC,IAAI,CAAC,CAAC;MAC7CH,MAAM,CAACI,OAAO,CAAC,CAAC,CAACxB,UAAU,EAAE7C,QAAQ,CAAC,KAAK;QACzCkE,IAAI,CAACI,YAAY,CAACtE,QAAQ,EAAE6C,UAAU,CAAC;MACzC,CAAC,CAAC;MACFiB,UAAU,CAACI,IAAI,CAAC;IAClB,CAAC,CAAC;IACF;EACF,CAAC,EAAE,EAAE,CAAC;EACN,OAAO1C,OAAO;AAChB,CAAC;AAACnB,OAAA,CAAAuD,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
2
2
|
export type SkData = SkJSIInstance<"Data">;
|
|
3
3
|
type RNModule = number;
|
|
4
|
-
type ESModule = {
|
|
5
|
-
__esModule: true;
|
|
6
|
-
default: string;
|
|
7
|
-
};
|
|
8
4
|
type MetroAsset = {
|
|
9
5
|
uri: string;
|
|
10
6
|
width: number;
|
|
11
7
|
height: number;
|
|
12
8
|
};
|
|
9
|
+
type ESModule = {
|
|
10
|
+
__esModule: true;
|
|
11
|
+
default: RNModule | MetroAsset | string;
|
|
12
|
+
};
|
|
13
13
|
export type DataModule = RNModule | ESModule | MetroAsset;
|
|
14
14
|
export type DataSource = DataModule | string | Uint8Array;
|
|
15
15
|
export type DataSourceParam = DataSource | null | undefined;
|
|
16
16
|
export declare const isRNModule: (mod: DataModule) => mod is RNModule;
|
|
17
|
+
export declare const unwrapModule: (mod: DataModule) => RNModule | MetroAsset | string;
|
|
17
18
|
export {};
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isRNModule = void 0;
|
|
6
|
+
exports.unwrapModule = exports.isRNModule = void 0;
|
|
7
7
|
const isRNModule = mod => typeof mod === "number";
|
|
8
|
+
|
|
9
|
+
// Since Expo SDK 52, on web, require() may return an ES module interop
|
|
10
|
+
// object ({ default: <asset> }) instead of the asset itself.
|
|
11
|
+
// See https://github.com/Shopify/react-native-skia/issues/2784
|
|
8
12
|
exports.isRNModule = isRNModule;
|
|
13
|
+
const unwrapModule = mod => typeof mod === "object" && mod !== null && "default" in mod ? mod.default : mod;
|
|
14
|
+
exports.unwrapModule = unwrapModule;
|
|
9
15
|
//# sourceMappingURL=Data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isRNModule","mod","exports"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype
|
|
1
|
+
{"version":3,"names":["isRNModule","mod","exports","unwrapModule","default"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype MetroAsset = {\n uri: string;\n width: number;\n height: number;\n};\ntype ESModule = {\n __esModule: true;\n default: RNModule | MetroAsset | string;\n};\n\nexport type DataModule = RNModule | ESModule | MetroAsset;\nexport type DataSource = DataModule | string | Uint8Array;\nexport type DataSourceParam = DataSource | null | undefined;\n\nexport const isRNModule = (mod: DataModule): mod is RNModule =>\n typeof mod === \"number\";\n\n// Since Expo SDK 52, on web, require() may return an ES module interop\n// object ({ default: <asset> }) instead of the asset itself.\n// See https://github.com/Shopify/react-native-skia/issues/2784\nexport const unwrapModule = (\n mod: DataModule\n): RNModule | MetroAsset | string =>\n typeof mod === \"object\" && mod !== null && \"default\" in mod\n ? mod.default\n : mod;\n"],"mappings":";;;;;;AAmBO,MAAMA,UAAU,GAAIC,GAAe,IACxC,OAAOA,GAAG,KAAK,QAAQ;;AAEzB;AACA;AACA;AAAAC,OAAA,CAAAF,UAAA,GAAAA,UAAA;AACO,MAAMG,YAAY,GACvBF,GAAe,IAEf,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,KAAK,IAAI,IAAI,SAAS,IAAIA,GAAG,GACvDA,GAAG,CAACG,OAAO,GACXH,GAAG;AAACC,OAAA,CAAAC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ import { JsiSkRect } from "./JsiSkRect";
|
|
|
5
5
|
import { JsiSkTypeface } from "./JsiSkTypeface";
|
|
6
6
|
export declare class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
7
7
|
constructor(CanvasKit: CanvasKit, ref: Font);
|
|
8
|
-
measureText(
|
|
8
|
+
measureText(text: string, paint?: SkPaint | undefined): SkRect;
|
|
9
9
|
getTextWidth(text: string, paint?: SkPaint | undefined): number;
|
|
10
10
|
getMetrics(): {
|
|
11
11
|
ascent: number;
|
|
@@ -13,8 +13,49 @@ class JsiSkFont extends _Host.HostObject {
|
|
|
13
13
|
constructor(CanvasKit, ref) {
|
|
14
14
|
super(CanvasKit, ref, "Font");
|
|
15
15
|
}
|
|
16
|
-
measureText(
|
|
17
|
-
|
|
16
|
+
measureText(text, paint) {
|
|
17
|
+
// CanvasKit doesn't expose SkFont::measureText directly, so we polyfill
|
|
18
|
+
// it: for each glyph we take its ink bounds (relative to its own origin),
|
|
19
|
+
// offset it by the accumulated advance, and union the results. This
|
|
20
|
+
// matches the bounds computed natively by SkFont::measureText.
|
|
21
|
+
const glyphs = this.ref.getGlyphIDs(text);
|
|
22
|
+
if (glyphs.length === 0) {
|
|
23
|
+
return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));
|
|
24
|
+
}
|
|
25
|
+
const skPaint = paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : null;
|
|
26
|
+
// Flattened rectangles: 4 floats (left, top, right, bottom) per glyph.
|
|
27
|
+
const bounds = this.ref.getGlyphBounds(glyphs, skPaint);
|
|
28
|
+
const advances = this.ref.getGlyphWidths(glyphs, skPaint);
|
|
29
|
+
let left = 0;
|
|
30
|
+
let top = 0;
|
|
31
|
+
let right = 0;
|
|
32
|
+
let bottom = 0;
|
|
33
|
+
let isEmpty = true;
|
|
34
|
+
let xPos = 0;
|
|
35
|
+
for (let i = 0; i < glyphs.length; i++) {
|
|
36
|
+
const l = bounds[i * 4] + xPos;
|
|
37
|
+
const t = bounds[i * 4 + 1];
|
|
38
|
+
const r = bounds[i * 4 + 2] + xPos;
|
|
39
|
+
const b = bounds[i * 4 + 3];
|
|
40
|
+
xPos += advances[i];
|
|
41
|
+
// Skip empty glyph bounds (e.g. whitespace), like SkRect::join does.
|
|
42
|
+
if (l >= r || t >= b) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (isEmpty) {
|
|
46
|
+
left = l;
|
|
47
|
+
top = t;
|
|
48
|
+
right = r;
|
|
49
|
+
bottom = b;
|
|
50
|
+
isEmpty = false;
|
|
51
|
+
} else {
|
|
52
|
+
left = Math.min(left, l);
|
|
53
|
+
top = Math.min(top, t);
|
|
54
|
+
right = Math.max(right, r);
|
|
55
|
+
bottom = Math.max(bottom, b);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.CanvasKit.LTRBRect(left, top, right, bottom));
|
|
18
59
|
}
|
|
19
60
|
getTextWidth(text, paint) {
|
|
20
61
|
const ids = this.getGlyphIDs(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Host","require","_JsiSkPaint","_JsiSkPoint","_JsiSkRect","_JsiSkTypeface","JsiSkFont","HostObject","constructor","CanvasKit","ref","measureText","_text","_paint","throwNotImplementedOnRNWeb","getTextWidth","text","paint","ids","getGlyphIDs","widths","getGlyphWidths","reduce","a","b","getMetrics","result","ascent","descent","leading","bounds","JsiSkRect","undefined","str","numCodePoints","glyphs","JsiSkPaint","fromValue","getGlyphIntercepts","positions","top","bottom","map","p","Array","from","JsiSkPoint","flat","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","JsiSkTypeface","setEdging","edging","getEnum","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face","exports"],"sources":["JsiSkFont.ts"],"sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, getEnum, throwNotImplementedOnRNWeb } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(_text: string, _paint?: SkPaint | undefined) {\n return throwNotImplementedOnRNWeb<SkRect>();\n }\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [\n ...this.ref.getGlyphWidths(\n glyphs,\n paint ? JsiSkPaint.fromValue(paint) : null\n ),\n ];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(getEnum(this.CanvasKit, \"FontEdging\", edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(getEnum(this.CanvasKit, \"FontHinting\", hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);\n }\n}\n"],"mappings":";;;;;;AAYA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEO,MAAMK,SAAS,SAASC,gBAAU,CAAiC;EACxEC,WAAWA,CAACC,SAAoB,EAAEC,GAAS,EAAE;IAC3C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,MAAM,CAAC;EAC/B;EAEAC,WAAWA,CAACC,KAAa,EAAEC,MAA4B,EAAE;IACvD,OAAO,IAAAC,gCAA0B,EAAS,CAAC;EAC7C;EAEAC,YAAYA,CAACC,IAAY,EAAEC,KAA2B,EAAE;IACtD,MAAMC,GAAG,GAAG,IAAI,CAACC,WAAW,CAACH,IAAI,CAAC;IAClC,MAAMI,MAAM,GAAG,IAAI,CAACC,cAAc,CAACH,GAAG,EAAED,KAAK,CAAC;IAC9C,OAAOG,MAAM,CAACE,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,EAAE,CAAC,CAAC;EAC1C;EAEAC,UAAUA,CAAA,EAAG;IACX,MAAMC,MAAM,GAAG,IAAI,CAAChB,GAAG,CAACe,UAAU,CAAC,CAAC;IACpC,OAAO;MACLE,MAAM,EAAED,MAAM,CAACC,MAAM;MACrBC,OAAO,EAAEF,MAAM,CAACE,OAAO;MACvBC,OAAO,EAAEH,MAAM,CAACG,OAAO;MACvBC,MAAM,EAAEJ,MAAM,CAACI,MAAM,GACjB,IAAIC,oBAAS,CAAC,IAAI,CAACtB,SAAS,EAAEiB,MAAM,CAACI,MAAM,CAAC,GAC5CE;IACN,CAAC;EACH;EAEAb,WAAWA,CAACc,GAAW,EAAEC,aAAsB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3,"names":["_Host","require","_JsiSkPaint","_JsiSkPoint","_JsiSkRect","_JsiSkTypeface","JsiSkFont","HostObject","constructor","CanvasKit","ref","measureText","text","paint","glyphs","getGlyphIDs","length","JsiSkRect","XYWHRect","skPaint","JsiSkPaint","fromValue","bounds","getGlyphBounds","advances","getGlyphWidths","left","top","right","bottom","isEmpty","xPos","i","l","t","r","b","Math","min","max","LTRBRect","getTextWidth","ids","widths","reduce","a","getMetrics","result","ascent","descent","leading","undefined","str","numCodePoints","getGlyphIntercepts","positions","map","p","Array","from","JsiSkPoint","flat","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","JsiSkTypeface","setEdging","edging","getEnum","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face","exports"],"sources":["JsiSkFont.ts"],"sourcesContent":["import type { CanvasKit, Font, Paint } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, getEnum } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(text: string, paint?: SkPaint | undefined): SkRect {\n // CanvasKit doesn't expose SkFont::measureText directly, so we polyfill\n // it: for each glyph we take its ink bounds (relative to its own origin),\n // offset it by the accumulated advance, and union the results. This\n // matches the bounds computed natively by SkFont::measureText.\n const glyphs = this.ref.getGlyphIDs(text);\n if (glyphs.length === 0) {\n return new JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));\n }\n const skPaint = paint ? JsiSkPaint.fromValue<Paint>(paint) : null;\n // Flattened rectangles: 4 floats (left, top, right, bottom) per glyph.\n const bounds = this.ref.getGlyphBounds(glyphs, skPaint);\n const advances = this.ref.getGlyphWidths(glyphs, skPaint);\n let left = 0;\n let top = 0;\n let right = 0;\n let bottom = 0;\n let isEmpty = true;\n let xPos = 0;\n for (let i = 0; i < glyphs.length; i++) {\n const l = bounds[i * 4] + xPos;\n const t = bounds[i * 4 + 1];\n const r = bounds[i * 4 + 2] + xPos;\n const b = bounds[i * 4 + 3];\n xPos += advances[i];\n // Skip empty glyph bounds (e.g. whitespace), like SkRect::join does.\n if (l >= r || t >= b) {\n continue;\n }\n if (isEmpty) {\n left = l;\n top = t;\n right = r;\n bottom = b;\n isEmpty = false;\n } else {\n left = Math.min(left, l);\n top = Math.min(top, t);\n right = Math.max(right, r);\n bottom = Math.max(bottom, b);\n }\n }\n return new JsiSkRect(\n this.CanvasKit,\n this.CanvasKit.LTRBRect(left, top, right, bottom)\n );\n }\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [\n ...this.ref.getGlyphWidths(\n glyphs,\n paint ? JsiSkPaint.fromValue(paint) : null\n ),\n ];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(getEnum(this.CanvasKit, \"FontEdging\", edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(getEnum(this.CanvasKit, \"FontHinting\", hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);\n }\n}\n"],"mappings":";;;;;;AAYA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEO,MAAMK,SAAS,SAASC,gBAAU,CAAiC;EACxEC,WAAWA,CAACC,SAAoB,EAAEC,GAAS,EAAE;IAC3C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,MAAM,CAAC;EAC/B;EAEAC,WAAWA,CAACC,IAAY,EAAEC,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IAAI,CAAC9E,GAAG,CAAC6E,WAAW,CAACC,IAAI,GAAGpB,4BAAa,CAAC/C,SAAS,CAACmE,IAAI,CAAC,GAAG,IAAI,CAAC;EACnE;AACF;AAACC,OAAA,CAAAnF,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Image, PixelRatio, Platform as RNPlatform, findNodeHandle, View } from "react-native";
|
|
2
|
-
import { isRNModule } from "../skia/types";
|
|
2
|
+
import { isRNModule, unwrapModule } from "../skia/types";
|
|
3
3
|
export const Platform = {
|
|
4
4
|
OS: RNPlatform.OS,
|
|
5
5
|
PixelRatio: PixelRatio.get(),
|
|
6
6
|
resolveAsset: source => {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const asset = unwrapModule(source);
|
|
8
|
+
if (typeof asset === "string") {
|
|
9
|
+
return asset;
|
|
10
|
+
}
|
|
11
|
+
return isRNModule(asset) ? Image.resolveAssetSource(asset).uri : asset.uri;
|
|
9
12
|
},
|
|
10
13
|
findNodeHandle,
|
|
11
14
|
View
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Image","PixelRatio","Platform","RNPlatform","findNodeHandle","View","isRNModule","OS","get","resolveAsset","source","
|
|
1
|
+
{"version":3,"names":["Image","PixelRatio","Platform","RNPlatform","findNodeHandle","View","isRNModule","unwrapModule","OS","get","resolveAsset","source","asset","resolveAssetSource","uri"],"sources":["Platform.ts"],"sourcesContent":["import {\n Image,\n PixelRatio,\n Platform as RNPlatform,\n findNodeHandle,\n View,\n} from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule, unwrapModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\nexport const Platform: IPlatform = {\n OS: RNPlatform.OS,\n PixelRatio: PixelRatio.get(),\n resolveAsset: (source: DataModule) => {\n const asset = unwrapModule(source);\n if (typeof asset === \"string\") {\n return asset;\n }\n return isRNModule(asset) ? Image.resolveAssetSource(asset).uri : asset.uri;\n },\n findNodeHandle,\n View,\n};\n"],"mappings":"AAAA,SACEA,KAAK,EACLC,UAAU,EACVC,QAAQ,IAAIC,UAAU,EACtBC,cAAc,EACdC,IAAI,QACC,cAAc;AAGrB,SAASC,UAAU,EAAEC,YAAY,QAAQ,eAAe;AAIxD,OAAO,MAAML,QAAmB,GAAG;EACjCM,EAAE,EAAEL,UAAU,CAACK,EAAE;EACjBP,UAAU,EAAEA,UAAU,CAACQ,GAAG,CAAC,CAAC;EAC5BC,YAAY,EAAGC,MAAkB,IAAK;IACpC,MAAMC,KAAK,GAAGL,YAAY,CAACI,MAAM,CAAC;IAClC,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOA,KAAK;IACd;IACA,OAAON,UAAU,CAACM,KAAK,CAAC,GAAGZ,KAAK,CAACa,kBAAkB,CAACD,KAAK,CAAC,CAACE,GAAG,GAAGF,KAAK,CAACE,GAAG;EAC5E,CAAC;EACDV,cAAc;EACdC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
|
-
import { isRNModule } from "../skia/types";
|
|
2
|
+
import { isRNModule, unwrapModule } from "../skia/types";
|
|
3
3
|
// Layout is observed by the views themselves (see SkiaPictureView.web.tsx):
|
|
4
4
|
// this shim only reproduces react-native-web's default View styling.
|
|
5
5
|
const View = ({
|
|
@@ -37,8 +37,12 @@ export const Platform = {
|
|
|
37
37
|
PixelRatio: typeof window !== "undefined" ? window.devicePixelRatio : 1,
|
|
38
38
|
// window is not defined on node
|
|
39
39
|
resolveAsset: source => {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const asset = unwrapModule(source);
|
|
41
|
+
if (typeof asset === "string") {
|
|
42
|
+
return asset;
|
|
43
|
+
}
|
|
44
|
+
if (isRNModule(asset)) {
|
|
45
|
+
if (typeof require === "function") {
|
|
42
46
|
const {
|
|
43
47
|
getAssetByID
|
|
44
48
|
} = require("react-native/Libraries/Image/AssetRegistry");
|
|
@@ -46,16 +50,13 @@ export const Platform = {
|
|
|
46
50
|
httpServerLocation,
|
|
47
51
|
name,
|
|
48
52
|
type
|
|
49
|
-
} = getAssetByID(
|
|
53
|
+
} = getAssetByID(asset);
|
|
50
54
|
const uri = `${httpServerLocation}/${name}.${type}`;
|
|
51
55
|
return uri;
|
|
52
56
|
}
|
|
53
57
|
throw new Error("Asset source is a number - this is not supported on the web");
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
return source.uri;
|
|
57
|
-
}
|
|
58
|
-
return source.default;
|
|
59
|
+
return asset.uri;
|
|
59
60
|
},
|
|
60
61
|
findNodeHandle: () => {
|
|
61
62
|
throw new Error("findNodeHandle is not supported on the web");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","isRNModule","View","children","style","rawStyle","cssStyles","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","textDecoration","zIndex","createElement","Platform","OS","PixelRatio","window","devicePixelRatio","resolveAsset","source","require","getAssetByID","httpServerLocation","name","type","uri","Error","
|
|
1
|
+
{"version":3,"names":["React","useMemo","isRNModule","unwrapModule","View","children","style","rawStyle","cssStyles","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","textDecoration","zIndex","createElement","Platform","OS","PixelRatio","window","devicePixelRatio","resolveAsset","source","asset","require","getAssetByID","httpServerLocation","name","type","uri","Error","findNodeHandle"],"sources":["Platform.web.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport React, { useMemo } from \"react\";\nimport type { ViewComponent, ViewProps } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule, unwrapModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\n// Layout is observed by the views themselves (see SkiaPictureView.web.tsx):\n// this shim only reproduces react-native-web's default View styling.\nconst View = (({ children, style: rawStyle }: ViewProps) => {\n const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);\n const cssStyles = useMemo(() => {\n return {\n alignItems: \"stretch\" as const,\n backgroundColor: \"transparent\" as const,\n border: \"0 solid black\" as const,\n boxSizing: \"border-box\" as const,\n display: \"flex\" as const,\n flexBasis: \"auto\" as const,\n flexDirection: \"column\" as const,\n flexShrink: 0,\n listStyle: \"none\" as const,\n margin: 0,\n minHeight: 0,\n minWidth: 0,\n padding: 0,\n position: \"relative\" as const,\n textDecoration: \"none\" as const,\n zIndex: 0,\n ...style,\n };\n }, [style]);\n\n return <div style={cssStyles}>{children}</div>;\n}) as unknown as typeof ViewComponent;\n\nexport const Platform: IPlatform = {\n OS: \"web\",\n PixelRatio: typeof window !== \"undefined\" ? window.devicePixelRatio : 1, // window is not defined on node\n resolveAsset: (source: DataModule) => {\n const asset = unwrapModule(source);\n if (typeof asset === \"string\") {\n return asset;\n }\n if (isRNModule(asset)) {\n if (typeof require === \"function\") {\n const {\n getAssetByID,\n } = require(\"react-native/Libraries/Image/AssetRegistry\");\n const { httpServerLocation, name, type } = getAssetByID(asset);\n const uri = `${httpServerLocation}/${name}.${type}`;\n return uri;\n }\n throw new Error(\n \"Asset source is a number - this is not supported on the web\"\n );\n }\n return asset.uri;\n },\n findNodeHandle: () => {\n throw new Error(\"findNodeHandle is not supported on the web\");\n },\n View,\n};\n"],"mappings":"AACA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAItC,SAASC,UAAU,EAAEC,YAAY,QAAQ,eAAe;AAIxD;AACA;AACA,MAAMC,IAAI,GAAIA,CAAC;EAAEC,QAAQ;EAAEC,KAAK,EAAEC;AAAoB,CAAC,KAAK;EAC1D,MAAMD,KAAK,GAAGL,OAAO,CAAC,MAAOM,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,CAAC,CAAmB,EAAE,CAACA,QAAQ,CAAC,CAAC;EAC1E,MAAMC,SAAS,G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;QACnD,OAAOC,GAAG;MACZ;MACA,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;IACH;IACA,OAAOP,KAAK,CAACM,GAAG;EAClB,CAAC;EACDE,cAAc,EAAEA,CAAA,KAAM;IACpB,MAAM,IAAID,KAAK,CAAC,4CAA4C,CAAC;EAC/D,CAAC;EACDpC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
+
import { FontSlant, FontWeight } from "../types";
|
|
1
2
|
import type { DataModule, DataSourceParam, SkFontMgr } from "../types";
|
|
2
3
|
import type { SkTypefaceFontProvider } from "../types/Paragraph/TypefaceFontProvider";
|
|
3
4
|
/**
|
|
4
5
|
* Returns a Skia Font object
|
|
5
6
|
* */
|
|
6
7
|
export declare const useFont: (font: DataSourceParam, size?: number, onError?: (err: Error) => void) => import("../types").SkFont | null;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* React Native style font slant, as found in the `fontStyle` property of
|
|
10
|
+
* `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.
|
|
11
|
+
*/
|
|
12
|
+
export type RNFontSlant = "normal" | "italic" | "oblique" | FontSlant;
|
|
13
|
+
/**
|
|
14
|
+
* React Native style font weight, as found in the `fontWeight` property of
|
|
15
|
+
* `TextStyle`. Numeric weights such as the {@link FontWeight} enum values
|
|
16
|
+
* used by the Paragraph API are accepted as well.
|
|
17
|
+
*/
|
|
18
|
+
export type RNFontWeight = "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | FontWeight;
|
|
19
|
+
/**
|
|
20
|
+
* Font style accepted by {@link matchFont}.
|
|
21
|
+
* `fontStyle` and `fontWeight` accept both the React Native string values
|
|
22
|
+
* and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same
|
|
23
|
+
* values can be shared with the Paragraph API.
|
|
24
|
+
*/
|
|
25
|
+
export interface RNFontStyle {
|
|
10
26
|
fontFamily: string;
|
|
11
27
|
fontSize: number;
|
|
12
|
-
fontStyle:
|
|
13
|
-
fontWeight:
|
|
28
|
+
fontStyle: RNFontSlant;
|
|
29
|
+
fontWeight: RNFontWeight;
|
|
14
30
|
}
|
|
15
31
|
export declare const matchFont: (inputStyle?: Partial<RNFontStyle>, fontMgr?: SkFontMgr) => import("../types").SkFont;
|
|
16
32
|
export declare const listFontFamilies: (fontMgr?: SkFontMgr) => string[];
|
|
17
33
|
export declare const useFonts: (sources: Record<string, DataModule[]>) => SkTypefaceFontProvider | null;
|
|
18
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*global SkiaApi*/
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { Skia } from "../Skia";
|
|
4
|
-
import { FontSlant } from "../types";
|
|
4
|
+
import { FontSlant, FontWeight } from "../types";
|
|
5
5
|
import { Platform } from "../../Platform";
|
|
6
6
|
import { useTypeface } from "./Typeface";
|
|
7
7
|
const defaultFontSize = 14;
|
|
@@ -19,6 +19,25 @@ export const useFont = (font, size = defaultFontSize, onError) => {
|
|
|
19
19
|
}
|
|
20
20
|
}, [size, typeface]);
|
|
21
21
|
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* React Native style font slant, as found in the `fontStyle` property of
|
|
25
|
+
* `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* React Native style font weight, as found in the `fontWeight` property of
|
|
30
|
+
* `TextStyle`. Numeric weights such as the {@link FontWeight} enum values
|
|
31
|
+
* used by the Paragraph API are accepted as well.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Font style accepted by {@link matchFont}.
|
|
36
|
+
* `fontStyle` and `fontWeight` accept both the React Native string values
|
|
37
|
+
* and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same
|
|
38
|
+
* values can be shared with the Paragraph API.
|
|
39
|
+
*/
|
|
40
|
+
|
|
22
41
|
const defaultFontStyle = {
|
|
23
42
|
fontFamily: "System",
|
|
24
43
|
fontSize: defaultFontSize,
|
|
@@ -26,7 +45,9 @@ const defaultFontStyle = {
|
|
|
26
45
|
fontWeight: "normal"
|
|
27
46
|
};
|
|
28
47
|
const slant = s => {
|
|
29
|
-
if (s === "
|
|
48
|
+
if (typeof s === "number") {
|
|
49
|
+
return s;
|
|
50
|
+
} else if (s === "italic") {
|
|
30
51
|
return FontSlant.Italic;
|
|
31
52
|
} else if (s === "oblique") {
|
|
32
53
|
return FontSlant.Oblique;
|
|
@@ -37,11 +58,11 @@ const slant = s => {
|
|
|
37
58
|
const weight = fontWeight => {
|
|
38
59
|
switch (fontWeight) {
|
|
39
60
|
case "normal":
|
|
40
|
-
return
|
|
61
|
+
return FontWeight.Normal;
|
|
41
62
|
case "bold":
|
|
42
|
-
return
|
|
63
|
+
return FontWeight.Bold;
|
|
43
64
|
default:
|
|
44
|
-
return parseInt(fontWeight, 10);
|
|
65
|
+
return typeof fontWeight === "number" ? fontWeight : parseInt(fontWeight, 10);
|
|
45
66
|
}
|
|
46
67
|
};
|
|
47
68
|
export const matchFont = (inputStyle = {}, fontMgr = Skia.FontMgr.System()) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","useState","Skia","FontSlant","Platform","useTypeface","defaultFontSize","useFont","font","size","onError","typeface","Font","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","Italic","Oblique","Upright","weight","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","families","Set","i","countFamilies","add","getFamilyName","Array","from","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","map","typefaceToLoad","Data","fromURI","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\nconst defaultFontSize = 14;\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size = defaultFontSize,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface) {\n return Skia.Font(typeface, size);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useState","Skia","FontSlant","FontWeight","Platform","useTypeface","defaultFontSize","useFont","font","size","onError","typeface","Font","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","Italic","Oblique","Upright","weight","Normal","Bold","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","families","Set","i","countFamilies","add","getFamilyName","Array","from","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","map","typefaceToLoad","Data","fromURI","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant, FontWeight } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\nconst defaultFontSize = 14;\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size = defaultFontSize,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface) {\n return Skia.Font(typeface, size);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\n/**\n * React Native style font slant, as found in the `fontStyle` property of\n * `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.\n */\nexport type RNFontSlant = \"normal\" | \"italic\" | \"oblique\" | FontSlant;\n\n/**\n * React Native style font weight, as found in the `fontWeight` property of\n * `TextStyle`. Numeric weights such as the {@link FontWeight} enum values\n * used by the Paragraph API are accepted as well.\n */\nexport type RNFontWeight =\n | \"normal\"\n | \"bold\"\n | \"100\"\n | \"200\"\n | \"300\"\n | \"400\"\n | \"500\"\n | \"600\"\n | \"700\"\n | \"800\"\n | \"900\"\n | FontWeight;\n\n/**\n * Font style accepted by {@link matchFont}.\n * `fontStyle` and `fontWeight` accept both the React Native string values\n * and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same\n * values can be shared with the Paragraph API.\n */\nexport interface RNFontStyle {\n fontFamily: string;\n fontSize: number;\n fontStyle: RNFontSlant;\n fontWeight: RNFontWeight;\n}\n\nconst defaultFontStyle: RNFontStyle = {\n fontFamily: \"System\",\n fontSize: defaultFontSize,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n};\n\nconst slant = (s: RNFontSlant): FontSlant => {\n if (typeof s === \"number\") {\n return s;\n } else if (s === \"italic\") {\n return FontSlant.Italic;\n } else if (s === \"oblique\") {\n return FontSlant.Oblique;\n } else {\n return FontSlant.Upright;\n }\n};\n\nconst weight = (fontWeight: RNFontWeight): FontWeight => {\n switch (fontWeight) {\n case \"normal\":\n return FontWeight.Normal;\n case \"bold\":\n return FontWeight.Bold;\n default:\n return typeof fontWeight === \"number\"\n ? fontWeight\n : (parseInt(fontWeight, 10) as FontWeight);\n }\n};\n\nexport const matchFont = (\n inputStyle: Partial<RNFontStyle> = {},\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const fontStyle = {\n ...defaultFontStyle,\n ...inputStyle,\n };\n const style = {\n weight: weight(fontStyle.fontWeight),\n width: 5,\n slant: slant(fontStyle.fontStyle),\n };\n const typeface = fontMgr.matchFamilyStyle(fontStyle.fontFamily, style);\n return Skia.Font(typeface, fontStyle.fontSize);\n};\n\nexport const listFontFamilies = (\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const families = new Set<string>();\n for (let i = 0; i < fontMgr.countFamilies(); i++) {\n families.add(fontMgr.getFamilyName(i));\n }\n return Array.from(families);\n};\n\nconst loadTypefaces = (typefacesToLoad: Record<string, DataModule[]>) => {\n const promises = Object.keys(typefacesToLoad).flatMap((familyName) => {\n return typefacesToLoad[familyName].map((typefaceToLoad) => {\n return Skia.Data.fromURI(Platform.resolveAsset(typefaceToLoad)).then(\n (data) => {\n const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data);\n if (tf === null) {\n throw new Error(`Couldn't create typeface for ${familyName}`);\n }\n return [familyName, tf] as const;\n }\n );\n });\n });\n return Promise.all(promises);\n};\n\nexport const useFonts = (sources: Record<string, DataModule[]>) => {\n const [fontMgr, setFontMgr] = useState<null | SkTypefaceFontProvider>(null);\n\n useEffect(() => {\n loadTypefaces(sources).then((result) => {\n const fMgr = Skia.TypefaceFontProvider.Make();\n result.forEach(([familyName, typeface]) => {\n fMgr.registerFont(typeface, familyName);\n });\n setFontMgr(fMgr);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return fontMgr;\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAEpD,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,SAAS,EAAEC,UAAU,QAAQ,UAAU;AAEhD,SAASC,QAAQ,QAAQ,gBAAgB;AAGzC,SAASC,WAAW,QAAQ,YAAY;AAExC,MAAMC,eAAe,GAAG,EAAE;;AAE1B;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAC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I,IAAI,CACjEC,IAAI,IAAK;QACR,MAAMC,EAAE,GAAGzD,IAAI,CAAC0D,QAAQ,CAACC,wBAAwB,CAACH,IAAI,CAAC;QACvD,IAAIC,EAAE,KAAK,IAAI,EAAE;UACf,MAAM,IAAIG,KAAK,CAAC,gCAAgCX,UAAU,EAAE,CAAC;QAC/D;QACA,OAAO,CAACA,UAAU,EAAEQ,EAAE,CAAC;MACzB,CACF,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOI,OAAO,CAACC,GAAG,CAACjB,QAAQ,CAAC;AAC9B,CAAC;AAED,OAAO,MAAMkB,QAAQ,GAAIC,OAAqC,IAAK;EACjE,MAAM,CAACpC,OAAO,EAAEqC,UAAU,CAAC,GAAGlE,QAAQ,CAAgC,IAAI,CAAC;EAE3EF,SAAS,CAAC,MAAM;IACd8C,aAAa,CAACqB,OAAO,CAAC,CAACT,IAAI,CAAEW,MAAM,IAAK;MACtC,MAAMC,IAAI,GAAGnE,IAAI,CAACoE,oBAAoB,CAACC,IAAI,CAAC,CAAC;MAC7CH,MAAM,CAACI,OAAO,CAAC,CAAC,CAACrB,UAAU,EAAEvC,QAAQ,CAAC,KAAK;QACzCyD,IAAI,CAACI,YAAY,CAAC7D,QAAQ,EAAEuC,UAAU,CAAC;MACzC,CAAC,CAAC;MACFgB,UAAU,CAACE,IAAI,CAAC;IAClB,CAAC,CAAC;IACF;EACF,CAAC,EAAE,EAAE,CAAC;EACN,OAAOvC,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
2
2
|
export type SkData = SkJSIInstance<"Data">;
|
|
3
3
|
type RNModule = number;
|
|
4
|
-
type ESModule = {
|
|
5
|
-
__esModule: true;
|
|
6
|
-
default: string;
|
|
7
|
-
};
|
|
8
4
|
type MetroAsset = {
|
|
9
5
|
uri: string;
|
|
10
6
|
width: number;
|
|
11
7
|
height: number;
|
|
12
8
|
};
|
|
9
|
+
type ESModule = {
|
|
10
|
+
__esModule: true;
|
|
11
|
+
default: RNModule | MetroAsset | string;
|
|
12
|
+
};
|
|
13
13
|
export type DataModule = RNModule | ESModule | MetroAsset;
|
|
14
14
|
export type DataSource = DataModule | string | Uint8Array;
|
|
15
15
|
export type DataSourceParam = DataSource | null | undefined;
|
|
16
16
|
export declare const isRNModule: (mod: DataModule) => mod is RNModule;
|
|
17
|
+
export declare const unwrapModule: (mod: DataModule) => RNModule | MetroAsset | string;
|
|
17
18
|
export {};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export const isRNModule = mod => typeof mod === "number";
|
|
2
|
+
|
|
3
|
+
// Since Expo SDK 52, on web, require() may return an ES module interop
|
|
4
|
+
// object ({ default: <asset> }) instead of the asset itself.
|
|
5
|
+
// See https://github.com/Shopify/react-native-skia/issues/2784
|
|
6
|
+
export const unwrapModule = mod => typeof mod === "object" && mod !== null && "default" in mod ? mod.default : mod;
|
|
2
7
|
//# sourceMappingURL=Data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype
|
|
1
|
+
{"version":3,"names":["isRNModule","mod","unwrapModule","default"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype MetroAsset = {\n uri: string;\n width: number;\n height: number;\n};\ntype ESModule = {\n __esModule: true;\n default: RNModule | MetroAsset | string;\n};\n\nexport type DataModule = RNModule | ESModule | MetroAsset;\nexport type DataSource = DataModule | string | Uint8Array;\nexport type DataSourceParam = DataSource | null | undefined;\n\nexport const isRNModule = (mod: DataModule): mod is RNModule =>\n typeof mod === \"number\";\n\n// Since Expo SDK 52, on web, require() may return an ES module interop\n// object ({ default: <asset> }) instead of the asset itself.\n// See https://github.com/Shopify/react-native-skia/issues/2784\nexport const unwrapModule = (\n mod: DataModule\n): RNModule | MetroAsset | string =>\n typeof mod === \"object\" && mod !== null && \"default\" in mod\n ? mod.default\n : mod;\n"],"mappings":"AAmBA,OAAO,MAAMA,UAAU,GAAIC,GAAe,IACxC,OAAOA,GAAG,KAAK,QAAQ;;AAEzB;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GACvBD,GAAe,IAEf,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,KAAK,IAAI,IAAI,SAAS,IAAIA,GAAG,GACvDA,GAAG,CAACE,OAAO,GACXF,GAAG","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ import { JsiSkRect } from "./JsiSkRect";
|
|
|
5
5
|
import { JsiSkTypeface } from "./JsiSkTypeface";
|
|
6
6
|
export declare class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
7
7
|
constructor(CanvasKit: CanvasKit, ref: Font);
|
|
8
|
-
measureText(
|
|
8
|
+
measureText(text: string, paint?: SkPaint | undefined): SkRect;
|
|
9
9
|
getTextWidth(text: string, paint?: SkPaint | undefined): number;
|
|
10
10
|
getMetrics(): {
|
|
11
11
|
ascent: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HostObject, getEnum
|
|
1
|
+
import { HostObject, getEnum } from "./Host";
|
|
2
2
|
import { JsiSkPaint } from "./JsiSkPaint";
|
|
3
3
|
import { JsiSkPoint } from "./JsiSkPoint";
|
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
|
@@ -7,8 +7,49 @@ export class JsiSkFont extends HostObject {
|
|
|
7
7
|
constructor(CanvasKit, ref) {
|
|
8
8
|
super(CanvasKit, ref, "Font");
|
|
9
9
|
}
|
|
10
|
-
measureText(
|
|
11
|
-
|
|
10
|
+
measureText(text, paint) {
|
|
11
|
+
// CanvasKit doesn't expose SkFont::measureText directly, so we polyfill
|
|
12
|
+
// it: for each glyph we take its ink bounds (relative to its own origin),
|
|
13
|
+
// offset it by the accumulated advance, and union the results. This
|
|
14
|
+
// matches the bounds computed natively by SkFont::measureText.
|
|
15
|
+
const glyphs = this.ref.getGlyphIDs(text);
|
|
16
|
+
if (glyphs.length === 0) {
|
|
17
|
+
return new JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));
|
|
18
|
+
}
|
|
19
|
+
const skPaint = paint ? JsiSkPaint.fromValue(paint) : null;
|
|
20
|
+
// Flattened rectangles: 4 floats (left, top, right, bottom) per glyph.
|
|
21
|
+
const bounds = this.ref.getGlyphBounds(glyphs, skPaint);
|
|
22
|
+
const advances = this.ref.getGlyphWidths(glyphs, skPaint);
|
|
23
|
+
let left = 0;
|
|
24
|
+
let top = 0;
|
|
25
|
+
let right = 0;
|
|
26
|
+
let bottom = 0;
|
|
27
|
+
let isEmpty = true;
|
|
28
|
+
let xPos = 0;
|
|
29
|
+
for (let i = 0; i < glyphs.length; i++) {
|
|
30
|
+
const l = bounds[i * 4] + xPos;
|
|
31
|
+
const t = bounds[i * 4 + 1];
|
|
32
|
+
const r = bounds[i * 4 + 2] + xPos;
|
|
33
|
+
const b = bounds[i * 4 + 3];
|
|
34
|
+
xPos += advances[i];
|
|
35
|
+
// Skip empty glyph bounds (e.g. whitespace), like SkRect::join does.
|
|
36
|
+
if (l >= r || t >= b) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (isEmpty) {
|
|
40
|
+
left = l;
|
|
41
|
+
top = t;
|
|
42
|
+
right = r;
|
|
43
|
+
bottom = b;
|
|
44
|
+
isEmpty = false;
|
|
45
|
+
} else {
|
|
46
|
+
left = Math.min(left, l);
|
|
47
|
+
top = Math.min(top, t);
|
|
48
|
+
right = Math.max(right, r);
|
|
49
|
+
bottom = Math.max(bottom, b);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return new JsiSkRect(this.CanvasKit, this.CanvasKit.LTRBRect(left, top, right, bottom));
|
|
12
53
|
}
|
|
13
54
|
getTextWidth(text, paint) {
|
|
14
55
|
const ids = this.getGlyphIDs(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HostObject","getEnum","throwNotImplementedOnRNWeb","JsiSkPaint","JsiSkPoint","JsiSkRect","JsiSkTypeface","JsiSkFont","constructor","CanvasKit","ref","measureText","_text","_paint","getTextWidth","text","paint","ids","getGlyphIDs","widths","getGlyphWidths","reduce","a","b","getMetrics","result","ascent","descent","leading","bounds","undefined","str","numCodePoints","glyphs","fromValue","getGlyphIntercepts","positions","top","bottom","map","p","Array","from","flat","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"sources":["JsiSkFont.ts"],"sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, getEnum, throwNotImplementedOnRNWeb } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(_text: string, _paint?: SkPaint | undefined) {\n return throwNotImplementedOnRNWeb<SkRect>();\n }\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [\n ...this.ref.getGlyphWidths(\n glyphs,\n paint ? JsiSkPaint.fromValue(paint) : null\n ),\n ];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(getEnum(this.CanvasKit, \"FontEdging\", edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(getEnum(this.CanvasKit, \"FontHinting\", hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTyp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C,GAAG,CAACwC,SAAS,CAACjD,OAAO,CAAC,IAAI,CAACQ,SAAS,EAAE,YAAY,EAAE0C,MAAM,CAAC,CAAC;EACnE;EAEAC,kBAAkBA,CAACC,eAAwB,EAAE;IAC3C,IAAI,CAAC3C,GAAG,CAAC0C,kBAAkB,CAACC,eAAe,CAAC;EAC9C;EAEAC,UAAUA,CAACC,OAAoB,EAAE;IAC/B,IAAI,CAAC7C,GAAG,CAAC4C,UAAU,CAACrD,OAAO,CAAC,IAAI,CAACQ,SAAS,EAAE,aAAa,EAAE8C,OAAO,CAAC,CAAC;EACtE;EAEAC,gBAAgBA,CAACC,aAAsB,EAAE;IACvC,IAAI,CAAC/C,GAAG,CAAC8C,gBAAgB,CAACC,aAAa,CAAC;EAC1C;EAEAC,SAASA,CAACC,EAAU,EAAE;IACpB,IAAI,CAACjD,GAAG,CAACgD,SAAS,CAACC,EAAE,CAAC;EACxB;EAEAC,OAAOA,CAACC,MAAc,EAAE;IACtB,IAAI,CAACnD,GAAG,CAACkD,OAAO,CAACC,MAAM,CAAC;EAC1B;EAEAC,QAAQA,CAACH,EAAU,EAAE;IACnB,IAAI,CAACjD,GAAG,CAACoD,QAAQ,CAACH,EAAE,CAAC;EACvB;EAEAI,WAAWA,CAACC,QAAiB,EAAE;IAC7B,IAAI,CAACtD,GAAG,CAACqD,WAAW,CAACC,QAAQ,CAAC;EAChC;EAEAC,WAAWA,CAACC,QAAiB,EAAE;IAC7B,IAAI,CAACxD,GAAG,CAACuD,WAAW,CAACC,QAAQ,CAAC;EAChC;EAEAC,WAAWA,CAACC,IAAuB,EAAE;IACnC,IAAI,CAAC1D,GAAG,CAACyD,WAAW,CAACC,IAAI,GAAG9D,aAAa,CAAC4B,SAAS,CAACkC,IAAI,CAAC,GAAG,IAAI,CAAC;EACnE;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["HostObject","getEnum","JsiSkPaint","JsiSkPoint","JsiSkRect","JsiSkTypeface","JsiSkFont","constructor","CanvasKit","ref","measureText","text","paint","glyphs","getGlyphIDs","length","XYWHRect","skPaint","fromValue","bounds","getGlyphBounds","advances","getGlyphWidths","left","top","right","bottom","isEmpty","xPos","i","l","t","r","b","Math","min","max","LTRBRect","getTextWidth","ids","widths","reduce","a","getMetrics","result","ascent","descent","leading","undefined","str","numCodePoints","getGlyphIntercepts","positions","map","p","Array","from","flat","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"sources":["JsiSkFont.ts"],"sourcesContent":["import type { CanvasKit, Font, Paint } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, getEnum } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(text: string, paint?: SkPaint | undefined): SkRect {\n // CanvasKit doesn't expose SkFont::measureText directly, so we polyfill\n // it: for each glyph we take its ink bounds (relative to its own origin),\n // offset it by the accumulated advance, and union the results. This\n // matches the bounds computed natively by SkFont::measureText.\n const glyphs = this.ref.getGlyphIDs(text);\n if (glyphs.length === 0) {\n return new JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));\n }\n const skPaint = paint ? JsiSkPaint.fromValue<Paint>(paint) : null;\n // Flattened rectangles: 4 floats (left, top, right, bottom) per glyph.\n const bounds = this.ref.getGlyphBounds(glyphs, skPaint);\n const advances = this.ref.getGlyphWidths(glyphs, skPaint);\n let left = 0;\n let top = 0;\n let right = 0;\n let bottom = 0;\n let isEmpty = true;\n let xPos = 0;\n for (let i = 0; i < glyphs.length; i++) {\n const l = bounds[i * 4] + xPos;\n const t = bounds[i * 4 + 1];\n const r = bounds[i * 4 + 2] + xPos;\n const b = bounds[i * 4 + 3];\n xPos += advances[i];\n // Skip empty glyph bounds (e.g. whitespace), like SkRect::join does.\n if (l >= r || t >= b) {\n continue;\n }\n if (isEmpty) {\n left = l;\n top = t;\n right = r;\n bottom = b;\n isEmpty = false;\n } else {\n left = Math.min(left, l);\n top = Math.min(top, t);\n right = Math.max(right, r);\n bottom = Math.max(bottom, b);\n }\n }\n return new JsiSkRect(\n this.CanvasKit,\n this.CanvasKit.LTRBRect(left, top, right, bottom)\n );\n }\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [\n ...this.ref.getGlyphWidths(\n glyphs,\n paint ? JsiSkPaint.fromValue(paint) : null\n ),\n ];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(getEnum(this.CanvasKit, \"FontEdging\", edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(getEnum(this.CanvasKit, \"FontHinting\", hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);\n }\n}\n"],"mappings":"AAYA,SAASA,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAC5C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,MAAMC,SAAS,SAASN,UAAU,CAAiC;EACxEO,WAAWA,CAACC,SAAoB,EAAEC,GAAS,EAAE;IAC3C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,MAAM,CAAC;EAC/B;EAEAC,WAAWA,CAACC,IAAY,EAAEC,KAA2B,EAAU;IAC7D;IACA;IACA;IACA;IACA,MAAMC,MAAM,GAAG,IAAI,CAACJ,GAAG,CAACK,WAAW,CAACH,IAAI,CAAC;IACzC,IAAIE,MAAM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