@@ -208,6 +208,15 @@ class CustomFontEmbedder {
208208 }
209209
210210 protected computeWidths ( ) : ( number | number [ ] ) [ ] {
211+
212+ /*
213+ let flag = false;
214+ if (/firasans-regular/i.test(this.fontName)) {
215+ console.info("Calling computeWidths", this);
216+ flag = true;
217+ }
218+ */
219+
211220 const glyphs = this . glyphCache . access ( ) ;
212221
213222 const widths : ( number | number [ ] ) [ ] = [ ] ;
@@ -228,6 +237,12 @@ class CustomFontEmbedder {
228237 currSection = [ ] ;
229238 }
230239
240+ /*
241+ if (flag && currGlyph.codePoints[0] === 48) {
242+ console.info('48', currGlyph);
243+ }
244+ */
245+
231246 currSection . push ( currGlyph . advanceWidth * this . scale ) ;
232247 }
233248
@@ -236,6 +251,7 @@ class CustomFontEmbedder {
236251 return widths ;
237252 }
238253
254+ /*
239255 private allGlyphsInFontSortedById = (): Glyph[] => {
240256 const glyphs: Glyph[] = new Array(this.font.characterSet.length);
241257 for (let idx = 0, len = glyphs.length; idx < len; idx++) {
@@ -244,6 +260,20 @@ class CustomFontEmbedder {
244260 }
245261 return sortedUniq(glyphs.sort(byAscendingId), (g) => g.id);
246262 };
263+ */
264+
265+ /**
266+ * thanks to @phipla, see
267+ * https://github.com/Hopding/pdf-lib/pull/1325
268+ */
269+ private allGlyphsInFontSortedById = ( ) : Glyph [ ] => {
270+ const glyphs : Glyph [ ] = new Array ( this . font . numGlyphs ) ;
271+ for ( let idx = 0 , len = glyphs . length ; idx < len ; idx ++ ) {
272+ glyphs [ idx ] = this . font . getGlyph ( idx ) ;
273+ }
274+ return sortedUniq ( glyphs . sort ( byAscendingId ) , ( g ) => g . id ) ;
275+ } ;
276+
247277}
248278
249279export default CustomFontEmbedder ;
0 commit comments