@shopify/react-native-skia 0.1.138 → 0.1.139
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkApi.h +0 -4
- package/cpp/api/JsiSkFont.h +0 -19
- package/lib/commonjs/mock/index.js +0 -4
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +5 -8
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/text/Glyphs.js +4 -6
- package/lib/commonjs/renderer/components/text/Glyphs.js.map +1 -1
- package/lib/commonjs/renderer/components/text/Text.js +4 -6
- package/lib/commonjs/renderer/components/text/Text.js.map +1 -1
- package/lib/commonjs/renderer/components/text/TextPath.js +3 -4
- package/lib/commonjs/renderer/components/text/TextPath.js.map +1 -1
- package/lib/commonjs/renderer/processors/Font.js +1 -27
- package/lib/commonjs/renderer/processors/Font.js.map +1 -1
- package/lib/commonjs/skia/core/Data.js +4 -5
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js +4 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.js +3 -1
- package/lib/commonjs/skia/core/SVG.js.map +1 -1
- package/lib/commonjs/skia/core/Typeface.js +4 -1
- package/lib/commonjs/skia/core/Typeface.js.map +1 -1
- package/lib/commonjs/skia/core/index.js +0 -26
- package/lib/commonjs/skia/core/index.js.map +1 -1
- package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
- package/lib/commonjs/skia/types/index.js +0 -13
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +0 -6
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +0 -3
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/values/hooks/useComputedValue.js +1 -8
- package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.js +53 -33
- package/lib/commonjs/views/SkiaView.web.js.map +1 -1
- package/lib/module/mock/index.js +0 -4
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +5 -6
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/text/Glyphs.js +4 -5
- package/lib/module/renderer/components/text/Glyphs.js.map +1 -1
- package/lib/module/renderer/components/text/Text.js +4 -5
- package/lib/module/renderer/components/text/Text.js.map +1 -1
- package/lib/module/renderer/components/text/TextPath.js +3 -3
- package/lib/module/renderer/components/text/TextPath.js.map +1 -1
- package/lib/module/renderer/processors/Font.js +0 -23
- package/lib/module/renderer/processors/Font.js.map +1 -1
- package/lib/module/skia/core/Data.js +4 -5
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/core/Image.js +2 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/core/SVG.js +2 -1
- package/lib/module/skia/core/SVG.js.map +1 -1
- package/lib/module/skia/core/Typeface.js +2 -1
- package/lib/module/skia/core/Typeface.js.map +1 -1
- package/lib/module/skia/core/index.js +0 -2
- package/lib/module/skia/core/index.js.map +1 -1
- package/lib/module/skia/types/Font/Font.js.map +1 -1
- package/lib/module/skia/types/index.js +0 -1
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +0 -6
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +0 -2
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/values/hooks/useComputedValue.js +0 -4
- package/lib/module/values/hooks/useComputedValue.js.map +1 -1
- package/lib/module/views/SkiaView.web.js +53 -34
- package/lib/module/views/SkiaView.web.js.map +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -3
- package/lib/typescript/src/renderer/DrawingContext.d.ts +1 -2
- package/lib/typescript/src/renderer/processors/Font.d.ts +1 -5
- package/lib/typescript/src/skia/core/index.d.ts +0 -2
- package/lib/typescript/src/skia/types/Font/Font.d.ts +0 -12
- package/lib/typescript/src/skia/types/Skia.d.ts +0 -2
- package/lib/typescript/src/skia/types/index.d.ts +0 -1
- package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -2
- package/lib/typescript/src/values/hooks/useComputedValue.d.ts +0 -1
- package/lib/typescript/src/views/SkiaView.web.d.ts +5 -5
- package/package.json +1 -1
- package/src/mock/index.ts +0 -4
- package/src/renderer/Canvas.tsx +5 -8
- package/src/renderer/DrawingContext.ts +1 -2
- package/src/renderer/components/text/Glyphs.tsx +2 -6
- package/src/renderer/components/text/Text.tsx +2 -3
- package/src/renderer/components/text/TextPath.tsx +2 -3
- package/src/renderer/processors/Font.ts +2 -25
- package/src/skia/core/Data.ts +8 -5
- package/src/skia/core/Image.ts +3 -1
- package/src/skia/core/SVG.ts +3 -1
- package/src/skia/core/Typeface.ts +4 -6
- package/src/skia/core/index.ts +0 -2
- package/src/skia/types/Font/Font.ts +0 -13
- package/src/skia/types/Skia.ts +0 -2
- package/src/skia/types/index.ts +0 -1
- package/src/skia/web/JsiSkFont.ts +0 -9
- package/src/skia/web/JsiSkTextBlobFactory.ts +1 -1
- package/src/skia/web/JsiSkia.ts +0 -2
- package/src/values/hooks/useComputedValue.ts +0 -5
- package/src/views/SkiaView.web.tsx +41 -46
- package/cpp/api/JsiSkFontMgr.h +0 -84
- package/cpp/api/JsiSkFontMgrFactory.h +0 -48
- package/lib/commonjs/skia/core/Paint.js +0 -28
- package/lib/commonjs/skia/core/Paint.js.map +0 -1
- package/lib/commonjs/skia/core/Path.js +0 -72
- package/lib/commonjs/skia/core/Path.js.map +0 -1
- package/lib/commonjs/skia/types/FontMgr/FontMgr.js +0 -6
- package/lib/commonjs/skia/types/FontMgr/FontMgr.js.map +0 -1
- package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js +0 -6
- package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
- package/lib/commonjs/skia/types/FontMgr/index.js +0 -32
- package/lib/commonjs/skia/types/FontMgr/index.js.map +0 -1
- package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -33
- package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +0 -1
- package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js +0 -25
- package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js.map +0 -1
- package/lib/module/skia/core/Paint.js +0 -17
- package/lib/module/skia/core/Paint.js.map +0 -1
- package/lib/module/skia/core/Path.js +0 -53
- package/lib/module/skia/core/Path.js.map +0 -1
- package/lib/module/skia/types/FontMgr/FontMgr.js +0 -2
- package/lib/module/skia/types/FontMgr/FontMgr.js.map +0 -1
- package/lib/module/skia/types/FontMgr/FontMgrFactory.js +0 -2
- package/lib/module/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
- package/lib/module/skia/types/FontMgr/index.js +0 -3
- package/lib/module/skia/types/FontMgr/index.js.map +0 -1
- package/lib/module/skia/web/JsiSkFontMgr.js +0 -23
- package/lib/module/skia/web/JsiSkFontMgr.js.map +0 -1
- package/lib/module/skia/web/JsiSkFontMgrFactory.js +0 -14
- package/lib/module/skia/web/JsiSkFontMgrFactory.js.map +0 -1
- package/lib/typescript/src/skia/core/Paint.d.ts +0 -6
- package/lib/typescript/src/skia/core/Path.d.ts +0 -21
- package/lib/typescript/src/skia/types/FontMgr/FontMgr.d.ts +0 -18
- package/lib/typescript/src/skia/types/FontMgr/FontMgrFactory.d.ts +0 -4
- package/lib/typescript/src/skia/types/FontMgr/index.d.ts +0 -2
- package/lib/typescript/src/skia/web/JsiSkFontMgr.d.ts +0 -9
- package/lib/typescript/src/skia/web/JsiSkFontMgrFactory.d.ts +0 -8
- package/src/skia/core/Paint.ts +0 -22
- package/src/skia/core/Path.ts +0 -60
- package/src/skia/types/FontMgr/FontMgr.ts +0 -24
- package/src/skia/types/FontMgr/FontMgrFactory.ts +0 -12
- package/src/skia/types/FontMgr/index.ts +0 -2
- package/src/skia/web/JsiSkFontMgr.ts +0 -38
- package/src/skia/web/JsiSkFontMgrFactory.ts +0 -18
package/cpp/api/JsiSkApi.h
CHANGED
@@ -33,7 +33,6 @@
|
|
33
33
|
#include "JsiSkVertices.h"
|
34
34
|
#include "JsiSkTypefaceFactory.h"
|
35
35
|
#include "JsiSkDataFactory.h"
|
36
|
-
#include "JsiSkFontMgrFactory.h"
|
37
36
|
#include "JsiSkSurfaceFactory.h"
|
38
37
|
#include "JsiSkTextBlobFactory.h"
|
39
38
|
#include "JsiSkContourMeasureIter.h"
|
@@ -72,9 +71,6 @@ namespace RNSkia
|
|
72
71
|
installFunction("PictureRecorder", JsiSkPictureRecorder::createCtor(context));
|
73
72
|
installFunction("Color", JsiSkColor::createCtor());
|
74
73
|
|
75
|
-
// Static members
|
76
|
-
installReadonlyProperty("FontMgr",
|
77
|
-
std::make_shared<JsiSkFontMgrFactory>(context));
|
78
74
|
installReadonlyProperty("SVG",
|
79
75
|
std::make_shared<JsiSkSVGFactory>(context));
|
80
76
|
installReadonlyProperty("Image",
|
package/cpp/api/JsiSkFont.h
CHANGED
@@ -38,24 +38,6 @@ namespace RNSkia
|
|
38
38
|
return jsi::String::createFromUtf8(runtime, "Font");
|
39
39
|
}
|
40
40
|
|
41
|
-
JSI_HOST_FUNCTION(measureText)
|
42
|
-
{
|
43
|
-
RNSkLogger::warnToJavascriptConsole(runtime, "measureText() is deprecated. Clients should use 'Font.getGlyphWidths' instead (the latter does no shaping)");
|
44
|
-
auto textVal = arguments[0].asString(runtime).utf8(runtime);
|
45
|
-
auto text = textVal.c_str();
|
46
|
-
SkRect rect;
|
47
|
-
std::shared_ptr<SkPaint> paint = nullptr;
|
48
|
-
// Check if a paint argument was provided
|
49
|
-
if (count == 2)
|
50
|
-
{
|
51
|
-
paint = JsiSkPaint::fromValue(runtime, arguments[1]);
|
52
|
-
}
|
53
|
-
getObject()->measureText(text, strlen(text), SkTextEncoding::kUTF8, &rect,
|
54
|
-
paint.get());
|
55
|
-
rect.setXYWH(0, 0, rect.width(), rect.height());
|
56
|
-
return JsiSkRect::toValue(runtime, getContext(), std::move(rect));
|
57
|
-
}
|
58
|
-
|
59
41
|
JSI_HOST_FUNCTION(getGlyphWidths)
|
60
42
|
{
|
61
43
|
auto jsiGlyphs = arguments[0].asObject(runtime).asArray(runtime);
|
@@ -279,7 +261,6 @@ namespace RNSkia
|
|
279
261
|
|
280
262
|
JSI_EXPORT_FUNCTIONS(
|
281
263
|
JSI_EXPORT_FUNC(JsiSkFont, getSize),
|
282
|
-
JSI_EXPORT_FUNC(JsiSkFont, measureText),
|
283
264
|
JSI_EXPORT_FUNC(JsiSkFont, getMetrics),
|
284
265
|
JSI_EXPORT_FUNC(JsiSkFont, getGlyphIDs),
|
285
266
|
JSI_EXPORT_FUNC(JsiSkFont, getGlyphIntercepts),
|
@@ -70,12 +70,8 @@ const Mock = {
|
|
70
70
|
useFont: Noop,
|
71
71
|
useTypeface: Noop,
|
72
72
|
useImage: Noop,
|
73
|
-
usePath: Noop,
|
74
73
|
useSVG: Noop,
|
75
|
-
useTextPath: Noop,
|
76
|
-
usePaint: Noop,
|
77
74
|
usePicture: Noop,
|
78
|
-
useSvgPath: Noop,
|
79
75
|
// 3. Point/Rect/Transform utilities
|
80
76
|
vec,
|
81
77
|
rect: (x, y, width, height) => ({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useDataCollection","useRawData","useData","useFont","useTypeface","useImage","
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useDataCollection","useRawData","useData","useFont","useTypeface","useImage","useSVG","usePicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","useSharedValueEffect","Values","ValuesHooks","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAjBA;AAmBA,MAAMA,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;AACzBC,MAAAA,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;AAEzBI,MAAAA,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;AAGzBK,MAAAA,GAAG,EAAE,MAAM;AAHc,KAApB,CAAP;AAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;;;AAEA,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb;AAAA;;AAAA,SAA6B;AAAED,IAAAA,CAAC,EAAEA,CAAF,aAAEA,CAAF,cAAEA,CAAF,GAAO,CAAV;AAAaC,IAAAA,CAAC,UAAEA,CAAF,aAAEA,CAAF,cAAEA,CAAF,GAAOD,CAAP,uCAAY;AAA1B,GAA7B;AAAA,CAAZ;;;AAEA,MAAME,IAOV,GAAG;AACJ;AACA;AACAJ,EAAAA,IAHI;AAIJ,KAAGK,QAJC;AAKJ;AACAC,EAAAA,iBAAiB,EAAEP,IANf;AAOJQ,EAAAA,UAAU,EAAER,IAPR;AAQJS,EAAAA,OAAO,EAAET,IARL;AASJU,EAAAA,OAAO,EAAEV,IATL;AAUJW,EAAAA,WA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-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useDataCollection: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n usePicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"]}
|
@@ -48,17 +48,13 @@ const render = (element, root, container) => {
|
|
48
48
|
const useCanvasRef = () => (0, _react.useRef)(null);
|
49
49
|
|
50
50
|
exports.useCanvasRef = useCanvasRef;
|
51
|
-
|
52
|
-
const defaultFontMgr = _Skia.Skia.FontMgr.RefDefault();
|
53
|
-
|
54
51
|
const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
|
55
52
|
let {
|
56
53
|
children,
|
57
54
|
style,
|
58
55
|
debug,
|
59
56
|
mode,
|
60
|
-
onTouch
|
61
|
-
fontMgr
|
57
|
+
onTouch
|
62
58
|
} = _ref;
|
63
59
|
const size = (0, _useValue.useValue)({
|
64
60
|
width: 0,
|
@@ -111,16 +107,17 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
|
|
111
107
|
opacity: 1,
|
112
108
|
ref,
|
113
109
|
center: _Skia.Skia.Point(width / 2, height / 2),
|
114
|
-
fontMgr: fontMgr !== null && fontMgr !== void 0 ? fontMgr : defaultFontMgr,
|
115
110
|
Skia: _Skia.Skia
|
116
111
|
};
|
117
112
|
container.draw(ctx);
|
118
113
|
}, [tick, onTouch]);
|
119
114
|
(0, _react.useEffect)(() => {
|
120
115
|
return () => {
|
121
|
-
|
116
|
+
skiaReconciler.updateContainer(null, root, null, () => {
|
117
|
+
container.depMgr.unsubscribe();
|
118
|
+
});
|
122
119
|
};
|
123
|
-
}, [container]);
|
120
|
+
}, [container, root]);
|
124
121
|
return /*#__PURE__*/_react.default.createElement(_views.SkiaView, {
|
125
122
|
ref: ref,
|
126
123
|
style: style,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Canvas.tsx"],"names":["skiaReconciler","skHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","subscribe","useCanvasRef","
|
1
|
+
{"version":3,"sources":["Canvas.tsx"],"names":["skiaReconciler","skHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","subscribe","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","size","width","height","canvasCtx","Skia","innerRef","ref","useCombinedRefs","tick","setTick","redraw","t","Container","DependencyManager","createContainer","onDraw","canvas","info","timestamp","touches","current","paint","Paint","ctx","opacity","center","Point","draw","unsubscribe","refs","targetRef","React","useRef","useEffect","forEach"],"mappings":";;;;;;;AAAA;;AAgBA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;AAHA;AAKO,MAAMA,cAAc,GAAG,8BAAgBC,wBAAhB,CAAvB;;AAEPD,cAAc,CAACE,kBAAf,CAAkC;AAChCC,EAAAA,UAAU,EAAE,CADoB;AAEhCC,EAAAA,OAAO,EAAE,OAFuB;AAGhCC,EAAAA,mBAAmB,EAAE;AAHW,CAAlC;;AAMA,MAAMC,MAAM,GAAG,CAACC,OAAD,EAAqBC,IAArB,EAAuCC,SAAvC,KAAgE;AAC7ET,EAAAA,cAAc,CAACU,eAAf,CAA+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AAOT,OAAP,CA3Ba,CAAf;AA8BA,wBAAU,MAAM;AACd,WAAO,MAAM;AACXpB,MAAAA,cAAc,CAACU,eAAf,CAA+B,IAA/B,EAAqCF,IAArC,EAA2C,IAA3C,EAAiD,MAAM;AACrDC,QAAAA,SAAS,CAACE,MAAV,CAAiBsC,WAAjB;AACD,OAFD;AAGD,KAJD;AAKD,GAND,EAMG,CAACxC,SAAD,EAAYD,IAAZ,CANH;AAQA,sBACE,6BAAC,eAAD;AACE,IAAA,GAAG,EAAEmB,GADP;AAEE,IAAA,KAAK,EAAEV,KAFT;AAGE,IAAA,MAAM,EAAEmB,MAHV;AAIE,IAAA,IAAI,EAAEjB,IAJR;AAKE,IAAA,KAAK,EAAED;AALT,IADF;AASD,CA3EmB,CAAf;AA8EP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMU,eAAe,GAAG,YAEnB;AAAA,oCADAsB,IACA;AADAA,IAAAA,IACA;AAAA;;AACH,QAAMC,SAAS,GAAGC,eAAMC,MAAN,CAAgB,IAAhB,CAAlB;;AACAD,iBAAME,SAAN,CAAgB,MAAM;AACpBJ,IAAAA,IAAI,CAACK,OAAL,CAAc5B,GAAD,IAAS;AACpB,UAAIA,GAAJ,EAAS;AACP,YAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,UAAAA,GAAG,CAACwB,SAAS,CAACV,OAAX,CAAH;AACD,SAFD,MAEO;AACLd,UAAAA,GAAG,CAACc,OAAJ,GAAcU,SAAS,CAACV,OAAxB;AACD;AACF;AACF,KARD;AASD,GAVD,EAUG,CAACS,IAAD,CAVH;;AAWA,SAAOC,SAAP;AACD,CAhBD","sourcesContent":["import React, {\n useEffect,\n useState,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport { SkiaView, useDrawCallback } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { useValue } from \"../values/hooks/useValue\";\nimport { Skia } from \"../skia/Skia\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./nodes\";\nimport { DependencyManager } from \"./DependencyManager\";\nimport { CanvasProvider } from \"./useCanvas\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n\n container.depMgr.subscribe();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaView>(null);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaView> {\n ref?: RefObject<SkiaView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaView, CanvasProps>(\n ({ children, style, debug, mode, onTouch }, forwardedRef) => {\n const size = useValue({ width: 0, height: 0 });\n const canvasCtx = useMemo(() => ({ Skia, size }), [size]);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [tick, setTick] = useState(0);\n const redraw = useCallback(() => setTick((t) => t + 1), []);\n\n const container = useMemo(\n () => new Container(new DependencyManager(ref), redraw),\n [redraw, ref]\n );\n\n const root = useMemo(\n () => skiaReconciler.createContainer(container, 0, false, null),\n [container]\n );\n // Render effect\n useEffect(() => {\n render(\n <CanvasProvider value={canvasCtx}>{children}</CanvasProvider>,\n root,\n container\n );\n }, [children, root, redraw, container, canvasCtx]);\n\n // Draw callback\n const onDraw = useDrawCallback(\n (canvas, info) => {\n // TODO: if tree is empty (count === 1) maybe we should not render?\n const { width, height, timestamp } = info;\n if (onTouch) {\n onTouch(info.touches);\n }\n if (\n width !== canvasCtx.size.current.width ||\n height !== canvasCtx.size.current.height\n ) {\n canvasCtx.size.current = { width, height };\n }\n const paint = Skia.Paint();\n const ctx = {\n width,\n height,\n timestamp,\n canvas,\n paint,\n opacity: 1,\n ref,\n center: Skia.Point(width / 2, height / 2),\n Skia,\n };\n container.draw(ctx);\n },\n [tick, onTouch]\n );\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.unsubscribe();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaView\n ref={ref}\n style={style}\n onDraw={onDraw}\n mode={mode}\n debug={debug}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"]}
|
@@ -9,8 +9,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
10
10
|
var _Drawing = require("../../nodes/Drawing");
|
11
11
|
|
12
|
-
var _Font = require("../../processors/Font");
|
13
|
-
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
13
|
|
16
14
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -18,9 +16,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
18
16
|
const onDraw = (0, _Drawing.createDrawing)((_ref, _ref2) => {
|
19
17
|
let {
|
20
18
|
canvas,
|
21
|
-
paint
|
22
|
-
fontMgr,
|
23
|
-
Skia
|
19
|
+
paint
|
24
20
|
} = _ref;
|
25
21
|
let {
|
26
22
|
glyphs: rawGlyphs,
|
@@ -28,7 +24,9 @@ const onDraw = (0, _Drawing.createDrawing)((_ref, _ref2) => {
|
|
28
24
|
y,
|
29
25
|
...fontDef
|
30
26
|
} = _ref2;
|
31
|
-
const
|
27
|
+
const {
|
28
|
+
font
|
29
|
+
} = fontDef;
|
32
30
|
const {
|
33
31
|
glyphs,
|
34
32
|
positions
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Glyphs.tsx"],"names":["onDraw","canvas","paint","
|
1
|
+
{"version":3,"sources":["Glyphs.tsx"],"names":["onDraw","canvas","paint","glyphs","rawGlyphs","x","y","fontDef","font","positions","reduce","acc","glyph","id","pos","push","drawGlyphs","Glyphs","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;AAqBA,MAAMA,MAAM,GAAG,4BACb,iBAAgE;AAAA,MAA/D;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA+D;AAAA,MAA5C;AAAEC,IAAAA,MAAM,EAAEC,SAAV;AAAqBC,IAAAA,CAArB;AAAwBC,IAAAA,CAAxB;AAA2B,OAAGC;AAA9B,GAA4C;AAC9D,QAAM;AAAEC,IAAAA;AAAF,MAAWD,OAAjB;AACA,QAAM;AAAEJ,IAAAA,MAAF;AAAUM,IAAAA;AAAV,MAAwBL,SAAS,CAACM,MAAV,CAC5B,CAACC,GAAD,EAAMC,KAAN,KAAgB;AACd,UAAM;AAAEC,MAAAA,EAAF;AAAMC,MAAAA;AAAN,QAAcF,KAApB;AACAD,IAAAA,GAAG,CAACR,MAAJ,CAAWY,IAAX,CAAgBF,EAAhB;AACAF,IAAAA,GAAG,CAACF,SAAJ,CAAcM,IAAd,CAAmBD,GAAnB;AACA,WAAOH,GAAP;AACD,GAN2B,EAO5B;AAAER,IAAAA,MAAM,EAAE,EAAV;AAAcM,IAAAA,SAAS,EAAE;AAAzB,GAP4B,CAA9B;AASAR,EAAAA,MAAM,CAACe,UAAP,CAAkBb,MAAlB,EAA0BM,SAA1B,EAAqCJ,CAArC,EAAwCC,CAAxC,EAA2CE,IAA3C,EAAiDN,KAAjD;AACD,CAbY,CAAf;;AAgBO,MAAMe,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAW,IAAA,MAAM,EAAElB;AAAnB,KAA+BkB,KAA/B,EAAP;AACD,CAFM;;;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpBd,EAAAA,CAAC,EAAE,CADiB;AAEpBC,EAAAA,CAAC,EAAE;AAFiB,CAAtB","sourcesContent":["import React from \"react\";\n\nimport type { CustomPaintProps, AnimatedProps } from \"../../processors\";\nimport { createDrawing } from \"../../nodes/Drawing\";\nimport type { SkPoint } from \"../../../skia/types\";\nimport type { FontDef } from \"../../processors/Font\";\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport type GlyphsProps = CustomPaintProps &\n FontDef & {\n x: number;\n y: number;\n glyphs: Glyph[];\n };\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nconst onDraw = createDrawing<GlyphsProps>(\n ({ canvas, paint }, { glyphs: rawGlyphs, x, y, ...fontDef }) => {\n const { font } = fontDef;\n const { glyphs, positions } = rawGlyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n canvas.drawGlyphs(glyphs, positions, x, y, font, paint);\n }\n);\n\nexport const Glyphs = (props: AnimatedProps<GlyphsProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nGlyphs.defaultProps = {\n x: 0,\n y: 0,\n};\n"]}
|
@@ -9,8 +9,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
10
10
|
var _Drawing = require("../../nodes/Drawing");
|
11
11
|
|
12
|
-
var _processors = require("../../processors");
|
13
|
-
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
13
|
|
16
14
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -18,9 +16,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
18
16
|
const onDraw = (0, _Drawing.createDrawing)((_ref, _ref2) => {
|
19
17
|
let {
|
20
18
|
canvas,
|
21
|
-
paint
|
22
|
-
fontMgr,
|
23
|
-
Skia
|
19
|
+
paint
|
24
20
|
} = _ref;
|
25
21
|
let {
|
26
22
|
text,
|
@@ -28,7 +24,9 @@ const onDraw = (0, _Drawing.createDrawing)((_ref, _ref2) => {
|
|
28
24
|
y,
|
29
25
|
...fontDef
|
30
26
|
} = _ref2;
|
31
|
-
const
|
27
|
+
const {
|
28
|
+
font
|
29
|
+
} = fontDef;
|
32
30
|
canvas.drawText(text, x, y, paint, font);
|
33
31
|
});
|
34
32
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Text.tsx"],"names":["onDraw","canvas","paint","
|
1
|
+
{"version":3,"sources":["Text.tsx"],"names":["onDraw","canvas","paint","text","x","y","fontDef","font","drawText","Text","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAOA;;;;;;AASA,MAAMA,MAAM,GAAG,4BACb,iBAAmD;AAAA,MAAlD;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAkD;AAAA,MAA/B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,CAAR;AAAWC,IAAAA,CAAX;AAAc,OAAGC;AAAjB,GAA+B;AACjD,QAAM;AAAEC,IAAAA;AAAF,MAAWD,OAAjB;AACAL,EAAAA,MAAM,CAACO,QAAP,CAAgBL,IAAhB,EAAsBC,CAAtB,EAAyBC,CAAzB,EAA4BH,KAA5B,EAAmCK,IAAnC;AACD,CAJY,CAAf;;AAOO,MAAME,IAAI,GAAIC,KAAD,IAAqC;AACvD,sBAAO;AAAW,IAAA,MAAM,EAAEV;AAAnB,KAA+BU,KAA/B,EAAP;AACD,CAFM;;;AAIPD,IAAI,CAACE,YAAL,GAAoB;AAClBP,EAAAA,CAAC,EAAE,CADe;AAElBC,EAAAA,CAAC,EAAE;AAFe,CAApB","sourcesContent":["import React from \"react\";\n\nimport type {\n CustomPaintProps,\n AnimatedProps,\n FontDef,\n} from \"../../processors\";\nimport { createDrawing } from \"../../nodes/Drawing\";\n\ntype TextProps = CustomPaintProps &\n FontDef & {\n text: string;\n x: number;\n y: number;\n };\n\nconst onDraw = createDrawing<TextProps>(\n ({ canvas, paint }, { text, x, y, ...fontDef }) => {\n const { font } = fontDef;\n canvas.drawText(text, x, y, paint, font);\n }\n);\n\nexport const Text = (props: AnimatedProps<TextProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nText.defaultProps = {\n x: 0,\n y: 0,\n};\n"]}
|
@@ -9,8 +9,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
10
10
|
var _nodes = require("../../nodes");
|
11
11
|
|
12
|
-
var _Font = require("../../processors/Font");
|
13
|
-
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
13
|
|
16
14
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -19,7 +17,6 @@ const onDraw = (0, _nodes.createDrawing)((_ref, _ref2) => {
|
|
19
17
|
let {
|
20
18
|
canvas,
|
21
19
|
paint,
|
22
|
-
fontMgr,
|
23
20
|
Skia
|
24
21
|
} = _ref;
|
25
22
|
let {
|
@@ -34,7 +31,9 @@ const onDraw = (0, _nodes.createDrawing)((_ref, _ref2) => {
|
|
34
31
|
throw new Error("Invalid path: " + pathDef);
|
35
32
|
}
|
36
33
|
|
37
|
-
const
|
34
|
+
const {
|
35
|
+
font
|
36
|
+
} = fontDef;
|
38
37
|
const ids = font.getGlyphIDs(text);
|
39
38
|
const widths = font.getGlyphWidths(ids, paint);
|
40
39
|
const rsx = [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["TextPath.tsx"],"names":["onDraw","canvas","paint","
|
1
|
+
{"version":3,"sources":["TextPath.tsx"],"names":["onDraw","canvas","paint","Skia","text","initialOffset","path","pathDef","fontDef","Path","MakeFromSVGString","Error","font","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","width","substring","px","py","tx","ty","getPosTan","adjustedX","adjustedY","push","RSXform","blob","TextBlob","MakeFromRSXform","drawTextBlob","TextPath","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;AAWA,MAAMA,MAAM,GAAG,0BACb,iBAGK;AAAA,MAFH;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA;AAAjB,GAEG;AAAA,MADH;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,aAAR;AAAuBC,IAAAA,IAAI,EAAEC,OAA7B;AAAsC,OAAGC;AAAzC,GACG;AACH,QAAMF,IAAI,GACR,OAAOC,OAAP,KAAmB,QAAnB,GACIJ,IAAI,CAACM,IAAL,CAAUC,iBAAV,CAA4BH,OAA5B,CADJ,GAEIA,OAHN;;AAIA,MAAID,IAAI,KAAK,IAAb,EAAmB;AACjB,UAAM,IAAIK,KAAJ,CAAU,mBAAmBJ,OAA7B,CAAN;AACD;;AACD,QAAM;AAAEK,IAAAA;AAAF,MAAWJ,OAAjB;AACA,QAAMK,GAAG,GAAGD,IAAI,CAACE,WAAL,CAAiBV,IAAjB,CAAZ;AACA,QAAMW,MAAM,GAAGH,IAAI,CAACI,cAAL,CAAoBH,GAApB,EAAyBX,KAAz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I,GAAGjC,IAAI,CAACkC,QAAL,CAAcC,eAAd,CAA8BlC,IAA9B,EAAoCa,GAApC,EAAyCL,IAAzC,CAAb;AACAX,EAAAA,MAAM,CAACsC,YAAP,CAAoBH,IAApB,EAA0B,CAA1B,EAA6B,CAA7B,EAAgClC,KAAhC;AACD,CA3CY,CAAf;;AA8CO,MAAMsC,QAAQ,GAAIC,KAAD,IAAyC;AAC/D,sBAAO;AAAW,IAAA,MAAM,EAAEzC;AAAnB,KAA+ByC,KAA/B,EAAP;AACD,CAFM;;;AAIPD,QAAQ,CAACE,YAAT,GAAwB;AACtBrC,EAAAA,aAAa,EAAE;AADO,CAAxB","sourcesContent":["import React from \"react\";\n\nimport type { CustomPaintProps, AnimatedProps } from \"../../processors\";\nimport { createDrawing } from \"../../nodes\";\nimport type { SkPath, SkRSXform } from \"../../../skia/types\";\nimport type { FontDef } from \"../../processors/Font\";\n\nexport type TextPathProps = CustomPaintProps &\n FontDef & {\n text: string;\n path: SkPath | string;\n initialOffset: number;\n };\n\nconst onDraw = createDrawing<TextPathProps>(\n (\n { canvas, paint, Skia },\n { text, initialOffset, path: pathDef, ...fontDef }\n ) => {\n const path =\n typeof pathDef === \"string\"\n ? Skia.Path.MakeFromSVGString(pathDef)\n : pathDef;\n if (path === null) {\n throw new Error(\"Invalid path: \" + pathDef);\n }\n const { font } = fontDef;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids, paint);\n const rsx: SkRSXform[] = [];\n const meas = Skia.ContourMeasureIter(path, false, 1);\n let cont = meas.next();\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = meas.next();\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const { px, py, tx, ty } = cont.getPosTan(dist);\n const adjustedX = px - (width / 2) * tx;\n const adjustedY = py - (width / 2) * ty;\n rsx.push(Skia.RSXform(tx, ty, adjustedX, adjustedY));\n dist += width / 2;\n }\n const blob = Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n canvas.drawTextBlob(blob, 0, 0, paint);\n }\n);\n\nexport const TextPath = (props: AnimatedProps<TextPathProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nTextPath.defaultProps = {\n initialOffset: 0,\n};\n"]}
|
@@ -3,37 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.isFont = void 0;
|
7
7
|
|
8
8
|
const isFont = fontDef => // We have an issue to check property existence on JSI backed instances
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
10
10
|
fontDef.font !== undefined;
|
11
11
|
|
12
12
|
exports.isFont = isFont;
|
13
|
-
|
14
|
-
const processFont = (Skia, fontMgr, fontDef) => {
|
15
|
-
let selectedFont;
|
16
|
-
|
17
|
-
if (isFont(fontDef)) {
|
18
|
-
selectedFont = fontDef.font;
|
19
|
-
} else {
|
20
|
-
console.warn( // eslint-disable-next-line max-len
|
21
|
-
"Using system fonts is deprecated. Please use the font property instead: https://shopify.github.io/react-native-skia/docs/text/fonts");
|
22
|
-
const {
|
23
|
-
familyName,
|
24
|
-
size
|
25
|
-
} = fontDef;
|
26
|
-
const typeface = fontMgr.matchFamilyStyle(familyName);
|
27
|
-
|
28
|
-
if (typeface === null) {
|
29
|
-
throw new Error(`No typeface found for ${familyName}`);
|
30
|
-
}
|
31
|
-
|
32
|
-
selectedFont = Skia.Font(typeface, size);
|
33
|
-
}
|
34
|
-
|
35
|
-
return selectedFont;
|
36
|
-
};
|
37
|
-
|
38
|
-
exports.processFont = processFont;
|
39
13
|
//# sourceMappingURL=Font.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Font.ts"],"names":["isFont","fontDef","font","undefined"
|
1
|
+
{"version":3,"sources":["Font.ts"],"names":["isFont","fontDef","font","undefined"],"mappings":";;;;;;;AAIO,MAAMA,MAAM,GAAIC,OAAD,IACpB;AACA;AACCA,OAAD,CAAiBC,IAAjB,KAA0BC,SAHrB","sourcesContent":["import type { SkFont } from \"../../skia/types\";\n\nexport type FontDef = { font: SkFont };\n\nexport const isFont = (fontDef: FontDef): fontDef is { font: SkFont } =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (fontDef as any).font !== undefined;\n"]}
|
@@ -28,15 +28,14 @@ const factoryWrapper = (data2, factory, onError) => {
|
|
28
28
|
|
29
29
|
const loadDataCollection = (sources, factory, onError) => Promise.all(sources.map(source => loadData(source, factory, onError)));
|
30
30
|
|
31
|
-
const loadData =
|
31
|
+
const loadData = (source, factory, onError) => {
|
32
32
|
if (source === null) {
|
33
|
-
return null;
|
33
|
+
return new Promise(resolve => resolve(null));
|
34
34
|
} else if (source instanceof Uint8Array) {
|
35
|
-
return factoryWrapper(_Skia.Skia.Data.fromBytes(source), factory, onError);
|
35
|
+
return new Promise(resolve => resolve(factoryWrapper(_Skia.Skia.Data.fromBytes(source), factory, onError)));
|
36
36
|
} else {
|
37
37
|
const uri = typeof source === "string" ? source : resolveAsset(source);
|
38
|
-
|
39
|
-
return factoryWrapper(d, factory, onError);
|
38
|
+
return _Skia.Skia.Data.fromURI(uri).then(d => factoryWrapper(d, factory, onError));
|
40
39
|
}
|
41
40
|
};
|
42
41
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Data.ts"],"names":["resolveAsset","source","Platform","OS","default","Image","resolveAssetSource","uri","factoryWrapper","data2","factory","onError","factoryResult","Error","loadDataCollection","sources","Promise","all","map","loadData","Uint8Array","Skia","Data","fromBytes","
|
1
|
+
{"version":3,"sources":["Data.ts"],"names":["resolveAsset","source","Platform","OS","default","Image","resolveAssetSource","uri","factoryWrapper","data2","factory","onError","factoryResult","Error","loadDataCollection","sources","Promise","all","map","loadData","resolve","Uint8Array","Skia","Data","fromBytes","fromURI","then","d","useLoading","loader","deps","data","setData","prevSourceRef","current","useDataCollection","useRawData","identity","useData"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AAGA,MAAMA,YAAY,GAAIC,MAAD,IAAwC;AAC3D,SAAOC,sBAASC,EAAT,KAAgB,KAAhB,GACHF,MAAM,CAACG,OADJ,GAEHC,mBAAMC,kBAAN,CAAyBL,MAAzB,EAAiCM,GAFrC;AAGD,CAJD;;AAMA,MAAMC,cAAc,GAAG,CACrBC,KADqB,EAErBC,OAFqB,EAGrBC,OAHqB,KAIlB;AACH,QAAMC,aAAa,GAAGF,OAAO,CAACD,KAAD,CAA7B;;AACA,MAAIG,aAAa,KAAK,IAAtB,EAA4B;AAC1BD,IAAAA,OAAO,IAAIA,OAAO,CAAC,IAAIE,KAAJ,CAAU,qBAAV,CAAD,CAAlB;AACA,WAAO,IAAP;AACD,GAHD,MAGO;AACL,WAAOD,aAAP;AACD;AACF,CAZD;;AAcA,MAAME,kBAAkB,GAAG,CACzBC,OADyB,EAEzBL,OAFyB,EAGzBC,OAHyB,KAKzBK,OAAO,CAACC,GAAR,CAAYF,OAAO,CAACG,GAAR,CAAajB,MAAD,IAAYkB,QAAQ,CAAClB,MAAD,EAASS,OAAT,EAAkBC,OAAlB,CAAhC,CAAZ,CALF;;AAOA,MAAMQ,QAAQ,GAAG,CACflB,MADe,EAEfS,OAFe,EAGfC,OAHe,KAIO;AACtB,MAAIV,MAAM,KAAK,IAAf,EAAqB;AACnB,WAAO,IAAIe,OAAJ,CAAaI,OAAD,IAAaA,OAAO,CAAC,IAAD,CAAhC,CAAP;AACD,GAFD,MAEO,IAAInB,MAAM,YAAYoB,UAAtB,EAAkC;AACvC,WAAO,IAAIL,OAAJ,CAAaI,OAAD,IACjBA,OAAO,CAACZ,cAAc,CAACc,WAAKC,IAAL,CAAUC,SAAV,CAAoBvB,MAApB,CAAD,EAA8BS,OAA9B,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;;;;AAOP,MAAMO,QAAQ,GAAIN,IAAD,IAAkBA,IAAnC;;AAEO,MAAMO,OAAO,GAAG,CACrBrC,MADqB,EAErBU,OAFqB,EAGrBmB,IAHqB,KAIlBM,UAAU,CAACnC,MAAD,EAASoC,QAAT,EAAmB1B,OAAnB,EAA4BmB,IAA5B,CAJR","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useRef, useEffect, useState } from \"react\";\nimport { Image, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSource } from \"../types\";\n\nconst resolveAsset = (source: ReturnType<typeof require>) => {\n return Platform.OS === \"web\"\n ? source.default\n : Image.resolveAssetSource(source).uri;\n};\n\nconst factoryWrapper = <T>(\n data2: SkData,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n return null;\n } else {\n return factoryResult;\n }\n};\n\nconst loadDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<(T | null)[]> =>\n Promise.all(sources.map((source) => loadData(source, factory, onError)));\n\nconst loadData = <T>(\n source: DataSource,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source === null) {\n return new Promise((resolve) => resolve(null));\n } else if (source instanceof Uint8Array) {\n return new Promise((resolve) =>\n resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError))\n );\n } else {\n const uri = typeof source === \"string\" ? source : resolveAsset(source);\n return Skia.Data.fromURI(uri).then((d) =>\n factoryWrapper(d, factory, onError)\n );\n }\n};\n\ntype Source = DataSource | null | undefined;\n\nconst useLoading = <T>(\n source: Source,\n loader: () => Promise<T | null>,\n deps: DependencyList = []\n) => {\n const [data, setData] = useState<T | null>(null);\n const prevSourceRef = useRef<Source>();\n useEffect(() => {\n if (prevSourceRef.current !== source) {\n prevSourceRef.current = source;\n loader().then(setData);\n } else {\n setData(null);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n return data;\n};\n\nexport const useDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) =>\n useLoading(\n sources,\n () => loadDataCollection(sources, factory, onError),\n deps\n );\n\nexport const useRawData = <T>(\n source: DataSource | null | undefined,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useLoading(source, () => loadData(source, factory, onError), deps);\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useRawData(source, identity, onError, deps);\n"]}
|
@@ -9,10 +9,13 @@ var _Skia = require("../Skia");
|
|
9
9
|
|
10
10
|
var _Data = require("./Data");
|
11
11
|
|
12
|
+
const imgFactory = _Skia.Skia.Image.MakeImageFromEncoded.bind(_Skia.Skia.Image);
|
12
13
|
/**
|
13
14
|
* Returns a Skia Image object
|
14
15
|
* */
|
15
|
-
|
16
|
+
|
17
|
+
|
18
|
+
const useImage = (source, onError) => (0, _Data.useRawData)(source, imgFactory, onError);
|
16
19
|
|
17
20
|
exports.useImage = useImage;
|
18
21
|
//# sourceMappingURL=Image.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Image.ts"],"names":["
|
1
|
+
{"version":3,"sources":["Image.ts"],"names":["imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,UAAU,GAAGC,WAAKC,KAAL,CAAWC,oBAAX,CAAgCC,IAAhC,CAAqCH,WAAKC,KAA1C,CAAnB;AAEA;AACA;AACA;;;AACO,MAAMG,QAAQ,GAAG,CACtBC,MADsB,EAEtBC,OAFsB,KAGnB,sBAAWD,MAAX,EAAmBN,UAAnB,EAA+BO,OAA/B,CAHE","sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSource } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n"]}
|
@@ -9,7 +9,9 @@ var _Skia = require("../Skia");
|
|
9
9
|
|
10
10
|
var _Data = require("./Data");
|
11
11
|
|
12
|
-
const
|
12
|
+
const svgFactory = _Skia.Skia.SVG.MakeFromData.bind(_Skia.Skia.SVG);
|
13
|
+
|
14
|
+
const useSVG = (source, onError) => (0, _Data.useRawData)(source, svgFactory, onError);
|
13
15
|
|
14
16
|
exports.useSVG = useSVG;
|
15
17
|
//# sourceMappingURL=SVG.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["SVG.ts"],"names":["
|
1
|
+
{"version":3,"sources":["SVG.ts"],"names":["svgFactory","Skia","SVG","MakeFromData","bind","useSVG","source","onError"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,UAAU,GAAGC,WAAKC,GAAL,CAASC,YAAT,CAAsBC,IAAtB,CAA2BH,WAAKC,GAAhC,CAAnB;;AAEO,MAAMG,MAAM,GAAG,CACpBC,MADoB,EAEpBC,OAFoB,KAGjB,sBAAWD,MAAX,EAAmBN,UAAnB,EAA+BO,OAA/B,CAHE","sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSource } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst svgFactory = Skia.SVG.MakeFromData.bind(Skia.SVG);\n\nexport const useSVG = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void\n) => useRawData(source, svgFactory, onError);\n"]}
|
@@ -9,10 +9,13 @@ var _Skia = require("../Skia");
|
|
9
9
|
|
10
10
|
var _Data = require("./Data");
|
11
11
|
|
12
|
+
const tfFactory = _Skia.Skia.Typeface.MakeFreeTypeFaceFromData.bind(_Skia.Skia.Typeface);
|
12
13
|
/**
|
13
14
|
* Returns a Skia Typeface object
|
14
15
|
* */
|
15
|
-
|
16
|
+
|
17
|
+
|
18
|
+
const useTypeface = (source, onError) => (0, _Data.useRawData)(source, tfFactory, onError);
|
16
19
|
|
17
20
|
exports.useTypeface = useTypeface;
|
18
21
|
//# sourceMappingURL=Typeface.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Typeface.ts"],"names":["
|
1
|
+
{"version":3,"sources":["Typeface.ts"],"names":["tfFactory","Skia","Typeface","MakeFreeTypeFaceFromData","bind","useTypeface","source","onError"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,SAAS,GAAGC,WAAKC,QAAL,CAAcC,wBAAd,CAAuCC,IAAvC,CAA4CH,WAAKC,QAAjD,CAAlB;AAEA;AACA;AACA;;;AACO,MAAMG,WAAW,GAAG,CACzBC,MADyB,EAEzBC,OAFyB,KAGtB,sBAAWD,MAAX,EAAmBN,SAAnB,EAA8BO,OAA9B,CAHE","sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSource } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst tfFactory = Skia.Typeface.MakeFreeTypeFaceFromData.bind(Skia.Typeface);\n\n/**\n * Returns a Skia Typeface object\n * */\nexport const useTypeface = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void\n) => useRawData(source, tfFactory, onError);\n"]}
|
@@ -82,19 +82,6 @@ Object.keys(_SVG).forEach(function (key) {
|
|
82
82
|
});
|
83
83
|
});
|
84
84
|
|
85
|
-
var _Path = require("./Path");
|
86
|
-
|
87
|
-
Object.keys(_Path).forEach(function (key) {
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
89
|
-
if (key in exports && exports[key] === _Path[key]) return;
|
90
|
-
Object.defineProperty(exports, key, {
|
91
|
-
enumerable: true,
|
92
|
-
get: function () {
|
93
|
-
return _Path[key];
|
94
|
-
}
|
95
|
-
});
|
96
|
-
});
|
97
|
-
|
98
85
|
var _Vector = require("./Vector");
|
99
86
|
|
100
87
|
Object.keys(_Vector).forEach(function (key) {
|
@@ -146,17 +133,4 @@ Object.keys(_Matrix).forEach(function (key) {
|
|
146
133
|
}
|
147
134
|
});
|
148
135
|
});
|
149
|
-
|
150
|
-
var _Paint = require("./Paint");
|
151
|
-
|
152
|
-
Object.keys(_Paint).forEach(function (key) {
|
153
|
-
if (key === "default" || key === "__esModule") return;
|
154
|
-
if (key in exports && exports[key] === _Paint[key]) return;
|
155
|
-
Object.defineProperty(exports, key, {
|
156
|
-
enumerable: true,
|
157
|
-
get: function () {
|
158
|
-
return _Paint[key];
|
159
|
-
}
|
160
|
-
});
|
161
|
-
});
|
162
136
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from \"./Data\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Image\";\nexport * from \"./Picture\";\nexport * from \"./SVG\";\nexport * from \"./Vector\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./Matrix\";\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Font.ts"],"names":["fontStyle","weight","width","slant","FontWeight","FontWidth","FontSlant","FontEdging","FontHinting","FontStyle","Normal","Upright","Bold","Italic","BoldItalic"],"mappings":";;;;;;;
|
1
|
+
{"version":3,"sources":["Font.ts"],"names":["fontStyle","weight","width","slant","FontWeight","FontWidth","FontSlant","FontEdging","FontHinting","FontStyle","Normal","Upright","Bold","Italic","BoldItalic"],"mappings":";;;;;;;AA4JA,MAAMA,SAAS,GAAG,CAChBC,MADgB,EAEhBC,KAFgB,EAGhBC,KAHgB,MAID;AAAEF,EAAAA,MAAF;AAAUC,E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Z,SAAS,CAACI,UAAU,CAACQ,IAAZ,EAAkBP,SAAS,CAACK,MAA5B,EAAoCJ,SAAS,CAACK,OAA9C,CAFQ;AAGvBE,EAAAA,MAAM,EAAEb,SAAS,CAACI,UAAU,CAACM,MAAZ,EAAoBL,SAAS,CAACK,MAA9B,EAAsCJ,SAAS,CAACO,MAAhD,CAHM;AAIvBC,EAAAA,UAAU,EAAEd,SAAS,CAACI,UAAU,CAACQ,IAAZ,EAAkBP,SAAS,CAACK,MAA5B,EAAoCJ,SAAS,CAACO,MAA9C;AAJE,CAAlB","sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkPaint } from \"../Paint\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkTypeface } from \"../Typeface\";\n\nexport interface FontMetrics {\n ascent: number; // suggested space above the baseline. < 0\n descent: number; // suggested space below the baseline. > 0\n leading: number; // suggested spacing between descent of previous line and ascent of next line.\n bounds?: SkRect; // smallest rect containing all glyphs (relative to 0,0)\n}\n\nexport interface SkFont extends SkJSIInstance<\"Font\"> {\n /**\n * Retrieves the total width of the provided text\n * @param text\n * @param paint\n */\n getTextWidth(text: string, paint?: SkPaint): number;\n\n /**\n * Retrieves the advanceX measurements for each glyph.\n * If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected.\n * One width per glyph is returned in the returned array.\n * @param glyphs\n * @param paint\n */\n getGlyphWidths(glyphs: number[], paint?: SkPaint): number[];\n\n /**\n * Returns the FontMetrics for this font.\n */\n getMetrics(): FontMetrics;\n\n /**\n * Retrieves the glyph ids for each code point in the provided string. This call is passed to\n * the typeface of this font. Note that glyph IDs are typeface-dependent; different faces\n * may have different ids for the same code point.\n * @param str\n * @param numCodePoints - the number of code points in the string. Defaults to str.length.\n */\n getGlyphIDs(str: string, numCodePoints?: number): number[];\n\n /**\n * Computes any intersections of a thick \"line\" and a run of positionsed glyphs.\n * The thick line is represented as a top and bottom coordinate (positive for\n * below the baseline, negative for above). If there are no intersections\n * (e.g. if this is intended as an underline, and there are no \"collisions\")\n * then the returned array will be empty. If there are intersections, the array\n * will contain pairs of X coordinates [start, end] for each segment that\n * intersected with a glyph.\n *\n * @param glyphs the glyphs to intersect with\n * @param positions x,y coordinates (2 per glyph) for each glyph\n * @param top top of the thick \"line\" to use for intersection testing\n * @param bottom bottom of the thick \"line\" to use for intersection testing\n * @return array of [start, end] x-coordinate pairs. Maybe be empty.\n */\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ): number[];\n\n /**\n * Returns text scale on x-axis. Default value is 1.\n */\n getScaleX(): number;\n\n /**\n * Returns text size in points.\n */\n getSize(): number;\n\n /**\n * Returns text skew on x-axis. Default value is zero.\n */\n getSkewX(): number;\n\n /**\n * Returns embolden effect for this font. Default value is false.\n */\n isEmbolden(): boolean;\n\n /**\n * Returns the Typeface set for this font.\n */\n getTypeface(): SkTypeface | null;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with partial transparency.\n * @param edging\n */\n setEdging(edging: FontEdging): void;\n\n /**\n * Requests, but does not require, to use bitmaps in fonts instead of outlines.\n * @param embeddedBitmaps\n */\n setEmbeddedBitmaps(embeddedBitmaps: boolean): void;\n\n /**\n * Sets level of glyph outline adjustment.\n * @param hinting\n */\n setHinting(hinting: FontHinting): void;\n\n /**\n * Requests, but does not require, linearly scalable font and glyph metrics.\n *\n * For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding.\n * Note that some bitmap formats may not be able to scale linearly and will ignore this flag.\n * @param linearMetrics\n */\n setLinearMetrics(linearMetrics: boolean): void;\n\n /**\n * Sets the text scale on the x-axis.\n * @param sx\n */\n setScaleX(sx: number): void;\n\n /**\n * Sets the text size in points on this font.\n * @param points\n */\n setSize(points: number): void;\n\n /**\n * Sets the text-skew on the x axis for this font.\n * @param sx\n */\n setSkewX(sx: number): void;\n\n /**\n * Set embolden effect for this font.\n * @param embolden\n */\n setEmbolden(embolden: boolean): void;\n\n /**\n * Requests, but does not require, that glyphs respect sub-pixel positioning.\n * @param subpixel\n */\n setSubpixel(subpixel: boolean): void;\n\n /**\n * Sets the typeface to use with this font. null means to clear the typeface and use the\n * default one.\n * @param face\n */\n setTypeface(face: SkTypeface | null): void;\n}\n\nconst fontStyle = (\n weight: FontWeight,\n width: FontWidth,\n slant: FontSlant\n): FontStyle => ({ weight, width, slant });\n\nexport interface FontStyle {\n weight?: FontWeight;\n width?: FontWidth;\n slant?: FontSlant;\n}\n\nexport enum FontWeight {\n Invisible = 0,\n Thin = 100,\n ExtraLight = 200,\n Light = 300,\n Normal = 400,\n Medium = 500,\n SemiBold = 600,\n Bold = 700,\n ExtraBold = 800,\n Black = 900,\n ExtraBlack = 1000,\n}\n\nexport enum FontWidth {\n UltraCondensed = 1,\n ExtraCondensed = 2,\n Condensed = 3,\n SemiCondensed = 4,\n Normal = 5,\n SemiExpanded = 6,\n Expanded = 7,\n ExtraExpanded = 8,\n UltraExpanded = 9,\n}\n\nexport enum FontSlant {\n Upright,\n Italic,\n Oblique,\n}\n\nexport enum FontEdging {\n Alias,\n AntiAlias,\n SubpixelAntiAlias,\n}\n\nexport enum FontHinting {\n None,\n Slight,\n Normal,\n Full,\n}\n\nexport const FontStyle = {\n Normal: fontStyle(FontWeight.Normal, FontWidth.Normal, FontSlant.Upright),\n Bold: fontStyle(FontWeight.Bold, FontWidth.Normal, FontSlant.Upright),\n Italic: fontStyle(FontWeight.Normal, FontWidth.Normal, FontSlant.Italic),\n BoldItalic: fontStyle(FontWeight.Bold, FontWidth.Normal, FontSlant.Italic),\n};\n"]}
|