GithubHelp home page GithubHelp logo

Comments (1)

Pomax avatar Pomax commented on July 23, 2024

The readme does mention that over in https://github.com/foliojs/fontkit#other-properties, the characterSet property is specifically for Unicode codepoint glyphs only. If you compare its length to numGlyphs, though, you will see that Fontkit does know that Calibri has over 6.5k glyphs:

const fontkit = require("fontkit");
const fs = require("fs/promises");
fs.readFile("./calibri.ttf")
  .then((font) => {
    font = fontkit.create(Buffer.from(font));
    console.log(font.numGlyphs);
    console.log(font.characterSet.length);
  })
  .catch(err => console.error(err));

outputs:

6954
3663

So if you want to work with the non-unicode glyphs, you'll have to build that list, but then you might still not be able to actually access those characters given that Fontkit's API is built around working specifically with Unicode codepoints.

However, also note that a ton of glyphs are not "letters": glyphs are just vector graphics, and while some glyphs are actual letters, with an associated code point, plenty are just "components" that used in other glyphs, and would make no sense when rendered in isolation: if you load Calibri in an actual font editor, you'll see it contains 3378 "unmapped" glyphs, meaning they are not meant to ever be rendered in isolation, only to be used as parts of other, real, glyphs. In terms of glyphs that you should actually be able to "use" for Calibri, there are only 3660 glyphs with outlines, plus three "empty" glyphs (notdef, the nonmarking return, and space)

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.