Giter VIP home page Giter VIP logo

Comments (10)

Pomax avatar Pomax commented on August 15, 2024 1

I've filed #115 for fixing woff2 parsing

from lib-font.

Pomax avatar Pomax commented on August 15, 2024 1

closing this issue as the code fixes for woff2 support are handled in #115 instead.

from lib-font.

Pomax avatar Pomax commented on August 15, 2024

Hm, running test.js on those fonts reveals that woff2 files aren't actually being decoded properly at all, so that's something to dig into.

from lib-font.

Pomax avatar Pomax commented on August 15, 2024

@RoelN so it looks like at least in the browser all those fonts work fine, but the two "numbers only" fonts don't have GSUB tables, so if your testing doesn't check whether font.opentype.tables.GSUB is undefined that might cause runtime errors rather than test errors:

$ ttx 135abd30-1390-4f9c-b6a2-d843157c3468.woff2
Dumping "135abd30-1390-4f9c-b6a2-d843157c3468.woff2" to "135abd30-1390-4f9c-b6a2-d843157c3468.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'name' table...
Dumping 'cmap' table...
Dumping 'post' table...
Dumping 'CFF ' table...
Dumping 'GPOS' table...
Dumping 'hmtx' table...

and

$ ttx 64017d81-9430-4cba-8219-8f5cc28b923e.woff2
Dumping "64017d81-9430-4cba-8219-8f5cc28b923e.woff2" to "64017d81-9430-4cba-8219-8f5cc28b923e.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'hmtx' table...
Dumping 'LTSH' table...
Dumping 'VDMX' table...
Dumping 'hdmx' table...
Dumping 'cmap' table...
Dumping 'fpgm' table...
Dumping 'prep' table...
Dumping 'cvt ' table...
Dumping 'loca' table...
Dumping 'glyf' table...
ERROR: 'name' table stringOffset incorrect. Expected: 294; Actual: 354
Dumping 'name' table...
Dumping 'post' table...
Dumping 'gasp' table...

from lib-font.

RoelN avatar RoelN commented on August 15, 2024

We might have cheered too soon! Two fonts still trip up LibFont. For instance, the Proxima Nova one:

import { Font } from "./lib-font.js";

const font = new Font("woff2 testing");
// font.src = `./fonts/broken/BrushPosterGrotesk.woff2`;
// font.src = `./fonts/broken/64017d81-9430-4cba-8219-8f5cc28b923e.woff2`;
// font.src = `./fonts/broken/135abd30-1390-4f9c-b6a2-d843157c3468.woff2`;
font.src = `./fonts/broken/proximanova-regular-webfont.woff2`;
font.onerror = (evt) => console.error(evt);
font.onload = (evt) => {
  let font = evt.detail.font;
  const { name } = font.opentype.tables;
  console.log(name);
};

gives:

$ node test.js
parser getUint16 2 Parser {
  name: 'name',
  length: 1638,
  start: 0,
  offset: 1640,
  data: DataView {
    byteLength: 1638,
    byteOffset: 0,
    buffer: ArrayBuffer {
      [Uint8Contents]: <01 7c 01 7d 01 7e 01 7f 01 80 01 81 01 82 01 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8a 01 8b 01 8c 01 8d 01 8e 01 8f 01 90 01 91 01 92 00 d8 00 e1 01 93 01 94 00 db 00 dc 00 dd 00 e0 00 d9 00 df 01 95 01 96 01 97 01 98 01 99 01 9a 01 9b 01 9c 01 9d 01 9e 01 9f 01 a0 01 a1 01 a2 01 a3 01 a4 01 a5 ... 1538 more bytes>,
      byteLength: 1638
    }
  }
}
parser 0 1640
Event {
  type: 'error',
  detail: RangeError: Offset is outside the bounds of the DataView
      at DataView.getUint16 (<anonymous>)
      at Parser.getValue (file:///Users/roel/code/lib-font/src/parser.js:60:29)
      at Parser.get (file:///Users/roel/code/lib-font/src/parser.js:38:25)
      at new NameRecord (file:///Users/roel/code/lib-font/src/opentype/tables/simple/name.js:60:25)
      at file:///Users/roel/code/lib-font/src/opentype/tables/simple/name.js:20:14
      at Array.map (<anonymous>)
      at new name (file:///Users/roel/code/lib-font/src/opentype/tables/simple/name.js:19:51)
      at createTable (file:///Users/roel/code/lib-font/src/opentype/tables/createTable.js:88:20)
      at file:///Users/roel/code/lib-font/src/opentype/woff2.js:125:14
      at Object.get (file:///Users/roel/code/lib-font/src/lazy.js:15:13),
  msg: 'Failed to load font at ./fonts/broken/proximanova-regular-webfont.woff2'
}

A similar error is given for BrushPosterGrotesk.woff2.

Not sure if this is related to the WOFF2 handling, or something to the name table code specifically?

from lib-font.

RoelN avatar RoelN commented on August 15, 2024

I added some more fonts to test with!

from lib-font.

Pomax avatar Pomax commented on August 15, 2024

I've had to remove some links from your updated list, because they contained a number of heavily licensed fonts that may most certainly not be redistributed =)

from lib-font.

Pomax avatar Pomax commented on August 15, 2024

Flaticon investigation issue: #120

from lib-font.

Pomax avatar Pomax commented on August 15, 2024

#120 was resolved, with v2.3.0 published to npm: @RoelN this should have fixed all the things, but if not, let me know.

from lib-font.

RoelN avatar RoelN commented on August 15, 2024

Thanks @Pomax, this is working nicely! I've integrated it in my local Wakamai Fondue build, and all fond that previously broke it, are now working fine!

from lib-font.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.