Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 #4

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

v3 #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ indent_style = tab

[*.{md,mdx}]
trim_trailing_whitespace = false

[*.bdf]
charset = utf-8
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = false
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -25,11 +25,11 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .npmrc file to publish to npm
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Install modules
run: npm install
Expand All @@ -40,9 +40,9 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup .npmrc file to publish to GitHub Packages
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@tomchen'
- run: npm run addscope
Expand Down
28 changes: 6 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,18 @@ jobs:
os:
- ubuntu-latest
- windows-latest
node: [12.x, 14.x, 15.x]
node: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 23.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install modules
run: yarn
- name: Run tests
run: yarn test

deno-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
deno: ['v1.13', 'v1.x', 'nightly']

steps:
- uses: actions/checkout@v2
- name: Set up Deno
uses: denolib/setup-deno@v2
with:
deno-version: ${{ matrix.deno }}
- name: Run tests
run: cd deno && deno test --unstable --allow-read --allow-write --allow-net test/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '22.x'
5 changes: 0 additions & 5 deletions .husky/commit-msg

This file was deleted.

1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
},
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
Expand Down
47 changes: 23 additions & 24 deletions src/bdfparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ export class Font {

private async __parse_headers(): Promise<void> {
while (1) {
const line: string = (await this.__f?.next())?.value
let line: string = (await this.__f?.next())?.value.trim()
while (line.length === 0) {
line = (await this.__f?.next())?.value.trim()
}
const kvlist = line.split(/ (.+)/, 2)
const l = kvlist.length
let nlist: string[]
Expand Down Expand Up @@ -296,9 +299,8 @@ export class Font {
break
case 'METRICSSET':
case 'CONTENTVERSION':
this.__headers[
<'metricsset' | 'contentversion'>key.toLowerCase()
] = parseInt(value, 10)
this.__headers[<'metricsset' | 'contentversion'>key.toLowerCase()] =
parseInt(value, 10)
break
case 'CHARS':
console.warn(
Expand Down Expand Up @@ -338,7 +340,10 @@ export class Font {

private async __parse_props(): Promise<void> {
while (1) {
const line: string = (await this.__f?.next())?.value
let line: string = (await this.__f?.next())?.value.trim()
while (line.length === 0) {
line = (await this.__f?.next())?.value.trim()
}
const kvlist = line.split(/ (.+)/, 2)
const l = kvlist.length
if (l === 2) {
Expand Down Expand Up @@ -378,7 +383,10 @@ export class Font {
private async __parse_glyph_count(): Promise<void> {
let line: string
if (this.__curline_chars === null) {
line = (await this.__f?.next())?.value
line = (await this.__f?.next())?.value.trim()
while (line.length === 0) {
line = (await this.__f?.next())?.value.trim()
}
} else {
line = this.__curline_chars
this.__curline_chars = null
Expand Down Expand Up @@ -892,13 +900,8 @@ export class Font {
missing?: Glyph | GlyphMeta | null
} = {}
): Bitmap {
const {
linelimit,
mode,
direction,
usecurrentglyphspacing,
missing,
} = options
const { linelimit, mode, direction, usecurrentglyphspacing, missing } =
options
return this.drawcps(
str.split('').map((c) => {
const cp = c.codePointAt(0)
Expand Down Expand Up @@ -942,14 +945,8 @@ export class Font {
usecurrentglyphspacing?: boolean | null
} = {}
): Bitmap {
const {
order,
r,
linelimit,
mode,
direction,
usecurrentglyphspacing,
} = options
const { order, r, linelimit, mode, direction, usecurrentglyphspacing } =
options
const _mode = mode ?? 0
return this.drawcps(this.itercps(order, r), {
linelimit,
Expand Down Expand Up @@ -1616,9 +1613,11 @@ export class Bitmap {
newsubstr: string
): string => {
if ('replaceAll' in String.prototype) {
return (str as string & {
replaceAll: (...args: string[]) => string
}).replaceAll(substr, newsubstr)
return (
str as string & {
replaceAll: (...args: string[]) => string
}
).replaceAll(substr, newsubstr)
} else {
const escapeRegExp = (s: string): string =>
s.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&')
Expand Down
21 changes: 19 additions & 2 deletions test/fonts/unifont-13.0.04-for-test.bdf
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
STARTFONT 2.1


STARTFONT 2.1

FONT -gnu-Unifont-Medium-R-Normal-Sans-16-160-75-75-c-80-iso10646-1
SIZE 16 75 75
FONTBOUNDINGBOX 16 16 0 -2
COMMENT "Generated by fontforge, http://fontforge.sourceforge.net"
COMMENT "(C)Copyright"
STARTPROPERTIES 24
COPYRIGHT "Copyright (C) 1998-2020 Roman Czyborra, Paul Hardy, Qianqian Fang, Andrew Miller, Johnnie Weaver, David Corbett, Rebecca Bettencourt, et al. License: SIL Open Font License version 1.1 and GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html> with the GNU Font Embedding Exception."


FONT_VERSION "13.0.04"
FONT_TYPE "Bitmap"
FOUNDRY "GNU"
Expand All @@ -30,7 +35,13 @@ FONT_ASCENT 14
FONT_DESCENT 2
DEFAULT_CHAR 65533
ENDPROPERTIES
CHARS 849






CHARS 849
STARTCHAR U+0001
ENCODING 1
SWIDTH 1000 0
Expand Down Expand Up @@ -19558,4 +19569,10 @@ BITMAP
4A
4A
ENDCHAR





ENDFONT

Loading
Loading