@ohos-ports/canvas 3.2.3-beta.1 → 3.2.3-beta.3
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/build/Release/canvas-postbuild.node +0 -0
- package/build/Release/canvas.node +0 -0
- package/index.js +1 -6
- package/lib/bindings.js +0 -13
- package/package.json +23 -13
- package/src/Backends.h +9 -0
- package/binding.gyp +0 -229
- package/install-prebuilt.js +0 -142
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -76,12 +76,7 @@ exports.createCanvas = createCanvas
|
|
|
76
76
|
exports.createImageData = createImageData
|
|
77
77
|
exports.loadImage = loadImage
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
// Backends.cc, not registered in init.cc). Only export it when the
|
|
81
|
-
// native module actually provides it.
|
|
82
|
-
if (bindings.Backends) {
|
|
83
|
-
exports.backends = bindings.Backends
|
|
84
|
-
}
|
|
79
|
+
exports.backends = bindings.Backends
|
|
85
80
|
|
|
86
81
|
/** Library version. */
|
|
87
82
|
exports.version = packageJson.version
|
package/lib/bindings.js
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
// On OpenHarmony the system fontconfig config file may be missing.
|
|
7
|
-
// Set FONTCONFIG_PATH so the .so bundled with this package picks up
|
|
8
|
-
// the fonts.conf that install-prebuilt.js drops next to canvas.node.
|
|
9
|
-
if (!process.env.FONTCONFIG_PATH) {
|
|
10
|
-
const buildDir = path.join(__dirname, '..', 'build', 'Release')
|
|
11
|
-
if (fs.existsSync(path.join(buildDir, 'fonts.conf'))) {
|
|
12
|
-
process.env.FONTCONFIG_PATH = buildDir
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
3
|
const bindings = require('../build/Release/canvas.node')
|
|
17
4
|
|
|
18
5
|
module.exports = bindings
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/canvas",
|
|
3
3
|
"description": "Canvas graphics API backed by Cairo",
|
|
4
|
-
"version": "3.2.3-beta.
|
|
4
|
+
"version": "3.2.3-beta.3",
|
|
5
5
|
"author": "TJ Holowaychuk <tj@learnboost.com>",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"browser": "browser.js",
|
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
"pdf"
|
|
23
23
|
],
|
|
24
24
|
"homepage": "https://github.com/Automattic/node-canvas",
|
|
25
|
-
"repository":
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
28
|
+
"directory": "ports/canvas/3.2.3"
|
|
29
|
+
},
|
|
26
30
|
"scripts": {
|
|
27
31
|
"prebenchmark": "node-gyp build",
|
|
28
32
|
"benchmark": "node benchmarks/run.js",
|
|
@@ -32,25 +36,20 @@
|
|
|
32
36
|
"test-server": "node test/server.js",
|
|
33
37
|
"generate-wpt": "node ./test/wpt/generate.js",
|
|
34
38
|
"test-wpt": "mocha test/wpt/generated/*.js",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
39
|
+
"tsd": "tsd",
|
|
40
|
+
"install": "node -e \"process.exit(0)\""
|
|
37
41
|
},
|
|
38
42
|
"files": [
|
|
39
|
-
"binding.gyp",
|
|
40
43
|
"browser.js",
|
|
41
44
|
"index.d.ts",
|
|
42
45
|
"index.js",
|
|
43
|
-
"install-prebuilt.js",
|
|
44
46
|
"lib/",
|
|
45
47
|
"src/",
|
|
46
|
-
"util/"
|
|
48
|
+
"util/",
|
|
49
|
+
"build/Release/*.node"
|
|
47
50
|
],
|
|
48
51
|
"dependencies": {
|
|
49
|
-
"node-addon-api": "^7.0.0"
|
|
50
|
-
"prebuild-install": "^7.1.3"
|
|
51
|
-
},
|
|
52
|
-
"optionalDependencies": {
|
|
53
|
-
"@ohos-ports/canvas-prebuilt-openharmony-arm64": "3.2.3-beta.0"
|
|
52
|
+
"node-addon-api": "^7.0.0"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@types/node": "^10.12.18",
|
|
@@ -71,5 +70,16 @@
|
|
|
71
70
|
7
|
|
72
71
|
]
|
|
73
72
|
},
|
|
74
|
-
"license": "MIT"
|
|
73
|
+
"license": "MIT",
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/ohos-ports/ohos-ports/issues"
|
|
76
|
+
},
|
|
77
|
+
"ohos_ports": {
|
|
78
|
+
"platform": "openharmony",
|
|
79
|
+
"arch": "arm64",
|
|
80
|
+
"native_artifact": "build/Release/canvas.node",
|
|
81
|
+
"source": "compiled from source on HarmonyOS (node-gyp + clang, harmonybrew cairo/pango/harfbuzz stack)",
|
|
82
|
+
"runtime_note": "requires LD_LIBRARY_PATH=$HOME/.harmonybrew/lib for brew shared libs (cairo, pango, harfbuzz, freetype, fontconfig, libjpeg, libpng, pixman, libintl)"
|
|
83
|
+
},
|
|
84
|
+
"gypfile": false
|
|
75
85
|
}
|
package/src/Backends.h
ADDED
package/binding.gyp
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
'conditions': [
|
|
3
|
-
['OS=="win"', {
|
|
4
|
-
'variables': {
|
|
5
|
-
'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle
|
|
6
|
-
'with_jpeg%': 'false',
|
|
7
|
-
'with_gif%': 'false',
|
|
8
|
-
'with_rsvg%': 'false',
|
|
9
|
-
'variables': { # Nest jpeg_root to evaluate it before with_jpeg
|
|
10
|
-
'jpeg_root%': '<!(node ./util/win_jpeg_lookup)'
|
|
11
|
-
},
|
|
12
|
-
'jpeg_root%': '<(jpeg_root)', # Take value of nested variable
|
|
13
|
-
'conditions': [
|
|
14
|
-
['jpeg_root==""', {
|
|
15
|
-
'with_jpeg%': 'false'
|
|
16
|
-
}, {
|
|
17
|
-
'with_jpeg%': 'true'
|
|
18
|
-
}]
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
}, { # 'OS!="win"'
|
|
22
|
-
'variables': {
|
|
23
|
-
'with_jpeg%': '<!(node ./util/has_lib.js jpeg)',
|
|
24
|
-
'with_gif%': '<!(node ./util/has_lib.js gif)',
|
|
25
|
-
'with_rsvg%': '<!(node ./util/has_lib.js rsvg)'
|
|
26
|
-
}
|
|
27
|
-
}]
|
|
28
|
-
],
|
|
29
|
-
'targets': [
|
|
30
|
-
{
|
|
31
|
-
'target_name': 'canvas-postbuild',
|
|
32
|
-
'dependencies': ['canvas'],
|
|
33
|
-
'conditions': [
|
|
34
|
-
['OS=="win"', {
|
|
35
|
-
'copies': [{
|
|
36
|
-
'destination': '<(PRODUCT_DIR)',
|
|
37
|
-
'files': [
|
|
38
|
-
'<(GTK_Root)/bin/zlib1.dll',
|
|
39
|
-
'<(GTK_Root)/bin/libintl-8.dll',
|
|
40
|
-
'<(GTK_Root)/bin/libpng14-14.dll',
|
|
41
|
-
'<(GTK_Root)/bin/libpangocairo-1.0-0.dll',
|
|
42
|
-
'<(GTK_Root)/bin/libpango-1.0-0.dll',
|
|
43
|
-
'<(GTK_Root)/bin/libpangoft2-1.0-0.dll',
|
|
44
|
-
'<(GTK_Root)/bin/libpangowin32-1.0-0.dll',
|
|
45
|
-
'<(GTK_Root)/bin/libcairo-2.dll',
|
|
46
|
-
'<(GTK_Root)/bin/libfontconfig-1.dll',
|
|
47
|
-
'<(GTK_Root)/bin/libfreetype-6.dll',
|
|
48
|
-
'<(GTK_Root)/bin/libglib-2.0-0.dll',
|
|
49
|
-
'<(GTK_Root)/bin/libgobject-2.0-0.dll',
|
|
50
|
-
'<(GTK_Root)/bin/libgmodule-2.0-0.dll',
|
|
51
|
-
'<(GTK_Root)/bin/libgthread-2.0-0.dll',
|
|
52
|
-
'<(GTK_Root)/bin/libexpat-1.dll'
|
|
53
|
-
]
|
|
54
|
-
}]
|
|
55
|
-
}]
|
|
56
|
-
]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
'target_name': 'canvas',
|
|
60
|
-
'include_dirs': ["<!(node -p \"require('node-addon-api').include_dir\")"],
|
|
61
|
-
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS', 'NODE_ADDON_API_ENABLE_MAYBE' ],
|
|
62
|
-
'sources': [
|
|
63
|
-
'src/bmp/BMPParser.cc',
|
|
64
|
-
'src/Canvas.cc',
|
|
65
|
-
'src/CanvasGradient.cc',
|
|
66
|
-
'src/CanvasPattern.cc',
|
|
67
|
-
'src/CanvasRenderingContext2d.cc',
|
|
68
|
-
'src/closure.cc',
|
|
69
|
-
'src/color.cc',
|
|
70
|
-
'src/Image.cc',
|
|
71
|
-
'src/ImageData.cc',
|
|
72
|
-
'src/init.cc',
|
|
73
|
-
'src/register_font.cc',
|
|
74
|
-
'src/FontParser.cc'
|
|
75
|
-
],
|
|
76
|
-
'conditions': [
|
|
77
|
-
['OS=="win"', {
|
|
78
|
-
'libraries': [
|
|
79
|
-
'-l<(GTK_Root)/lib/cairo.lib',
|
|
80
|
-
'-l<(GTK_Root)/lib/libpng.lib',
|
|
81
|
-
'-l<(GTK_Root)/lib/pangocairo-1.0.lib',
|
|
82
|
-
'-l<(GTK_Root)/lib/pango-1.0.lib',
|
|
83
|
-
'-l<(GTK_Root)/lib/freetype.lib',
|
|
84
|
-
'-l<(GTK_Root)/lib/glib-2.0.lib',
|
|
85
|
-
'-l<(GTK_Root)/lib/gobject-2.0.lib'
|
|
86
|
-
],
|
|
87
|
-
'include_dirs': [
|
|
88
|
-
'<(GTK_Root)/include',
|
|
89
|
-
'<(GTK_Root)/include/cairo',
|
|
90
|
-
'<(GTK_Root)/include/pango-1.0',
|
|
91
|
-
'<(GTK_Root)/include/glib-2.0',
|
|
92
|
-
'<(GTK_Root)/include/freetype2',
|
|
93
|
-
'<(GTK_Root)/lib/glib-2.0/include'
|
|
94
|
-
],
|
|
95
|
-
'defines': [
|
|
96
|
-
'_USE_MATH_DEFINES', # for M_PI
|
|
97
|
-
'NOMINMAX' # allow std::min/max to work
|
|
98
|
-
],
|
|
99
|
-
'configurations': {
|
|
100
|
-
'Debug': {
|
|
101
|
-
'msvs_settings': {
|
|
102
|
-
'VCCLCompilerTool': {
|
|
103
|
-
'WarningLevel': 4,
|
|
104
|
-
'ExceptionHandling': 1,
|
|
105
|
-
'DisableSpecificWarnings': [
|
|
106
|
-
4100, 4611
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
'Release': {
|
|
112
|
-
'msvs_settings': {
|
|
113
|
-
'VCCLCompilerTool': {
|
|
114
|
-
'WarningLevel': 4,
|
|
115
|
-
'ExceptionHandling': 1,
|
|
116
|
-
'DisableSpecificWarnings': [
|
|
117
|
-
4100, 4611
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, { # 'OS!="win"'
|
|
124
|
-
'libraries': [
|
|
125
|
-
'<!@(pkg-config pixman-1 --libs)',
|
|
126
|
-
'<!@(pkg-config cairo --libs)',
|
|
127
|
-
'<!@(pkg-config libpng --libs)',
|
|
128
|
-
'<!@(pkg-config pangocairo --libs)',
|
|
129
|
-
'<!@(pkg-config freetype2 --libs)'
|
|
130
|
-
],
|
|
131
|
-
'include_dirs': [
|
|
132
|
-
'<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)',
|
|
133
|
-
'<!@(pkg-config libpng --cflags-only-I | sed s/-I//g)',
|
|
134
|
-
'<!@(pkg-config pangocairo --cflags-only-I | sed s/-I//g)',
|
|
135
|
-
'<!@(pkg-config freetype2 --cflags-only-I | sed s/-I//g)'
|
|
136
|
-
],
|
|
137
|
-
'cflags': ['-Wno-cast-function-type'],
|
|
138
|
-
'cflags!': ['-fno-exceptions'],
|
|
139
|
-
'cflags_cc!': ['-fno-exceptions']
|
|
140
|
-
}],
|
|
141
|
-
['OS=="mac"', {
|
|
142
|
-
'cflags+': ['-fvisibility=hidden'],
|
|
143
|
-
'xcode_settings': {
|
|
144
|
-
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
|
|
145
|
-
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
|
|
146
|
-
}
|
|
147
|
-
}],
|
|
148
|
-
['with_jpeg=="true"', {
|
|
149
|
-
'defines': [
|
|
150
|
-
'HAVE_JPEG'
|
|
151
|
-
],
|
|
152
|
-
'conditions': [
|
|
153
|
-
['OS=="win"', {
|
|
154
|
-
'copies': [{
|
|
155
|
-
'destination': '<(PRODUCT_DIR)',
|
|
156
|
-
'files': [
|
|
157
|
-
'<(jpeg_root)/bin/jpeg62.dll',
|
|
158
|
-
]
|
|
159
|
-
}],
|
|
160
|
-
'include_dirs': [
|
|
161
|
-
'<(jpeg_root)/include'
|
|
162
|
-
],
|
|
163
|
-
'libraries': [
|
|
164
|
-
'-l<(jpeg_root)/lib/jpeg.lib',
|
|
165
|
-
]
|
|
166
|
-
}, {
|
|
167
|
-
'include_dirs': [
|
|
168
|
-
'<!@(pkg-config libjpeg --cflags-only-I | sed s/-I//g)'
|
|
169
|
-
],
|
|
170
|
-
'libraries': [
|
|
171
|
-
'<!@(pkg-config libjpeg --libs)'
|
|
172
|
-
]
|
|
173
|
-
}]
|
|
174
|
-
]
|
|
175
|
-
}],
|
|
176
|
-
['with_gif=="true"', {
|
|
177
|
-
'defines': [
|
|
178
|
-
'HAVE_GIF'
|
|
179
|
-
],
|
|
180
|
-
'conditions': [
|
|
181
|
-
['OS=="win"', {
|
|
182
|
-
'libraries': [
|
|
183
|
-
'-l<(GTK_Root)/lib/gif.lib'
|
|
184
|
-
]
|
|
185
|
-
}, {
|
|
186
|
-
'include_dirs': [
|
|
187
|
-
'/opt/homebrew/include'
|
|
188
|
-
],
|
|
189
|
-
'libraries': [
|
|
190
|
-
'-L/opt/homebrew/lib',
|
|
191
|
-
'-lgif'
|
|
192
|
-
]
|
|
193
|
-
}]
|
|
194
|
-
]
|
|
195
|
-
}],
|
|
196
|
-
['with_rsvg=="true"', {
|
|
197
|
-
'defines': [
|
|
198
|
-
'HAVE_RSVG'
|
|
199
|
-
],
|
|
200
|
-
'conditions': [
|
|
201
|
-
['OS=="win"', {
|
|
202
|
-
'copies': [{
|
|
203
|
-
'destination': '<(PRODUCT_DIR)',
|
|
204
|
-
'files': [
|
|
205
|
-
'<(GTK_Root)/bin/librsvg-2-2.dll',
|
|
206
|
-
'<(GTK_Root)/bin/libgdk_pixbuf-2.0-0.dll',
|
|
207
|
-
'<(GTK_Root)/bin/libgio-2.0-0.dll',
|
|
208
|
-
'<(GTK_Root)/bin/libcroco-0.6-3.dll',
|
|
209
|
-
'<(GTK_Root)/bin/libgsf-1-114.dll',
|
|
210
|
-
'<(GTK_Root)/bin/libxml2-2.dll'
|
|
211
|
-
]
|
|
212
|
-
}],
|
|
213
|
-
'libraries': [
|
|
214
|
-
'-l<(GTK_Root)/lib/librsvg-2-2.lib'
|
|
215
|
-
]
|
|
216
|
-
}, {
|
|
217
|
-
'include_dirs': [
|
|
218
|
-
'<!@(pkg-config librsvg-2.0 --cflags-only-I | sed s/-I//g)'
|
|
219
|
-
],
|
|
220
|
-
'libraries': [
|
|
221
|
-
'<!@(pkg-config librsvg-2.0 --libs)'
|
|
222
|
-
]
|
|
223
|
-
}]
|
|
224
|
-
]
|
|
225
|
-
}]
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
]
|
|
229
|
-
}
|
package/install-prebuilt.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Install script: tries to copy prebuilt binaries from the npm package
|
|
5
|
-
* canvas-prebuilt-openharmony-arm64. Falls back to node-gyp rebuild
|
|
6
|
-
* if the prebuilt package is not available (non-OpenHarmony platform).
|
|
7
|
-
*
|
|
8
|
-
* After copying, creates SONAME symlinks so the dynamic linker can find
|
|
9
|
-
* shared libraries at runtime (e.g. libpixman-1.so.0 -> libpixman-1.so.0.46.4).
|
|
10
|
-
*/
|
|
11
|
-
const path = require("path");
|
|
12
|
-
const fs = require("fs");
|
|
13
|
-
const { execSync } = require("child_process");
|
|
14
|
-
|
|
15
|
-
function copyDirRecursive(src, dest) {
|
|
16
|
-
if (!fs.existsSync(src)) return;
|
|
17
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
18
|
-
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
19
|
-
const srcPath = path.join(src, entry.name);
|
|
20
|
-
const destPath = path.join(dest, entry.name);
|
|
21
|
-
if (entry.isSymbolicLink()) {
|
|
22
|
-
const target = fs.readlinkSync(srcPath);
|
|
23
|
-
if (fs.existsSync(destPath)) fs.rmSync(destPath);
|
|
24
|
-
fs.symlinkSync(target, destPath);
|
|
25
|
-
} else if (entry.isDirectory()) {
|
|
26
|
-
copyDirRecursive(srcPath, destPath);
|
|
27
|
-
} else {
|
|
28
|
-
fs.copyFileSync(srcPath, destPath);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Read the SONAME embedded in an ELF shared library via readelf.
|
|
35
|
-
* Returns null if readelf is unavailable or the file has no SONAME.
|
|
36
|
-
*/
|
|
37
|
-
function readSoname(filePath) {
|
|
38
|
-
try {
|
|
39
|
-
const output = execSync(`readelf -d "${filePath}" 2>/dev/null`, {
|
|
40
|
-
encoding: "utf8",
|
|
41
|
-
timeout: 5000,
|
|
42
|
-
});
|
|
43
|
-
const match = output.match(/SONAME.*?\[(.+?)\]/);
|
|
44
|
-
return match ? match[1] : null;
|
|
45
|
-
} catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create SONAME symlinks for all .so files in the given directory.
|
|
52
|
-
*
|
|
53
|
-
* The dynamic linker resolves libraries by SONAME (e.g. libpixman-1.so.0),
|
|
54
|
-
* but prebuilt packages ship the real file with its full version suffix
|
|
55
|
-
* (e.g. libpixman-1.so.0.46.4). This function bridges the gap.
|
|
56
|
-
*
|
|
57
|
-
* Also handles the special case where libffi's SONAME is "libffi.so" but
|
|
58
|
-
* libpango requires "libffi.so.8" at runtime.
|
|
59
|
-
*/
|
|
60
|
-
function createSonameSymlinks(dir) {
|
|
61
|
-
if (!fs.existsSync(dir)) return;
|
|
62
|
-
|
|
63
|
-
const files = fs.readdirSync(dir);
|
|
64
|
-
let created = 0;
|
|
65
|
-
|
|
66
|
-
for (const file of files) {
|
|
67
|
-
// Skip symlinks and non-.so files
|
|
68
|
-
const filePath = path.join(dir, file);
|
|
69
|
-
const stat = fs.lstatSync(filePath);
|
|
70
|
-
if (stat.isSymbolicLink() || !file.includes(".so")) continue;
|
|
71
|
-
|
|
72
|
-
const soname = readSoname(filePath);
|
|
73
|
-
if (soname && soname !== file) {
|
|
74
|
-
const linkPath = path.join(dir, soname);
|
|
75
|
-
if (!fs.existsSync(linkPath)) {
|
|
76
|
-
fs.symlinkSync(file, linkPath);
|
|
77
|
-
console.log(`[canvas] ${soname} -> ${file}`);
|
|
78
|
-
created++;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Special case: libffi.so.8
|
|
84
|
-
// libffi's ELF SONAME is "libffi.so", but libpango links against
|
|
85
|
-
// "libffi.so.8". Create the intermediate symlink if the real file exists.
|
|
86
|
-
const libffiReal = files.find(
|
|
87
|
-
(f) => f.startsWith("libffi.so.") && !fs.lstatSync(path.join(dir, f)).isSymbolicLink()
|
|
88
|
-
);
|
|
89
|
-
if (libffiReal) {
|
|
90
|
-
const ffiLink = path.join(dir, "libffi.so.8");
|
|
91
|
-
if (!fs.existsSync(ffiLink)) {
|
|
92
|
-
fs.symlinkSync(libffiReal, ffiLink);
|
|
93
|
-
console.log(`[canvas] libffi.so.8 -> ${libffiReal}`);
|
|
94
|
-
created++;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return created;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Create a minimal fontconfig configuration file if the system does not
|
|
103
|
-
* provide one (e.g. OpenHarmony). The config points fontconfig at the
|
|
104
|
-
* system font directory so that text rendering works without warnings.
|
|
105
|
-
*/
|
|
106
|
-
function ensureFontconfigConfig(dir) {
|
|
107
|
-
const fontsConfPath = path.join(dir, "fonts.conf");
|
|
108
|
-
if (fs.existsSync(fontsConfPath)) return;
|
|
109
|
-
|
|
110
|
-
// HarmonyOS keeps system fonts in /system/fonts
|
|
111
|
-
const fontsConf = `<?xml version="1.0"?>
|
|
112
|
-
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
|
113
|
-
<fontconfig>
|
|
114
|
-
<dir>/system/fonts</dir>
|
|
115
|
-
<cachedir>/tmp/.fontconfig-cache</cachedir>
|
|
116
|
-
</fontconfig>
|
|
117
|
-
`;
|
|
118
|
-
|
|
119
|
-
fs.writeFileSync(fontsConfPath, fontsConf, "utf8");
|
|
120
|
-
console.log("[canvas] Created fonts.conf for fontconfig");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const prebuiltPath = require.resolve(
|
|
125
|
-
"@ohos-ports/canvas-prebuilt-openharmony-arm64/build/Release/canvas.node"
|
|
126
|
-
);
|
|
127
|
-
const prebuiltDir = path.dirname(prebuiltPath);
|
|
128
|
-
const destDir = path.join(__dirname, "build", "Release");
|
|
129
|
-
|
|
130
|
-
copyDirRecursive(prebuiltDir, destDir);
|
|
131
|
-
console.log("[canvas] Installed prebuilt binaries from @ohos-ports/canvas-prebuilt-openharmony-arm64");
|
|
132
|
-
|
|
133
|
-
console.log("[canvas] Creating SONAME symlinks...");
|
|
134
|
-
const count = createSonameSymlinks(destDir);
|
|
135
|
-
console.log(`[canvas] Created ${count} symlink(s)`);
|
|
136
|
-
|
|
137
|
-
// Ensure fontconfig has a config file to read on OpenHarmony
|
|
138
|
-
ensureFontconfigConfig(destDir);
|
|
139
|
-
} catch {
|
|
140
|
-
console.log("[canvas] No prebuilt package available, falling back to node-gyp");
|
|
141
|
-
process.exit(1);
|
|
142
|
-
}
|