ooxml-core 1.51.0 → 1.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +90 -34
- package/dist/index.mjs +90 -34
- package/dist/text/index.cjs +90 -34
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.mjs +89 -35
- package/dist/text/truetype/glyphless.d.ts +5 -0
- package/dist/text/truetype/glyphless.d.ts.map +1 -0
- package/dist/text/truetype/sfnt-write.d.ts +10 -0
- package/dist/text/truetype/sfnt-write.d.ts.map +1 -0
- package/dist/text/truetype/subset.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24118,6 +24118,7 @@ __export(text_exports, {
|
|
|
24118
24118
|
GOOGLE_FONTS_CSS2_BASE: () => GOOGLE_FONTS_CSS2_BASE,
|
|
24119
24119
|
GOOGLE_FONTS_FAMILIES: () => GOOGLE_FONTS_FAMILIES,
|
|
24120
24120
|
GOOGLE_WEBFONT_AXIS: () => GOOGLE_WEBFONT_AXIS,
|
|
24121
|
+
MAX_GLYPHLESS_GLYPHS: () => MAX_GLYPHLESS_GLYPHS,
|
|
24121
24122
|
METRIC_FONT_SUBSTITUTES: () => METRIC_FONT_SUBSTITUTES,
|
|
24122
24123
|
OOXML_DATETIME_PATTERNS: () => OOXML_DATETIME_PATTERNS,
|
|
24123
24124
|
PANOSE_FAMILY_MAP: () => PANOSE_FAMILY_MAP,
|
|
@@ -24157,6 +24158,7 @@ __export(text_exports, {
|
|
|
24157
24158
|
getPanoseWeight: () => getPanoseWeight,
|
|
24158
24159
|
getSubstituteFontFamily: () => getSubstituteFontFamily,
|
|
24159
24160
|
getSubstituteFonts: () => getSubstituteFonts,
|
|
24161
|
+
glyphlessTrueType: () => glyphlessTrueType,
|
|
24160
24162
|
hangsAtLineEnd: () => hangsAtLineEnd,
|
|
24161
24163
|
hasDesignAdvances: () => hasDesignAdvances,
|
|
24162
24164
|
hasDirectSubstitution: () => hasDirectSubstitution,
|
|
@@ -25615,6 +25617,91 @@ function readSfntFsType(data, header) {
|
|
|
25615
25617
|
return void 0;
|
|
25616
25618
|
}
|
|
25617
25619
|
|
|
25620
|
+
// text/truetype/sfnt-write.ts
|
|
25621
|
+
var pad4 = (n3) => n3 + 3 & -4;
|
|
25622
|
+
function checksum(bytes) {
|
|
25623
|
+
let sum = 0;
|
|
25624
|
+
for (let i2 = 0; i2 < bytes.length; i2 += 4)
|
|
25625
|
+
sum = sum + ((bytes[i2] ?? 0) << 24 | (bytes[i2 + 1] ?? 0) << 16 | (bytes[i2 + 2] ?? 0) << 8 | (bytes[i2 + 3] ?? 0)) >>> 0;
|
|
25626
|
+
return sum;
|
|
25627
|
+
}
|
|
25628
|
+
function writeSfnt(tables) {
|
|
25629
|
+
const directory = 12 + tables.length * 16;
|
|
25630
|
+
let total = directory;
|
|
25631
|
+
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
25632
|
+
const out = new Uint8Array(total);
|
|
25633
|
+
const view = new DataView(out.buffer);
|
|
25634
|
+
view.setUint32(0, 65536);
|
|
25635
|
+
view.setUint16(4, tables.length);
|
|
25636
|
+
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
25637
|
+
view.setUint16(6, power * 16);
|
|
25638
|
+
view.setUint16(8, Math.log2(power));
|
|
25639
|
+
view.setUint16(10, tables.length * 16 - power * 16);
|
|
25640
|
+
let position = directory;
|
|
25641
|
+
let headAt = -1;
|
|
25642
|
+
tables.forEach(([name2, bytes], index) => {
|
|
25643
|
+
const entry3 = 12 + index * 16;
|
|
25644
|
+
for (let i2 = 0; i2 < 4; i2++) out[entry3 + i2] = name2.charCodeAt(i2);
|
|
25645
|
+
view.setUint32(entry3 + 4, checksum(bytes));
|
|
25646
|
+
view.setUint32(entry3 + 8, position);
|
|
25647
|
+
view.setUint32(entry3 + 12, bytes.length);
|
|
25648
|
+
out.set(bytes, position);
|
|
25649
|
+
if (name2 === "head") headAt = position;
|
|
25650
|
+
position += pad4(bytes.length);
|
|
25651
|
+
});
|
|
25652
|
+
if (headAt >= 0) view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
25653
|
+
return out;
|
|
25654
|
+
}
|
|
25655
|
+
|
|
25656
|
+
// text/truetype/glyphless.ts
|
|
25657
|
+
var MAX_GLYPHLESS_GLYPHS = 65535;
|
|
25658
|
+
function glyphlessTrueType(advances2) {
|
|
25659
|
+
const count = Math.min(MAX_GLYPHLESS_GLYPHS, Math.max(1, advances2.length));
|
|
25660
|
+
const advance = (glyph2) => Math.max(0, Math.min(65535, Math.round(advances2[glyph2] ?? 0)));
|
|
25661
|
+
let widest = 0;
|
|
25662
|
+
const hmtx = new Uint8Array(count * 4);
|
|
25663
|
+
const hmtxView = new DataView(hmtx.buffer);
|
|
25664
|
+
for (let glyph2 = 0; glyph2 < count; glyph2++) {
|
|
25665
|
+
hmtxView.setUint16(glyph2 * 4, advance(glyph2));
|
|
25666
|
+
widest = Math.max(widest, advance(glyph2));
|
|
25667
|
+
}
|
|
25668
|
+
const head2 = new Uint8Array(54);
|
|
25669
|
+
const headView = new DataView(head2.buffer);
|
|
25670
|
+
headView.setUint32(0, 65536);
|
|
25671
|
+
headView.setUint32(4, 65536);
|
|
25672
|
+
headView.setUint32(12, 1594834165);
|
|
25673
|
+
headView.setUint16(16, 11);
|
|
25674
|
+
headView.setUint16(18, 1e3);
|
|
25675
|
+
headView.setInt16(38, -200);
|
|
25676
|
+
headView.setInt16(40, 1e3);
|
|
25677
|
+
headView.setInt16(42, 800);
|
|
25678
|
+
headView.setUint16(46, 8);
|
|
25679
|
+
headView.setInt16(48, 2);
|
|
25680
|
+
const hhea = new Uint8Array(36);
|
|
25681
|
+
const hheaView = new DataView(hhea.buffer);
|
|
25682
|
+
hheaView.setUint32(0, 65536);
|
|
25683
|
+
hheaView.setInt16(4, 800);
|
|
25684
|
+
hheaView.setInt16(6, -200);
|
|
25685
|
+
hheaView.setUint16(10, widest);
|
|
25686
|
+
hheaView.setInt16(18, 1);
|
|
25687
|
+
hheaView.setUint16(34, count);
|
|
25688
|
+
const maxp = new Uint8Array(32);
|
|
25689
|
+
const maxpView = new DataView(maxp.buffer);
|
|
25690
|
+
maxpView.setUint32(0, 65536);
|
|
25691
|
+
maxpView.setUint16(4, count);
|
|
25692
|
+
maxpView.setUint16(14, 1);
|
|
25693
|
+
const loca = new Uint8Array((count + 1) * 2);
|
|
25694
|
+
const glyf = new Uint8Array(4);
|
|
25695
|
+
return writeSfnt([
|
|
25696
|
+
["glyf", glyf],
|
|
25697
|
+
["head", head2],
|
|
25698
|
+
["hhea", hhea],
|
|
25699
|
+
["hmtx", hmtx],
|
|
25700
|
+
["loca", loca],
|
|
25701
|
+
["maxp", maxp]
|
|
25702
|
+
]);
|
|
25703
|
+
}
|
|
25704
|
+
|
|
25618
25705
|
// text/truetype/parse.ts
|
|
25619
25706
|
var u16 = (v, o) => o + 2 <= v.byteLength ? v.getUint16(o) : 0;
|
|
25620
25707
|
var i16 = (v, o) => o + 2 <= v.byteLength ? v.getInt16(o) : 0;
|
|
@@ -25744,13 +25831,6 @@ function parseTrueType(data) {
|
|
|
25744
25831
|
}
|
|
25745
25832
|
|
|
25746
25833
|
// text/truetype/subset.ts
|
|
25747
|
-
var pad4 = (n3) => n3 + 3 & -4;
|
|
25748
|
-
function checksum(bytes) {
|
|
25749
|
-
let sum = 0;
|
|
25750
|
-
for (let i2 = 0; i2 < bytes.length; i2 += 4)
|
|
25751
|
-
sum = sum + ((bytes[i2] ?? 0) << 24 | (bytes[i2 + 1] ?? 0) << 16 | (bytes[i2 + 2] ?? 0) << 8 | (bytes[i2 + 3] ?? 0)) >>> 0;
|
|
25752
|
-
return sum;
|
|
25753
|
-
}
|
|
25754
25834
|
function components(outline2) {
|
|
25755
25835
|
if (outline2.length < 10) return [];
|
|
25756
25836
|
const view = new DataView(outline2.buffer, outline2.byteOffset, outline2.byteLength);
|
|
@@ -25783,8 +25863,8 @@ function subsetTrueType(font, used) {
|
|
|
25783
25863
|
const source2 = font.outline(glyph2);
|
|
25784
25864
|
if (!source2.length) return source2;
|
|
25785
25865
|
const copy = Uint8Array.from(source2);
|
|
25786
|
-
const
|
|
25787
|
-
for (const part of components(copy))
|
|
25866
|
+
const view = new DataView(copy.buffer);
|
|
25867
|
+
for (const part of components(copy)) view.setUint16(part.offset, mapped.get(part.glyph) ?? 0);
|
|
25788
25868
|
return copy;
|
|
25789
25869
|
});
|
|
25790
25870
|
const count = glyphs.length;
|
|
@@ -25827,31 +25907,7 @@ function subsetTrueType(font, used) {
|
|
|
25827
25907
|
["maxp", maxp]
|
|
25828
25908
|
])
|
|
25829
25909
|
if (bytes) tables.push([name2, bytes]);
|
|
25830
|
-
|
|
25831
|
-
let total = directory;
|
|
25832
|
-
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
25833
|
-
const out = new Uint8Array(total);
|
|
25834
|
-
const view = new DataView(out.buffer);
|
|
25835
|
-
view.setUint32(0, 65536);
|
|
25836
|
-
view.setUint16(4, tables.length);
|
|
25837
|
-
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
25838
|
-
view.setUint16(6, power * 16);
|
|
25839
|
-
view.setUint16(8, Math.log2(power));
|
|
25840
|
-
view.setUint16(10, tables.length * 16 - power * 16);
|
|
25841
|
-
let position = directory;
|
|
25842
|
-
let headAt = 0;
|
|
25843
|
-
tables.forEach(([name2, bytes], index) => {
|
|
25844
|
-
const entry3 = 12 + index * 16;
|
|
25845
|
-
for (let i2 = 0; i2 < 4; i2++) out[entry3 + i2] = name2.charCodeAt(i2);
|
|
25846
|
-
view.setUint32(entry3 + 4, checksum(bytes));
|
|
25847
|
-
view.setUint32(entry3 + 8, position);
|
|
25848
|
-
view.setUint32(entry3 + 12, bytes.length);
|
|
25849
|
-
out.set(bytes, position);
|
|
25850
|
-
if (name2 === "head") headAt = position;
|
|
25851
|
-
position += pad4(bytes.length);
|
|
25852
|
-
});
|
|
25853
|
-
view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
25854
|
-
return { data: out, glyphs };
|
|
25910
|
+
return { data: writeSfnt(tables), glyphs };
|
|
25855
25911
|
}
|
|
25856
25912
|
|
|
25857
25913
|
// text/webfonts/google-fonts-catalogue.ts
|
package/dist/index.mjs
CHANGED
|
@@ -24093,6 +24093,7 @@ __export(text_exports, {
|
|
|
24093
24093
|
GOOGLE_FONTS_CSS2_BASE: () => GOOGLE_FONTS_CSS2_BASE,
|
|
24094
24094
|
GOOGLE_FONTS_FAMILIES: () => GOOGLE_FONTS_FAMILIES,
|
|
24095
24095
|
GOOGLE_WEBFONT_AXIS: () => GOOGLE_WEBFONT_AXIS,
|
|
24096
|
+
MAX_GLYPHLESS_GLYPHS: () => MAX_GLYPHLESS_GLYPHS,
|
|
24096
24097
|
METRIC_FONT_SUBSTITUTES: () => METRIC_FONT_SUBSTITUTES,
|
|
24097
24098
|
OOXML_DATETIME_PATTERNS: () => OOXML_DATETIME_PATTERNS,
|
|
24098
24099
|
PANOSE_FAMILY_MAP: () => PANOSE_FAMILY_MAP,
|
|
@@ -24132,6 +24133,7 @@ __export(text_exports, {
|
|
|
24132
24133
|
getPanoseWeight: () => getPanoseWeight,
|
|
24133
24134
|
getSubstituteFontFamily: () => getSubstituteFontFamily,
|
|
24134
24135
|
getSubstituteFonts: () => getSubstituteFonts,
|
|
24136
|
+
glyphlessTrueType: () => glyphlessTrueType,
|
|
24135
24137
|
hangsAtLineEnd: () => hangsAtLineEnd,
|
|
24136
24138
|
hasDesignAdvances: () => hasDesignAdvances,
|
|
24137
24139
|
hasDirectSubstitution: () => hasDirectSubstitution,
|
|
@@ -25590,6 +25592,91 @@ function readSfntFsType(data, header) {
|
|
|
25590
25592
|
return void 0;
|
|
25591
25593
|
}
|
|
25592
25594
|
|
|
25595
|
+
// text/truetype/sfnt-write.ts
|
|
25596
|
+
var pad4 = (n3) => n3 + 3 & -4;
|
|
25597
|
+
function checksum(bytes) {
|
|
25598
|
+
let sum = 0;
|
|
25599
|
+
for (let i2 = 0; i2 < bytes.length; i2 += 4)
|
|
25600
|
+
sum = sum + ((bytes[i2] ?? 0) << 24 | (bytes[i2 + 1] ?? 0) << 16 | (bytes[i2 + 2] ?? 0) << 8 | (bytes[i2 + 3] ?? 0)) >>> 0;
|
|
25601
|
+
return sum;
|
|
25602
|
+
}
|
|
25603
|
+
function writeSfnt(tables) {
|
|
25604
|
+
const directory = 12 + tables.length * 16;
|
|
25605
|
+
let total = directory;
|
|
25606
|
+
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
25607
|
+
const out = new Uint8Array(total);
|
|
25608
|
+
const view = new DataView(out.buffer);
|
|
25609
|
+
view.setUint32(0, 65536);
|
|
25610
|
+
view.setUint16(4, tables.length);
|
|
25611
|
+
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
25612
|
+
view.setUint16(6, power * 16);
|
|
25613
|
+
view.setUint16(8, Math.log2(power));
|
|
25614
|
+
view.setUint16(10, tables.length * 16 - power * 16);
|
|
25615
|
+
let position = directory;
|
|
25616
|
+
let headAt = -1;
|
|
25617
|
+
tables.forEach(([name2, bytes], index) => {
|
|
25618
|
+
const entry3 = 12 + index * 16;
|
|
25619
|
+
for (let i2 = 0; i2 < 4; i2++) out[entry3 + i2] = name2.charCodeAt(i2);
|
|
25620
|
+
view.setUint32(entry3 + 4, checksum(bytes));
|
|
25621
|
+
view.setUint32(entry3 + 8, position);
|
|
25622
|
+
view.setUint32(entry3 + 12, bytes.length);
|
|
25623
|
+
out.set(bytes, position);
|
|
25624
|
+
if (name2 === "head") headAt = position;
|
|
25625
|
+
position += pad4(bytes.length);
|
|
25626
|
+
});
|
|
25627
|
+
if (headAt >= 0) view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
25628
|
+
return out;
|
|
25629
|
+
}
|
|
25630
|
+
|
|
25631
|
+
// text/truetype/glyphless.ts
|
|
25632
|
+
var MAX_GLYPHLESS_GLYPHS = 65535;
|
|
25633
|
+
function glyphlessTrueType(advances2) {
|
|
25634
|
+
const count = Math.min(MAX_GLYPHLESS_GLYPHS, Math.max(1, advances2.length));
|
|
25635
|
+
const advance = (glyph2) => Math.max(0, Math.min(65535, Math.round(advances2[glyph2] ?? 0)));
|
|
25636
|
+
let widest = 0;
|
|
25637
|
+
const hmtx = new Uint8Array(count * 4);
|
|
25638
|
+
const hmtxView = new DataView(hmtx.buffer);
|
|
25639
|
+
for (let glyph2 = 0; glyph2 < count; glyph2++) {
|
|
25640
|
+
hmtxView.setUint16(glyph2 * 4, advance(glyph2));
|
|
25641
|
+
widest = Math.max(widest, advance(glyph2));
|
|
25642
|
+
}
|
|
25643
|
+
const head2 = new Uint8Array(54);
|
|
25644
|
+
const headView = new DataView(head2.buffer);
|
|
25645
|
+
headView.setUint32(0, 65536);
|
|
25646
|
+
headView.setUint32(4, 65536);
|
|
25647
|
+
headView.setUint32(12, 1594834165);
|
|
25648
|
+
headView.setUint16(16, 11);
|
|
25649
|
+
headView.setUint16(18, 1e3);
|
|
25650
|
+
headView.setInt16(38, -200);
|
|
25651
|
+
headView.setInt16(40, 1e3);
|
|
25652
|
+
headView.setInt16(42, 800);
|
|
25653
|
+
headView.setUint16(46, 8);
|
|
25654
|
+
headView.setInt16(48, 2);
|
|
25655
|
+
const hhea = new Uint8Array(36);
|
|
25656
|
+
const hheaView = new DataView(hhea.buffer);
|
|
25657
|
+
hheaView.setUint32(0, 65536);
|
|
25658
|
+
hheaView.setInt16(4, 800);
|
|
25659
|
+
hheaView.setInt16(6, -200);
|
|
25660
|
+
hheaView.setUint16(10, widest);
|
|
25661
|
+
hheaView.setInt16(18, 1);
|
|
25662
|
+
hheaView.setUint16(34, count);
|
|
25663
|
+
const maxp = new Uint8Array(32);
|
|
25664
|
+
const maxpView = new DataView(maxp.buffer);
|
|
25665
|
+
maxpView.setUint32(0, 65536);
|
|
25666
|
+
maxpView.setUint16(4, count);
|
|
25667
|
+
maxpView.setUint16(14, 1);
|
|
25668
|
+
const loca = new Uint8Array((count + 1) * 2);
|
|
25669
|
+
const glyf = new Uint8Array(4);
|
|
25670
|
+
return writeSfnt([
|
|
25671
|
+
["glyf", glyf],
|
|
25672
|
+
["head", head2],
|
|
25673
|
+
["hhea", hhea],
|
|
25674
|
+
["hmtx", hmtx],
|
|
25675
|
+
["loca", loca],
|
|
25676
|
+
["maxp", maxp]
|
|
25677
|
+
]);
|
|
25678
|
+
}
|
|
25679
|
+
|
|
25593
25680
|
// text/truetype/parse.ts
|
|
25594
25681
|
var u16 = (v, o) => o + 2 <= v.byteLength ? v.getUint16(o) : 0;
|
|
25595
25682
|
var i16 = (v, o) => o + 2 <= v.byteLength ? v.getInt16(o) : 0;
|
|
@@ -25719,13 +25806,6 @@ function parseTrueType(data) {
|
|
|
25719
25806
|
}
|
|
25720
25807
|
|
|
25721
25808
|
// text/truetype/subset.ts
|
|
25722
|
-
var pad4 = (n3) => n3 + 3 & -4;
|
|
25723
|
-
function checksum(bytes) {
|
|
25724
|
-
let sum = 0;
|
|
25725
|
-
for (let i2 = 0; i2 < bytes.length; i2 += 4)
|
|
25726
|
-
sum = sum + ((bytes[i2] ?? 0) << 24 | (bytes[i2 + 1] ?? 0) << 16 | (bytes[i2 + 2] ?? 0) << 8 | (bytes[i2 + 3] ?? 0)) >>> 0;
|
|
25727
|
-
return sum;
|
|
25728
|
-
}
|
|
25729
25809
|
function components(outline2) {
|
|
25730
25810
|
if (outline2.length < 10) return [];
|
|
25731
25811
|
const view = new DataView(outline2.buffer, outline2.byteOffset, outline2.byteLength);
|
|
@@ -25758,8 +25838,8 @@ function subsetTrueType(font, used) {
|
|
|
25758
25838
|
const source2 = font.outline(glyph2);
|
|
25759
25839
|
if (!source2.length) return source2;
|
|
25760
25840
|
const copy = Uint8Array.from(source2);
|
|
25761
|
-
const
|
|
25762
|
-
for (const part of components(copy))
|
|
25841
|
+
const view = new DataView(copy.buffer);
|
|
25842
|
+
for (const part of components(copy)) view.setUint16(part.offset, mapped.get(part.glyph) ?? 0);
|
|
25763
25843
|
return copy;
|
|
25764
25844
|
});
|
|
25765
25845
|
const count = glyphs.length;
|
|
@@ -25802,31 +25882,7 @@ function subsetTrueType(font, used) {
|
|
|
25802
25882
|
["maxp", maxp]
|
|
25803
25883
|
])
|
|
25804
25884
|
if (bytes) tables.push([name2, bytes]);
|
|
25805
|
-
|
|
25806
|
-
let total = directory;
|
|
25807
|
-
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
25808
|
-
const out = new Uint8Array(total);
|
|
25809
|
-
const view = new DataView(out.buffer);
|
|
25810
|
-
view.setUint32(0, 65536);
|
|
25811
|
-
view.setUint16(4, tables.length);
|
|
25812
|
-
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
25813
|
-
view.setUint16(6, power * 16);
|
|
25814
|
-
view.setUint16(8, Math.log2(power));
|
|
25815
|
-
view.setUint16(10, tables.length * 16 - power * 16);
|
|
25816
|
-
let position = directory;
|
|
25817
|
-
let headAt = 0;
|
|
25818
|
-
tables.forEach(([name2, bytes], index) => {
|
|
25819
|
-
const entry3 = 12 + index * 16;
|
|
25820
|
-
for (let i2 = 0; i2 < 4; i2++) out[entry3 + i2] = name2.charCodeAt(i2);
|
|
25821
|
-
view.setUint32(entry3 + 4, checksum(bytes));
|
|
25822
|
-
view.setUint32(entry3 + 8, position);
|
|
25823
|
-
view.setUint32(entry3 + 12, bytes.length);
|
|
25824
|
-
out.set(bytes, position);
|
|
25825
|
-
if (name2 === "head") headAt = position;
|
|
25826
|
-
position += pad4(bytes.length);
|
|
25827
|
-
});
|
|
25828
|
-
view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
25829
|
-
return { data: out, glyphs };
|
|
25885
|
+
return { data: writeSfnt(tables), glyphs };
|
|
25830
25886
|
}
|
|
25831
25887
|
|
|
25832
25888
|
// text/webfonts/google-fonts-catalogue.ts
|
package/dist/text/index.cjs
CHANGED
|
@@ -1708,6 +1708,91 @@ function readSfntFsType(data, header) {
|
|
|
1708
1708
|
return void 0;
|
|
1709
1709
|
}
|
|
1710
1710
|
|
|
1711
|
+
// text/truetype/sfnt-write.ts
|
|
1712
|
+
var pad4 = (n) => n + 3 & -4;
|
|
1713
|
+
function checksum(bytes) {
|
|
1714
|
+
let sum = 0;
|
|
1715
|
+
for (let i = 0; i < bytes.length; i += 4)
|
|
1716
|
+
sum = sum + ((bytes[i] ?? 0) << 24 | (bytes[i + 1] ?? 0) << 16 | (bytes[i + 2] ?? 0) << 8 | (bytes[i + 3] ?? 0)) >>> 0;
|
|
1717
|
+
return sum;
|
|
1718
|
+
}
|
|
1719
|
+
function writeSfnt(tables) {
|
|
1720
|
+
const directory = 12 + tables.length * 16;
|
|
1721
|
+
let total = directory;
|
|
1722
|
+
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
1723
|
+
const out = new Uint8Array(total);
|
|
1724
|
+
const view = new DataView(out.buffer);
|
|
1725
|
+
view.setUint32(0, 65536);
|
|
1726
|
+
view.setUint16(4, tables.length);
|
|
1727
|
+
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
1728
|
+
view.setUint16(6, power * 16);
|
|
1729
|
+
view.setUint16(8, Math.log2(power));
|
|
1730
|
+
view.setUint16(10, tables.length * 16 - power * 16);
|
|
1731
|
+
let position = directory;
|
|
1732
|
+
let headAt = -1;
|
|
1733
|
+
tables.forEach(([name2, bytes], index) => {
|
|
1734
|
+
const entry = 12 + index * 16;
|
|
1735
|
+
for (let i = 0; i < 4; i++) out[entry + i] = name2.charCodeAt(i);
|
|
1736
|
+
view.setUint32(entry + 4, checksum(bytes));
|
|
1737
|
+
view.setUint32(entry + 8, position);
|
|
1738
|
+
view.setUint32(entry + 12, bytes.length);
|
|
1739
|
+
out.set(bytes, position);
|
|
1740
|
+
if (name2 === "head") headAt = position;
|
|
1741
|
+
position += pad4(bytes.length);
|
|
1742
|
+
});
|
|
1743
|
+
if (headAt >= 0) view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
1744
|
+
return out;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
// text/truetype/glyphless.ts
|
|
1748
|
+
var MAX_GLYPHLESS_GLYPHS = 65535;
|
|
1749
|
+
function glyphlessTrueType(advances2) {
|
|
1750
|
+
const count = Math.min(MAX_GLYPHLESS_GLYPHS, Math.max(1, advances2.length));
|
|
1751
|
+
const advance = (glyph) => Math.max(0, Math.min(65535, Math.round(advances2[glyph] ?? 0)));
|
|
1752
|
+
let widest = 0;
|
|
1753
|
+
const hmtx = new Uint8Array(count * 4);
|
|
1754
|
+
const hmtxView = new DataView(hmtx.buffer);
|
|
1755
|
+
for (let glyph = 0; glyph < count; glyph++) {
|
|
1756
|
+
hmtxView.setUint16(glyph * 4, advance(glyph));
|
|
1757
|
+
widest = Math.max(widest, advance(glyph));
|
|
1758
|
+
}
|
|
1759
|
+
const head = new Uint8Array(54);
|
|
1760
|
+
const headView = new DataView(head.buffer);
|
|
1761
|
+
headView.setUint32(0, 65536);
|
|
1762
|
+
headView.setUint32(4, 65536);
|
|
1763
|
+
headView.setUint32(12, 1594834165);
|
|
1764
|
+
headView.setUint16(16, 11);
|
|
1765
|
+
headView.setUint16(18, 1e3);
|
|
1766
|
+
headView.setInt16(38, -200);
|
|
1767
|
+
headView.setInt16(40, 1e3);
|
|
1768
|
+
headView.setInt16(42, 800);
|
|
1769
|
+
headView.setUint16(46, 8);
|
|
1770
|
+
headView.setInt16(48, 2);
|
|
1771
|
+
const hhea = new Uint8Array(36);
|
|
1772
|
+
const hheaView = new DataView(hhea.buffer);
|
|
1773
|
+
hheaView.setUint32(0, 65536);
|
|
1774
|
+
hheaView.setInt16(4, 800);
|
|
1775
|
+
hheaView.setInt16(6, -200);
|
|
1776
|
+
hheaView.setUint16(10, widest);
|
|
1777
|
+
hheaView.setInt16(18, 1);
|
|
1778
|
+
hheaView.setUint16(34, count);
|
|
1779
|
+
const maxp = new Uint8Array(32);
|
|
1780
|
+
const maxpView = new DataView(maxp.buffer);
|
|
1781
|
+
maxpView.setUint32(0, 65536);
|
|
1782
|
+
maxpView.setUint16(4, count);
|
|
1783
|
+
maxpView.setUint16(14, 1);
|
|
1784
|
+
const loca = new Uint8Array((count + 1) * 2);
|
|
1785
|
+
const glyf = new Uint8Array(4);
|
|
1786
|
+
return writeSfnt([
|
|
1787
|
+
["glyf", glyf],
|
|
1788
|
+
["head", head],
|
|
1789
|
+
["hhea", hhea],
|
|
1790
|
+
["hmtx", hmtx],
|
|
1791
|
+
["loca", loca],
|
|
1792
|
+
["maxp", maxp]
|
|
1793
|
+
]);
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1711
1796
|
// text/truetype/parse.ts
|
|
1712
1797
|
var u16 = (v, o) => o + 2 <= v.byteLength ? v.getUint16(o) : 0;
|
|
1713
1798
|
var i16 = (v, o) => o + 2 <= v.byteLength ? v.getInt16(o) : 0;
|
|
@@ -1837,13 +1922,6 @@ function parseTrueType(data) {
|
|
|
1837
1922
|
}
|
|
1838
1923
|
|
|
1839
1924
|
// text/truetype/subset.ts
|
|
1840
|
-
var pad4 = (n) => n + 3 & -4;
|
|
1841
|
-
function checksum(bytes) {
|
|
1842
|
-
let sum = 0;
|
|
1843
|
-
for (let i = 0; i < bytes.length; i += 4)
|
|
1844
|
-
sum = sum + ((bytes[i] ?? 0) << 24 | (bytes[i + 1] ?? 0) << 16 | (bytes[i + 2] ?? 0) << 8 | (bytes[i + 3] ?? 0)) >>> 0;
|
|
1845
|
-
return sum;
|
|
1846
|
-
}
|
|
1847
1925
|
function components(outline) {
|
|
1848
1926
|
if (outline.length < 10) return [];
|
|
1849
1927
|
const view = new DataView(outline.buffer, outline.byteOffset, outline.byteLength);
|
|
@@ -1876,8 +1954,8 @@ function subsetTrueType(font, used) {
|
|
|
1876
1954
|
const source = font.outline(glyph);
|
|
1877
1955
|
if (!source.length) return source;
|
|
1878
1956
|
const copy = Uint8Array.from(source);
|
|
1879
|
-
const
|
|
1880
|
-
for (const part of components(copy))
|
|
1957
|
+
const view = new DataView(copy.buffer);
|
|
1958
|
+
for (const part of components(copy)) view.setUint16(part.offset, mapped.get(part.glyph) ?? 0);
|
|
1881
1959
|
return copy;
|
|
1882
1960
|
});
|
|
1883
1961
|
const count = glyphs.length;
|
|
@@ -1920,31 +1998,7 @@ function subsetTrueType(font, used) {
|
|
|
1920
1998
|
["maxp", maxp]
|
|
1921
1999
|
])
|
|
1922
2000
|
if (bytes) tables.push([name2, bytes]);
|
|
1923
|
-
|
|
1924
|
-
let total = directory;
|
|
1925
|
-
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
1926
|
-
const out = new Uint8Array(total);
|
|
1927
|
-
const view = new DataView(out.buffer);
|
|
1928
|
-
view.setUint32(0, 65536);
|
|
1929
|
-
view.setUint16(4, tables.length);
|
|
1930
|
-
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
1931
|
-
view.setUint16(6, power * 16);
|
|
1932
|
-
view.setUint16(8, Math.log2(power));
|
|
1933
|
-
view.setUint16(10, tables.length * 16 - power * 16);
|
|
1934
|
-
let position = directory;
|
|
1935
|
-
let headAt = 0;
|
|
1936
|
-
tables.forEach(([name2, bytes], index) => {
|
|
1937
|
-
const entry = 12 + index * 16;
|
|
1938
|
-
for (let i = 0; i < 4; i++) out[entry + i] = name2.charCodeAt(i);
|
|
1939
|
-
view.setUint32(entry + 4, checksum(bytes));
|
|
1940
|
-
view.setUint32(entry + 8, position);
|
|
1941
|
-
view.setUint32(entry + 12, bytes.length);
|
|
1942
|
-
out.set(bytes, position);
|
|
1943
|
-
if (name2 === "head") headAt = position;
|
|
1944
|
-
position += pad4(bytes.length);
|
|
1945
|
-
});
|
|
1946
|
-
view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
1947
|
-
return { data: out, glyphs };
|
|
2001
|
+
return { data: writeSfnt(tables), glyphs };
|
|
1948
2002
|
}
|
|
1949
2003
|
|
|
1950
2004
|
// text/webfonts/google-fonts-catalogue.ts
|
|
@@ -4487,6 +4541,7 @@ exports.GOOGLE_FONTS_CATALOGUE_DATE = GOOGLE_FONTS_CATALOGUE_DATE;
|
|
|
4487
4541
|
exports.GOOGLE_FONTS_CSS2_BASE = GOOGLE_FONTS_CSS2_BASE;
|
|
4488
4542
|
exports.GOOGLE_FONTS_FAMILIES = GOOGLE_FONTS_FAMILIES;
|
|
4489
4543
|
exports.GOOGLE_WEBFONT_AXIS = GOOGLE_WEBFONT_AXIS;
|
|
4544
|
+
exports.MAX_GLYPHLESS_GLYPHS = MAX_GLYPHLESS_GLYPHS;
|
|
4490
4545
|
exports.METRIC_FONT_SUBSTITUTES = METRIC_FONT_SUBSTITUTES;
|
|
4491
4546
|
exports.OOXML_DATETIME_PATTERNS = OOXML_DATETIME_PATTERNS;
|
|
4492
4547
|
exports.PANOSE_FAMILY_MAP = PANOSE_FAMILY_MAP;
|
|
@@ -4526,6 +4581,7 @@ exports.getLeaderStyles = getLeaderStyles;
|
|
|
4526
4581
|
exports.getPanoseWeight = getPanoseWeight;
|
|
4527
4582
|
exports.getSubstituteFontFamily = getSubstituteFontFamily;
|
|
4528
4583
|
exports.getSubstituteFonts = getSubstituteFonts;
|
|
4584
|
+
exports.glyphlessTrueType = glyphlessTrueType;
|
|
4529
4585
|
exports.hangsAtLineEnd = hangsAtLineEnd;
|
|
4530
4586
|
exports.hasDesignAdvances = hasDesignAdvances;
|
|
4531
4587
|
exports.hasDirectSubstitution = hasDirectSubstitution;
|
package/dist/text/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './font-substitution.js';
|
|
|
18
18
|
export * from './metric-font-family.js';
|
|
19
19
|
export * from './script-fonts.js';
|
|
20
20
|
export * from './truetype/embedding.js';
|
|
21
|
+
export { glyphlessTrueType, MAX_GLYPHLESS_GLYPHS } from './truetype/glyphless.js';
|
|
21
22
|
export { parseTrueType, type TrueTypeFont } from './truetype/parse.js';
|
|
22
23
|
export { subsetTrueType, type TrueTypeSubset } from './truetype/subset.js';
|
|
23
24
|
export * from './webfonts/index.js';
|
package/dist/text/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../text/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,SAAS,GACd,MAAM,4BAA4B,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,cAAc,YAAY,CAAC;AAC3B,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,KAAK,SAAS,GACd,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../text/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,SAAS,GACd,MAAM,4BAA4B,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,cAAc,YAAY,CAAC;AAC3B,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,KAAK,SAAS,GACd,MAAM,eAAe,CAAC"}
|
package/dist/text/index.mjs
CHANGED
|
@@ -1706,6 +1706,91 @@ function readSfntFsType(data, header) {
|
|
|
1706
1706
|
return void 0;
|
|
1707
1707
|
}
|
|
1708
1708
|
|
|
1709
|
+
// text/truetype/sfnt-write.ts
|
|
1710
|
+
var pad4 = (n) => n + 3 & -4;
|
|
1711
|
+
function checksum(bytes) {
|
|
1712
|
+
let sum = 0;
|
|
1713
|
+
for (let i = 0; i < bytes.length; i += 4)
|
|
1714
|
+
sum = sum + ((bytes[i] ?? 0) << 24 | (bytes[i + 1] ?? 0) << 16 | (bytes[i + 2] ?? 0) << 8 | (bytes[i + 3] ?? 0)) >>> 0;
|
|
1715
|
+
return sum;
|
|
1716
|
+
}
|
|
1717
|
+
function writeSfnt(tables) {
|
|
1718
|
+
const directory = 12 + tables.length * 16;
|
|
1719
|
+
let total = directory;
|
|
1720
|
+
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
1721
|
+
const out = new Uint8Array(total);
|
|
1722
|
+
const view = new DataView(out.buffer);
|
|
1723
|
+
view.setUint32(0, 65536);
|
|
1724
|
+
view.setUint16(4, tables.length);
|
|
1725
|
+
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
1726
|
+
view.setUint16(6, power * 16);
|
|
1727
|
+
view.setUint16(8, Math.log2(power));
|
|
1728
|
+
view.setUint16(10, tables.length * 16 - power * 16);
|
|
1729
|
+
let position = directory;
|
|
1730
|
+
let headAt = -1;
|
|
1731
|
+
tables.forEach(([name2, bytes], index) => {
|
|
1732
|
+
const entry = 12 + index * 16;
|
|
1733
|
+
for (let i = 0; i < 4; i++) out[entry + i] = name2.charCodeAt(i);
|
|
1734
|
+
view.setUint32(entry + 4, checksum(bytes));
|
|
1735
|
+
view.setUint32(entry + 8, position);
|
|
1736
|
+
view.setUint32(entry + 12, bytes.length);
|
|
1737
|
+
out.set(bytes, position);
|
|
1738
|
+
if (name2 === "head") headAt = position;
|
|
1739
|
+
position += pad4(bytes.length);
|
|
1740
|
+
});
|
|
1741
|
+
if (headAt >= 0) view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
1742
|
+
return out;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
// text/truetype/glyphless.ts
|
|
1746
|
+
var MAX_GLYPHLESS_GLYPHS = 65535;
|
|
1747
|
+
function glyphlessTrueType(advances2) {
|
|
1748
|
+
const count = Math.min(MAX_GLYPHLESS_GLYPHS, Math.max(1, advances2.length));
|
|
1749
|
+
const advance = (glyph) => Math.max(0, Math.min(65535, Math.round(advances2[glyph] ?? 0)));
|
|
1750
|
+
let widest = 0;
|
|
1751
|
+
const hmtx = new Uint8Array(count * 4);
|
|
1752
|
+
const hmtxView = new DataView(hmtx.buffer);
|
|
1753
|
+
for (let glyph = 0; glyph < count; glyph++) {
|
|
1754
|
+
hmtxView.setUint16(glyph * 4, advance(glyph));
|
|
1755
|
+
widest = Math.max(widest, advance(glyph));
|
|
1756
|
+
}
|
|
1757
|
+
const head = new Uint8Array(54);
|
|
1758
|
+
const headView = new DataView(head.buffer);
|
|
1759
|
+
headView.setUint32(0, 65536);
|
|
1760
|
+
headView.setUint32(4, 65536);
|
|
1761
|
+
headView.setUint32(12, 1594834165);
|
|
1762
|
+
headView.setUint16(16, 11);
|
|
1763
|
+
headView.setUint16(18, 1e3);
|
|
1764
|
+
headView.setInt16(38, -200);
|
|
1765
|
+
headView.setInt16(40, 1e3);
|
|
1766
|
+
headView.setInt16(42, 800);
|
|
1767
|
+
headView.setUint16(46, 8);
|
|
1768
|
+
headView.setInt16(48, 2);
|
|
1769
|
+
const hhea = new Uint8Array(36);
|
|
1770
|
+
const hheaView = new DataView(hhea.buffer);
|
|
1771
|
+
hheaView.setUint32(0, 65536);
|
|
1772
|
+
hheaView.setInt16(4, 800);
|
|
1773
|
+
hheaView.setInt16(6, -200);
|
|
1774
|
+
hheaView.setUint16(10, widest);
|
|
1775
|
+
hheaView.setInt16(18, 1);
|
|
1776
|
+
hheaView.setUint16(34, count);
|
|
1777
|
+
const maxp = new Uint8Array(32);
|
|
1778
|
+
const maxpView = new DataView(maxp.buffer);
|
|
1779
|
+
maxpView.setUint32(0, 65536);
|
|
1780
|
+
maxpView.setUint16(4, count);
|
|
1781
|
+
maxpView.setUint16(14, 1);
|
|
1782
|
+
const loca = new Uint8Array((count + 1) * 2);
|
|
1783
|
+
const glyf = new Uint8Array(4);
|
|
1784
|
+
return writeSfnt([
|
|
1785
|
+
["glyf", glyf],
|
|
1786
|
+
["head", head],
|
|
1787
|
+
["hhea", hhea],
|
|
1788
|
+
["hmtx", hmtx],
|
|
1789
|
+
["loca", loca],
|
|
1790
|
+
["maxp", maxp]
|
|
1791
|
+
]);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1709
1794
|
// text/truetype/parse.ts
|
|
1710
1795
|
var u16 = (v, o) => o + 2 <= v.byteLength ? v.getUint16(o) : 0;
|
|
1711
1796
|
var i16 = (v, o) => o + 2 <= v.byteLength ? v.getInt16(o) : 0;
|
|
@@ -1835,13 +1920,6 @@ function parseTrueType(data) {
|
|
|
1835
1920
|
}
|
|
1836
1921
|
|
|
1837
1922
|
// text/truetype/subset.ts
|
|
1838
|
-
var pad4 = (n) => n + 3 & -4;
|
|
1839
|
-
function checksum(bytes) {
|
|
1840
|
-
let sum = 0;
|
|
1841
|
-
for (let i = 0; i < bytes.length; i += 4)
|
|
1842
|
-
sum = sum + ((bytes[i] ?? 0) << 24 | (bytes[i + 1] ?? 0) << 16 | (bytes[i + 2] ?? 0) << 8 | (bytes[i + 3] ?? 0)) >>> 0;
|
|
1843
|
-
return sum;
|
|
1844
|
-
}
|
|
1845
1923
|
function components(outline) {
|
|
1846
1924
|
if (outline.length < 10) return [];
|
|
1847
1925
|
const view = new DataView(outline.buffer, outline.byteOffset, outline.byteLength);
|
|
@@ -1874,8 +1952,8 @@ function subsetTrueType(font, used) {
|
|
|
1874
1952
|
const source = font.outline(glyph);
|
|
1875
1953
|
if (!source.length) return source;
|
|
1876
1954
|
const copy = Uint8Array.from(source);
|
|
1877
|
-
const
|
|
1878
|
-
for (const part of components(copy))
|
|
1955
|
+
const view = new DataView(copy.buffer);
|
|
1956
|
+
for (const part of components(copy)) view.setUint16(part.offset, mapped.get(part.glyph) ?? 0);
|
|
1879
1957
|
return copy;
|
|
1880
1958
|
});
|
|
1881
1959
|
const count = glyphs.length;
|
|
@@ -1918,31 +1996,7 @@ function subsetTrueType(font, used) {
|
|
|
1918
1996
|
["maxp", maxp]
|
|
1919
1997
|
])
|
|
1920
1998
|
if (bytes) tables.push([name2, bytes]);
|
|
1921
|
-
|
|
1922
|
-
let total = directory;
|
|
1923
|
-
for (const [, bytes] of tables) total += pad4(bytes.length);
|
|
1924
|
-
const out = new Uint8Array(total);
|
|
1925
|
-
const view = new DataView(out.buffer);
|
|
1926
|
-
view.setUint32(0, 65536);
|
|
1927
|
-
view.setUint16(4, tables.length);
|
|
1928
|
-
const power = 2 ** Math.floor(Math.log2(tables.length));
|
|
1929
|
-
view.setUint16(6, power * 16);
|
|
1930
|
-
view.setUint16(8, Math.log2(power));
|
|
1931
|
-
view.setUint16(10, tables.length * 16 - power * 16);
|
|
1932
|
-
let position = directory;
|
|
1933
|
-
let headAt = 0;
|
|
1934
|
-
tables.forEach(([name2, bytes], index) => {
|
|
1935
|
-
const entry = 12 + index * 16;
|
|
1936
|
-
for (let i = 0; i < 4; i++) out[entry + i] = name2.charCodeAt(i);
|
|
1937
|
-
view.setUint32(entry + 4, checksum(bytes));
|
|
1938
|
-
view.setUint32(entry + 8, position);
|
|
1939
|
-
view.setUint32(entry + 12, bytes.length);
|
|
1940
|
-
out.set(bytes, position);
|
|
1941
|
-
if (name2 === "head") headAt = position;
|
|
1942
|
-
position += pad4(bytes.length);
|
|
1943
|
-
});
|
|
1944
|
-
view.setUint32(headAt + 8, 2981146554 - checksum(out) >>> 0);
|
|
1945
|
-
return { data: out, glyphs };
|
|
1999
|
+
return { data: writeSfnt(tables), glyphs };
|
|
1946
2000
|
}
|
|
1947
2001
|
|
|
1948
2002
|
// text/webfonts/google-fonts-catalogue.ts
|
|
@@ -4479,4 +4533,4 @@ function textWithoutTags(html) {
|
|
|
4479
4533
|
return out + html.slice(at);
|
|
4480
4534
|
}
|
|
4481
4535
|
|
|
4482
|
-
export { AUTO_SPACE_EM, FONT_SUBSTITUTION_MAP, GOOGLE_FONTS_CATALOGUE_DATE, GOOGLE_FONTS_CSS2_BASE, GOOGLE_FONTS_FAMILIES, GOOGLE_WEBFONT_AXIS, METRIC_FONT_SUBSTITUTES, OOXML_DATETIME_PATTERNS, PANOSE_FAMILY_MAP, PANOSE_MONOSPACE_PROPORTION, PANOSE_SANS_SERIF_STYLES, PANOSE_WEIGHT_MAP, TEXT_CASE_MODES, buildFontFamilyString, buildGoogleFontsFragment, buildGoogleFontsHref, buildLeaderString, changeTextCase, changeTextCaseRanges, classifyPanose, collectRunFamilies, collectWebfontFaces, complexBreakAllowed, decimalAnchorIndex, decimalSeparatorForLanguage, decodeHtmlEntities, designTextWidthEm, detectFontScript, distributeRunsText, eastAsianAutoSpace, embeddingPermission, findGoogleFontsFamily, findLookAlikeGoogleFontsFamily, findMetricCompatibleGoogleFontsFamily, fontStyleShorthand, fontWeightAttribute, fontWeightShorthand, formatDatePicture, formatLocaleNumber, getGoogleFontsVariants, getLeaderCharacter, getLeaderStyles, getPanoseWeight, getSubstituteFontFamily, getSubstituteFonts, hangsAtLineEnd, hasDesignAdvances, hasDirectSubstitution, hasDistinctScriptFonts, htmlClipboardFragment, isComplexBreakChar, isEastAsianChar, isEastAsianLetter, kinsokuLanguage, kinsokuSets, matchGoogleWebfontFragments, mayDisplayEmbeddedFont, mayEmbedFontInEditableDocument, mayEmbedFontSubset, mergeTextThreeWay, metricFontFamily, namedFontVerticalMetrics, normalizeGoogleFontsBaseUrl, officeFontVerticalMetrics, ooxmlDateTimeFieldPicture, parseCssColorHex, parseCssDeclarations, parseFontWeightName, parseHtmlAttributes, parseLocaleNumber, parsePanoseBytes, parsePanoseString, parseTrueType, parseTsv, prohibitedAtLineEnd, prohibitedAtLineStart, readSfntFsType, realignOrCollapseRuns, resolveFontForScript, resolveFontItalic, resolveFontWeight, resolveGoogleFontsCss2Base, resolveGoogleFontsFace, resolveScriptFontSet, segmentByFont, segmentByScript, selectGoogleWebfontFamilies, servedGoogleFontsFamily, stripFontStyleSuffix, subsetTrueType, toTsv, tokenizeHtml, wrapStyledRuns };
|
|
4536
|
+
export { AUTO_SPACE_EM, FONT_SUBSTITUTION_MAP, GOOGLE_FONTS_CATALOGUE_DATE, GOOGLE_FONTS_CSS2_BASE, GOOGLE_FONTS_FAMILIES, GOOGLE_WEBFONT_AXIS, MAX_GLYPHLESS_GLYPHS, METRIC_FONT_SUBSTITUTES, OOXML_DATETIME_PATTERNS, PANOSE_FAMILY_MAP, PANOSE_MONOSPACE_PROPORTION, PANOSE_SANS_SERIF_STYLES, PANOSE_WEIGHT_MAP, TEXT_CASE_MODES, buildFontFamilyString, buildGoogleFontsFragment, buildGoogleFontsHref, buildLeaderString, changeTextCase, changeTextCaseRanges, classifyPanose, collectRunFamilies, collectWebfontFaces, complexBreakAllowed, decimalAnchorIndex, decimalSeparatorForLanguage, decodeHtmlEntities, designTextWidthEm, detectFontScript, distributeRunsText, eastAsianAutoSpace, embeddingPermission, findGoogleFontsFamily, findLookAlikeGoogleFontsFamily, findMetricCompatibleGoogleFontsFamily, fontStyleShorthand, fontWeightAttribute, fontWeightShorthand, formatDatePicture, formatLocaleNumber, getGoogleFontsVariants, getLeaderCharacter, getLeaderStyles, getPanoseWeight, getSubstituteFontFamily, getSubstituteFonts, glyphlessTrueType, hangsAtLineEnd, hasDesignAdvances, hasDirectSubstitution, hasDistinctScriptFonts, htmlClipboardFragment, isComplexBreakChar, isEastAsianChar, isEastAsianLetter, kinsokuLanguage, kinsokuSets, matchGoogleWebfontFragments, mayDisplayEmbeddedFont, mayEmbedFontInEditableDocument, mayEmbedFontSubset, mergeTextThreeWay, metricFontFamily, namedFontVerticalMetrics, normalizeGoogleFontsBaseUrl, officeFontVerticalMetrics, ooxmlDateTimeFieldPicture, parseCssColorHex, parseCssDeclarations, parseFontWeightName, parseHtmlAttributes, parseLocaleNumber, parsePanoseBytes, parsePanoseString, parseTrueType, parseTsv, prohibitedAtLineEnd, prohibitedAtLineStart, readSfntFsType, realignOrCollapseRuns, resolveFontForScript, resolveFontItalic, resolveFontWeight, resolveGoogleFontsCss2Base, resolveGoogleFontsFace, resolveScriptFontSet, segmentByFont, segmentByScript, selectGoogleWebfontFamilies, servedGoogleFontsFamily, stripFontStyleSuffix, subsetTrueType, toTsv, tokenizeHtml, wrapStyledRuns };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The most glyphs a TrueType font addresses. */
|
|
2
|
+
export declare const MAX_GLYPHLESS_GLYPHS = 65535;
|
|
3
|
+
/** A font of `advances.length` empty glyphs (at least one, `.notdef`), 1000 units per em. */
|
|
4
|
+
export declare function glyphlessTrueType(advances: readonly number[]): Uint8Array;
|
|
5
|
+
//# sourceMappingURL=glyphless.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphless.d.ts","sourceRoot":"","sources":["../../../text/truetype/glyphless.ts"],"names":[],"mappings":"AASA,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAgDzE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write an sfnt (TrueType) font file from its tables: the table directory with checksums, each
|
|
3
|
+
* table padded to four bytes, and the `head` table's checksum adjustment. The tables are written
|
|
4
|
+
* in the order given (callers pass them sorted by tag). DOM-free.
|
|
5
|
+
*/
|
|
6
|
+
/** `n` rounded up to a multiple of four. */
|
|
7
|
+
export declare const pad4: (n: number) => number;
|
|
8
|
+
/** The font file holding `tables` (`[tag, bytes]`, sorted by tag). */
|
|
9
|
+
export declare function writeSfnt(tables: readonly (readonly [string, Uint8Array])[]): Uint8Array;
|
|
10
|
+
//# sourceMappingURL=sfnt-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sfnt-write.d.ts","sourceRoot":"","sources":["../../../text/truetype/sfnt-write.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4CAA4C;AAC5C,eAAO,MAAM,IAAI,MAAO,MAAM,KAAG,MAAsB,CAAC;AAexD,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,UAAU,CA0BxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../../text/truetype/subset.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../../text/truetype/subset.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,MAAM,WAAW,cAAc;IAC9B,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAqBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAqE1F"}
|