Compare commits

...

4 Commits

Author SHA1 Message Date
Tim van der Meij
ab124db046
Merge pull request #21072 from Snuffleupagus/hmtx-TypedArray
Use a TypedArray when building the "hmtx" font table
2026-04-09 21:26:45 +02:00
Tim van der Meij
27e171ea38
Merge pull request #21067 from mozilla/dependabot/npm_and_yarn/basic-ftp-5.2.1
Bump basic-ftp from 5.2.0 to 5.2.1
2026-04-09 21:23:36 +02:00
Jonas Jenwald
8f56ee2ae9 Use a TypedArray when building the "hmtx" font table
In this case it's trivial to compute the size of the data upfront, hence we can use a TypedArray which should be more efficient than a string.
2026-04-09 18:58:58 +02:00
dependabot[bot]
81644a7ee9
Bump basic-ftp from 5.2.0 to 5.2.1
Bumps [basic-ftp](https://github.com/patrickjuchli/basic-ftp) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/patrickjuchli/basic-ftp/releases)
- [Changelog](https://github.com/patrickjuchli/basic-ftp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/patrickjuchli/basic-ftp/compare/v5.2.0...v5.2.1)

---
updated-dependencies:
- dependency-name: basic-ftp
  dependency-version: 5.2.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-08 20:13:58 +00:00
2 changed files with 15 additions and 24 deletions

21
package-lock.json generated
View File

@ -2565,9 +2565,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2589,9 +2586,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@ -2613,9 +2607,6 @@
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2637,9 +2628,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2661,9 +2649,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@ -4235,9 +4220,9 @@
}
},
"node_modules/basic-ftp": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.2.0.tgz",
"integrity": "sha512-VoMINM2rqJwJgfdHq6RiUudKt2BV+FY5ZFezP/ypmwayk68+NzzAQy4XXLlqsGD4MCzq3DrmNFD/uUmBJuGoXw==",
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.2.1.tgz",
"integrity": "sha512-0yaL8JdxTknKDILitVpfYfV2Ob6yb3udX/hK97M7I3jOeznBNxQPtVvTUtnhUkyHlxFWyr5Lvknmgzoc7jf+1Q==",
"dev": true,
"license": "MIT",
"engines": {

View File

@ -3311,19 +3311,25 @@ class Font {
"hmtx",
(function fontFieldsHmtx() {
const charstrings = font.charstrings;
const cffWidths = font.cff ? font.cff.widths : null;
let hmtx = "\x00\x00\x00\x00"; // Fake .notdef
const cffWidths = font.cff?.widths ?? null;
const data = new Uint8Array(numGlyphs * 4);
// Fake .notdef (width=0 and lsb=0) first, skip redundant assignment.
let pos = 4;
for (let i = 1, ii = numGlyphs; i < ii; i++) {
let width = 0;
if (charstrings) {
const charstring = charstrings[i - 1];
width = "width" in charstring ? charstring.width : 0;
width = charstrings[i - 1].width || 0;
} else if (cffWidths) {
width = Math.ceil(cffWidths[i] || 0);
}
hmtx += string16(width) + string16(0);
data[pos++] = (width >> 8) & 0xff;
data[pos++] = width & 0xff;
// Use lsb=0, skip redundant assignment.
pos += 2;
}
return hmtx;
return data;
})()
);