Installations
npm install @codepunkt/wasm-layout-text
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.18.3
NPM Version
6.14.6
Score
71.7
Supply Chain
82.1
Quality
75.3
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
Rust (62.94%)
JavaScript (33.46%)
Makefile (3.6%)
Developer
codepunkt
Download Statistics
Total Downloads
9,394
Last Day
1
Last Week
3
Last Month
35
Last Year
657
GitHub Statistics
2 Stars
6 Commits
3 Watching
1 Branches
1 Contributors
Bundle Size
4.19 kB
Minified
1.62 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.0.0
Package Id
@codepunkt/wasm-layout-text@3.0.0
Unpacked Size
123.85 kB
Size
44.68 kB
File Count
6
NPM Version
6.14.6
Node Version
12.18.3
Total Downloads
Cumulative downloads
Total Downloads
9,394
Last day
0%
1
Compared to previous day
Last week
-50%
3
Compared to previous week
Last month
29.6%
35
Compared to previous month
Last year
-81.7%
657
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
No dependencies detected.
@codepunkt/wasm-layout-text
Key features
This package layouts text and returns the result as an UInt8Array
of pixels. It supports:
- custom image dimensions
- custom (TrueType) font, font size and color
- text positioning, custom text bounding box
- any combination of vertical and horizontal alignment
Usage
The package provides a render
function that returns an UInt8Array
of pixels:
1const { readFileSync } = requir("fs");
2const { join } = require("path");
3const wlt = require("@codepunkt/wasm-layout-text");
4
5const font = readFileSync(join(__dirname, "myfont.ttf"));
6
7const buffer = wlt.render(
8 // text, size, color, ttf font buffer
9 new wlt.Text("Hello world", 64, new wlt.RgbColor(91, 214, 123), font),
10 // image dimension
11 new wlt.Dimension(1200, 630),
12 // text bounds
13 new wlt.Dimensions(1100, 530),
14 // text position
15 new wlt.Position(50, 50),
16 // text alignment
17 new wlt.Alignment(wlt.HorizontalAlign.Left, wlt.VerticalAlign.Top)
18);
You can then use Jimp or other image processing libraries to
- load this buffer
- combine it with other buffers (such as a background image or additional text generated by this package)
- save to image file
Contributing
Contributions are welcome! A JavaScript usage example with Jimp is available in the example
directory.
There are a few make
tasks, most notably:
make build
: will build rust code from./src
to JavaScript code in./pkg
(using wasm-pack)make node
: executes theexample
code with Node.js and uses the local JavaScript package from.pkg
to render all alignment permutations (expects the./pkg
folder to exist)
No vulnerabilities found.
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: main:1
Reason
4 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-xvf7-4v9q-58w6
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-x565-32qp-m3vf
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.4
/10
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More