Skip to content

Commit

Permalink
Fixtures update
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Mar 11, 2023
1 parent 130c4c6 commit f11514c
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 266 deletions.
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `skr canvas`

![CI](https://github.com/Brooooooklyn/canvas/workflows/CI/badge.svg)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm111-hotpink)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm112-hotpink)
[![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `skr canvas`

![CI](https://github.com/Brooooooklyn/canvas/workflows/CI/badge.svg)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm111-hotpink)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm112-hotpink)
[![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)

Expand Down
3 changes: 3 additions & 0 deletions __test__/echarts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ test('echarts-start', async (t) => {
// @ts-expect-error
const chart = init(canvas)
chart.setOption({
textStyle: {
fontFamily: 'Iosevka Slab, PingFang HK',
},
title: {
text: 'ECharts 入门示例',
},
Expand Down
Binary file modified __test__/snapshots/draw-image-svg-noto-emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/echarts-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/filter-blur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/filter-contrast-ff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/filter-grayscale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/filter-hue-rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/text-align-with-space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion __test__/text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ test('text-align-with-space', async (t) => {
ctx.moveTo(100, 0)
ctx.lineTo(100, 512)
ctx.stroke()
ctx.font = '48px sans-serif'
ctx.font = '48px sans-serif, PingFang HK'
ctx.textAlign = 'center'
ctx.fillText('蒙娜丽莎', 100, 50)
ctx.fillText('兔 宝 宝', 100, 200)
Expand Down
8 changes: 5 additions & 3 deletions example/draw-emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ const { join } = require('path')

const { createCanvas, GlobalFonts } = require('../index.js')

GlobalFonts.registerFromPath(join(__dirname, '..', '__test__', 'fonts', 'AppleColorEmoji@2x.ttf'), 'Apple Emoji')
GlobalFonts.registerFromPath(join(__dirname, '..', '__test__', 'fonts', 'AppleColorEmoji@2x.ttf'), 'Apple Color Emoji')
GlobalFonts.registerFromPath(join(__dirname, '..', '__test__', 'fonts', 'COLRv1.ttf'), 'COLRv1')

console.info(GlobalFonts.families)
GlobalFonts.families.forEach(({ family }) => {
console.info(family)
})

const canvas = createCanvas(760, 360)
const ctx = canvas.getContext('2d')

ctx.font = '50px Apple Emoji'
ctx.font = '50px Apple Color Emoji'
ctx.strokeText('😀😃😄😁😆😅😂🤣☺️😊😊😇', 50, 150)

ctx.font = '100px COLRv1'
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,41 @@
"version": "napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
},
"devDependencies": {
"@jimp/core": "^0.22.0",
"@jimp/custom": "^0.22.0",
"@jimp/jpeg": "^0.22.0",
"@jimp/png": "^0.22.0",
"@napi-rs/cli": "^2.14.5",
"@octokit/rest": "^19.0.5",
"@swc-node/register": "^1.5.4",
"@swc/core": "^1.3.24",
"@jimp/core": "^0.22.7",
"@jimp/custom": "^0.22.7",
"@jimp/jpeg": "^0.22.7",
"@jimp/png": "^0.22.7",
"@napi-rs/cli": "^2.14.8",
"@octokit/rest": "^19.0.7",
"@swc-node/register": "^1.6.2",
"@swc/core": "^1.3.39",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"ava": "^5.1.0",
"@types/node": "^18.15.0",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"ava": "^5.2.0",
"benny": "^3.7.1",
"canvas": "^2.11.0",
"canvaskit-wasm": "^0.38.0",
"colorette": "^2.0.19",
"conventional-changelog-cli": "^2.2.2",
"echarts": "^5.4.1",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-sonarjs": "^0.18.0",
"husky": "^8.0.2",
"lint-staged": "^13.1.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5",
"pinst": "^3.0.0",
"png.js": "^0.2.1",
"prettier": "^2.8.1",
"pretty-bytes": "^6.0.0",
"prettier": "^2.8.4",
"pretty-bytes": "^6.1.0",
"skia-canvas": "^1.0.1",
"table": "^6.8.1",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},
"lint-staged": {
"*.@(js|ts|tsx|yml|yaml|md|json|html)": [
Expand Down
11 changes: 9 additions & 2 deletions scripts/build-skia.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let ExtraLdFlags
let ExtraAsmFlags

const GN_ARGS = [
`is_official_build=false`,
`is_official_build=true`,
`is_component_build=false`,
`is_debug=false`,
`werror=false`,
Expand All @@ -45,7 +45,6 @@ const GN_ARGS = [
`skia_enable_android_utils=false`,
`skia_enable_discrete_gpu=false`,
`skia_enable_gpu=false`,
`skia_enable_particles=true`,
`skia_enable_pdf=true`,
`skia_enable_skottie=false`,
`skia_enable_skshaper=true`,
Expand All @@ -55,6 +54,7 @@ const GN_ARGS = [
`skia_enable_sktext=true`,
`skia_pdf_subset_harfbuzz=true`,
`skia_use_expat=true`,
`skia_use_system_expat=false`,
`skia_use_gl=false`,
`skia_use_harfbuzz=true`,
`skia_use_icu=true`,
Expand All @@ -78,6 +78,10 @@ const GN_ARGS = [
`skia_use_system_harfbuzz=false`,
`skia_use_lua=false`,
`skia_use_piex=false`,
`skia_enable_fontmgr_custom_directory=true`,
`skia_enable_fontmgr_custom_embedded=false`,
`skia_enable_fontmgr_custom_empty=true`,
`skia_enable_fontmgr_android=false`,
]

switch (PLATFORM_NAME) {
Expand All @@ -98,6 +102,8 @@ switch (PLATFORM_NAME) {
'\\"-DSK_HAS_HEIF_LIBRARY\\",' +
'\\"-DSK_SHAPER_HARFBUZZ_AVAILABLE\\"'
ExtraSkiaBuildFlag = 'clang_win=\\"C:\\\\Program Files\\\\LLVM\\"'
GN_ARGS.push(`skia_enable_fontmgr_win=false`)
GN_ARGS.push(`skia_fontmgr_factory=\\":fontmgr_custom_directory_factory\\"`)
break
case 'linux':
case 'darwin':
Expand All @@ -124,6 +130,7 @@ switch (PLATFORM_NAME) {
) {
ExtraCflagsCC += ',"-stdlib=libc++", "-static", "-I/usr/lib/llvm-15/include/c++/v1"'
}
GN_ARGS.push(`skia_fontmgr_factory=":fontmgr_custom_directory_factory"`)
break
default:
throw new TypeError(`Don't support ${PLATFORM_NAME} for now`)
Expand Down
2 changes: 1 addition & 1 deletion skia
Submodule skia updated 1509 files
4 changes: 3 additions & 1 deletion skia-c/skia_c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <include/core/SkColorFilter.h>
#include <include/core/SkData.h>
#include <include/core/SkDrawable.h>
#include <include/core/SkEncodedImageFormat.h>
#include <include/core/SkGraphics.h>
#include <include/core/SkFontMgr.h>
#include <include/core/SkPaint.h>
Expand Down Expand Up @@ -100,6 +101,7 @@ class TypefaceFontProviderCustom : public TypefaceFontProvider

sk_sp<SkTypeface> onLegacyMakeTypeface(const char family_name[], SkFontStyle style) const override
{
SkDebugf("onLegacyMakeTypeface: %s, \n", family_name);
auto style_set = this->onMatchFamily(family_name);
if (!style_set)
{
Expand Down Expand Up @@ -129,7 +131,7 @@ struct skiac_font_collection
sk_sp<FontCollection> collection;
sk_sp<SkFontMgr> font_mgr;
sk_sp<TypefaceFontProviderCustom> assets;
skiac_font_collection() : collection(sk_make_sp<FontCollection>()), font_mgr(SkFontMgr_New_Custom_Directory(SK_FONT_FILE_PREFIX)), assets(sk_make_sp<TypefaceFontProviderCustom>(font_mgr))
skiac_font_collection() : collection(sk_make_sp<FontCollection>()), font_mgr(SkFontMgr::RefDefault()), assets(sk_make_sp<TypefaceFontProviderCustom>(font_mgr))
{
collection->setDefaultFontManager(SkFontMgr::RefDefault());
collection->setAssetFontManager(font_mgr);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"allowSyntheticDefaultImports": true,
"allowJs": true,
"outDir": "dist",
"sourceMap": true,
"lib": ["ESNext", "DOM"]
},
"exclude": ["node_modules", "depot_tools", "skia", "skia-c", "example", "target", "npm"]
Expand Down
Loading

1 comment on commit f11514c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: f11514c Previous: bad913c Ratio
Draw house#skia-canvas 21.9 ops/sec (±1.13%) 24 ops/sec (±0.1%) 1.10
Draw house#node-canvas 19.8 ops/sec (±0.95%) 26 ops/sec (±0.28%) 1.31
Draw house#@napi-rs/skia 20.5 ops/sec (±0.97%) 23 ops/sec (±0.54%) 1.12
Draw gradient#skia-canvas 20.5 ops/sec (±0.95%) 22.7 ops/sec (±0.21%) 1.11
Draw gradient#node-canvas 18.7 ops/sec (±0.6%) 25.2 ops/sec (±0.28%) 1.35
Draw gradient#@napi-rs/skia 19.4 ops/sec (±1.25%) 22.6 ops/sec (±0.09%) 1.16

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.