Giter Club home page Giter Club logo

Comments (2)

Pomax avatar Pomax commented on July 2, 2024

As a slightly more elaborate test, using https://fonts.google.com/noto/specimen/Noto+Sans+New+Tai+Lue:

const fs = require("fs");
const fontkit = require("fontkit");
const font = fs.readFileSync("./NotoSansNewTaiLue-Regular.ttf");
const fontObject = fontkit.create(font);
const glyphs = fontObject.glyphsForString(" ");
console.log(glyphs[0]);
console.log(glyphs[0].advanceWidth);

yields:

<ref *1> $f680320fa07ef53d$export$2e2bcd8739ae039 {
  id: 440,
  codePoints: [ 32 ],
  _font: $0a8ef2660a6ce4b6$export$2e2bcd8739ae039 {
    type: 'TTF',
    defaultLanguage: null,
    stream: $8ae20583b93e4933$export$c18b354bac7948e9 {
      buffer: <Buffer 00 01 00 00 00 10 01 00 00 04 00 00 47 44 45 46 09 41 09 81 00 00 01 c8 00 00 00 54 47 50 4f 53 a6 ee 44 e4 00 00 25 00 00 00 1d 04 47 53 55 42 9a 2e ... 47330 more bytes>,
      view: [DataView],
      pos: 268,
      length: 47380
    },
    variationCoords: null,
    _directoryPos: 0,
    _tables: { cmap: [Object] },
    _glyphs: { '440': [Circular *1] },
    directory: {
      tag: '\x00\x01\x00\x00',
      numTables: 16,
      searchRange: 256,
      entrySelector: 4,
      rangeShift: 0,
      tables: [Object]
    }
  },
  isMark: false,
  isLigature: false,
  type: 'TTF'
}
d:\temp\node_modules\restructure\dist\main.cjs:91
        const ret = this.view[key](this.pos, false);
                                  ^

RangeError: Offset is outside the bounds of the DataView
    at DataView.getInt16 (<anonymous>)
    at $8ae20583b93e4933$export$c18b354bac7948e9.<computed> [as readInt16BE] (d:\temp\node_modules\restructure\dist\main.cjs:91:35)
    at $af65abf7bf65ac42$export$fffa67e515d04022.decode (d:\temp\node_modules\restructure\dist\main.cjs:268:40)
    at $aa8b66bae6abe658$export$eabc71f011df675a._parseFields (d:\temp\node_modules\restructure\dist\main.cjs:732:29)
    at $aa8b66bae6abe658$export$eabc71f011df675a.decode (d:\temp\node_modules\restructure\dist\main.cjs:703:14)
    at $f680320fa07ef53d$export$2e2bcd8739ae039._getCBox (d:\temp\node_modules\fontkit\dist\main.cjs:10906:54)
    at $f680320fa07ef53d$export$2e2bcd8739ae039._getMetrics (d:\temp\node_modules\fontkit\dist\main.cjs:11074:25)
    at get advanceWidth (d:\temp\node_modules\fontkit\dist\main.cjs:10764:21)
    at descriptor.get (d:\temp\node_modules\fontkit\dist\main.cjs:92:29)
    at Object.<anonymous> (d:\temp\test.js:7:23)

Node.js v18.14.1

from fontkit.

iamakulov avatar iamakulov commented on July 2, 2024

Yup, indeed! The exception happens only when you access .advanceWidth.

from fontkit.

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.