diff --git a/CHANGELOG.md b/CHANGELOG.md index b835ab79..be012a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,56 @@ This changelog also contains important changes in dependencies. ## [Unreleased] +## [2.5.0] - 2023-10-16 + +### Added + +Now we can finally loading custom fonts in Wasm, including the WOFF2 format (see [playground](https://resvg-js.vercel.app/)), thanks to the high-performance `woff2-rs`. + +In addition, we implemented smarter default font family fallback. the `defaultFontFamily` option can now be omitted. We'll read the font-family from the incoming fonts and set it to the default. + +```html + + +``` + +- feat: improve custom loaded fonts. Thanks to @yisibl [#209](https://github.com/yisibl/resvg-js/issues/209) +- feat: support for loading custom fonts in Wasm, via the `fontBuffers` option. Thanks to @antmelnyk [#217](https://github.com/yisibl/resvg-js/issues/217) +- feat: support loading WOFF2 font in Wasm. Thanks to @yisibl [#220](https://github.com/yisibl/resvg-js/issues/220) +- chore: Wasm uses the same logic as Node.js to find the default font family.Thanks to @yisibl [#252](https://github.com/yisibl/resvg-js/issues/252) + +We have improved the [upstream svgtypes#14](https://github.com/RazrFalcon/svgtypes/pull/14), allow parsing of float `rgb()/rgba()` values from CSS Color 4 draft like `rgb(3.14, 110, 201)`. + + - fix(deps): update rust crate svgtypes to 0.12.0. Thanks to @yisibl [#266](https://github.com/yisibl/resvg-js/issues/266) + +### Changed + +- test: fix test image timeout. [#262](https://github.com/yisibl/resvg-js/issues/262) + ## [2.4.1] - 2023-02-15 ### Fixed @@ -526,7 +576,8 @@ The first official version, use [resvg 0.18.0](https://github.com/RazrFalcon/res - Support custom fonts and system fonts. - Supports setting the background color of PNG. -[unreleased]: https://github.com/yisibl/resvg-js/compare/v2.4.1...HEAD +[unreleased]: https://github.com/yisibl/resvg-js/compare/v2.5.0...HEAD +[2.5.0]: https://github.com/yisibl/resvg-js/compare/v2.4.1...v2.5.0 [2.4.1]: https://github.com/yisibl/resvg-js/compare/v2.4.0...v2.4.1 [2.4.0]: https://github.com/yisibl/resvg-js/compare/v2.3.1...v2.4.0 [2.3.1]: https://github.com/yisibl/resvg-js/compare/v2.3.0...v2.3.1 diff --git a/README.md b/README.md index c2f206a7..171815c7 100755 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ async function main() { font: { fontFiles: ['./example/SourceHanSerifCN-Light-subset.ttf'], // Load custom fonts. loadSystemFonts: false, // It will be faster to disable loading system fonts. - defaultFontFamily: 'Source Han Serif CN Light', + // defaultFontFamily: 'Source Han Serif CN Light', // You can omit this. }, } const resvg = new Resvg(svg, opts) @@ -161,11 +161,21 @@ This package also ships a pure WebAssembly artifact built with `wasm-bindgen` to (async function () { // The Wasm must be initialized first await resvg.initWasm(fetch('https://unpkg.com/@resvg/resvg-wasm/index_bg.wasm')) + + const font = await fetch('./fonts/Pacifico-Regular.woff2') + if (!font.ok) return + + const fontData = await font.arrayBuffer() + const buffer = new Uint8Array(fontData) + const opts = { fitTo: { mode: 'width', // If you need to change the size value: 800, }, + font: { + fontBuffers: [buffer], // New in 2.5.0, loading custom fonts + }, } const svg = ' ... ' // Input SVG, String or Uint8Array diff --git a/npm/android-arm-eabi/package.json b/npm/android-arm-eabi/package.json index e4b803e2..877ed564 100644 --- a/npm/android-arm-eabi/package.json +++ b/npm/android-arm-eabi/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-android-arm-eabi", - "version": "2.4.1", + "version": "2.5.0", "os": [ "android" ], diff --git a/npm/android-arm64/package.json b/npm/android-arm64/package.json index 2baddfa2..f72fa7f6 100644 --- a/npm/android-arm64/package.json +++ b/npm/android-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-android-arm64", - "version": "2.4.1", + "version": "2.5.0", "os": [ "android" ], diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 4acacf00..dfe50947 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-darwin-arm64", - "version": "2.4.1", + "version": "2.5.0", "os": [ "darwin" ], diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index d71af3de..102d6a5b 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-darwin-x64", - "version": "2.4.1", + "version": "2.5.0", "os": [ "darwin" ], diff --git a/npm/linux-arm-gnueabihf/package.json b/npm/linux-arm-gnueabihf/package.json index 78d82979..b3e496a2 100644 --- a/npm/linux-arm-gnueabihf/package.json +++ b/npm/linux-arm-gnueabihf/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-linux-arm-gnueabihf", - "version": "2.4.1", + "version": "2.5.0", "os": [ "linux" ], diff --git a/npm/linux-arm64-gnu/package.json b/npm/linux-arm64-gnu/package.json index 04a0f81e..dba96087 100644 --- a/npm/linux-arm64-gnu/package.json +++ b/npm/linux-arm64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-linux-arm64-gnu", - "version": "2.4.1", + "version": "2.5.0", "os": [ "linux" ], diff --git a/npm/linux-arm64-musl/package.json b/npm/linux-arm64-musl/package.json index 47d6262c..2f1759e1 100644 --- a/npm/linux-arm64-musl/package.json +++ b/npm/linux-arm64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-linux-arm64-musl", - "version": "2.4.1", + "version": "2.5.0", "os": [ "linux" ], diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index 338481c9..4babec63 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-linux-x64-gnu", - "version": "2.4.1", + "version": "2.5.0", "os": [ "linux" ], diff --git a/npm/linux-x64-musl/package.json b/npm/linux-x64-musl/package.json index 59af1f2c..78e70429 100644 --- a/npm/linux-x64-musl/package.json +++ b/npm/linux-x64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-linux-x64-musl", - "version": "2.4.1", + "version": "2.5.0", "os": [ "linux" ], diff --git a/npm/win32-arm64-msvc/package.json b/npm/win32-arm64-msvc/package.json index 8a10b4fb..19b37ab5 100644 --- a/npm/win32-arm64-msvc/package.json +++ b/npm/win32-arm64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-win32-arm64-msvc", - "version": "2.4.1", + "version": "2.5.0", "os": [ "win32" ], diff --git a/npm/win32-ia32-msvc/package.json b/npm/win32-ia32-msvc/package.json index f9709958..ce17bc8b 100644 --- a/npm/win32-ia32-msvc/package.json +++ b/npm/win32-ia32-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-win32-ia32-msvc", - "version": "2.4.1", + "version": "2.5.0", "os": [ "win32" ], diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index 3beea510..4a70d99a 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js-win32-x64-msvc", - "version": "2.4.1", + "version": "2.5.0", "os": [ "win32" ], diff --git a/package.json b/package.json index 40ff50e4..7f663860 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-js", - "version": "2.4.1", + "version": "2.5.0", "description": "A high-performance SVG renderer and toolkit, powered by Rust based resvg and napi-rs", "main": "index.js", "repository": "git@github.com:yisibl/resvg-js.git", diff --git a/wasm/index_bg.wasm b/wasm/index_bg.wasm index 6b955d1d..7e77996b 100644 Binary files a/wasm/index_bg.wasm and b/wasm/index_bg.wasm differ diff --git a/wasm/package.json b/wasm/package.json index c17a3651..863d8c59 100644 --- a/wasm/package.json +++ b/wasm/package.json @@ -1,6 +1,6 @@ { "name": "@resvg/resvg-wasm", - "version": "2.4.1", + "version": "2.5.0", "description": "A high-performance SVG renderer and toolkit, powered by Rust based resvg and napi-rs", "main": "index.js", "module": "index.mjs",