├── .github
└── FUNDING.yml
├── .gitignore
├── .npmignore
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── examples
├── get-font-name.js
├── introduction.js
└── lib-font-in-the-browser.html
├── fonts
├── AthenaRuby_b018.ttf
├── IBMPlexSansThai-Light.ttf
├── MehrNastaliqWeb-Regular.ttf
├── OpenSans
│ ├── Apache License.txt
│ ├── OpenSans-Bold.ttf
│ ├── OpenSans-BoldItalic.ttf
│ ├── OpenSans-ExtraBold.ttf
│ ├── OpenSans-ExtraBoldItalic.ttf
│ ├── OpenSans-Italic.ttf
│ ├── OpenSans-Light.ttf
│ ├── OpenSans-LightItalic.ttf
│ ├── OpenSans-Regular.ttf
│ ├── OpenSans-Semibold.ttf
│ └── OpenSans-SemiboldItalic.ttf
├── README.md
├── Recursive_VF_1.064.ttf
├── SourceCodePro
│ ├── SourceCodePro-Regular.otf
│ ├── SourceCodePro-Regular.otf.woff
│ ├── SourceCodePro-Regular.otf.woff2
│ ├── SourceCodePro-Regular.ttf
│ ├── SourceCodePro-Regular.ttf.woff
│ ├── SourceCodePro-Regular.ttf.woff2
│ ├── SourceCodeVariable-Roman.otf
│ ├── SourceCodeVariable-Roman.otf.woff
│ ├── SourceCodeVariable-Roman.otf.woff2
│ ├── SourceCodeVariable-Roman.ttf
│ ├── SourceCodeVariable-Roman.ttf.woff
│ └── SourceCodeVariable-Roman.ttf.woff2
├── issue-114
│ ├── Flaticon.woff2
│ ├── README.md
│ ├── roboto-regular.woff2
│ └── tawk-font-icon-2.woff2
├── issue-123
│ └── Castoro-Regular.woff2
├── issue-127
│ └── Abelone-FREE.otf
└── issue-130
│ ├── ABeeZee-Regular.ttf
│ ├── AbyssinicaSIL-Regular.ttf
│ ├── AkayaKanadaka-Regular.ttf
│ └── Alice-Regular.ttf
├── index.html
├── lib-font.browser.js
├── lib-font.js
├── lib
├── inflate.js
└── unbrotli.js
├── package.json
├── src
├── eventing.js
├── lazy.js
├── opentype
│ ├── index.js
│ ├── sfnt.js
│ ├── tables
│ │ ├── advanced
│ │ │ ├── BASE.js
│ │ │ ├── GDEF.js
│ │ │ ├── GPOS.js
│ │ │ ├── GSUB.js
│ │ │ ├── JSTF.js
│ │ │ ├── MATH.js
│ │ │ ├── README.md
│ │ │ ├── lookups
│ │ │ │ ├── gpos
│ │ │ │ │ ├── gpos-lookup.js
│ │ │ │ │ ├── lookup-type-1.js
│ │ │ │ │ ├── lookup-type-2.js
│ │ │ │ │ ├── lookup-type-3.js
│ │ │ │ │ ├── lookup-type-4.js
│ │ │ │ │ ├── lookup-type-5.js
│ │ │ │ │ ├── lookup-type-6.js
│ │ │ │ │ ├── lookup-type-7.js
│ │ │ │ │ ├── lookup-type-8.js
│ │ │ │ │ └── lookup-type-9.js
│ │ │ │ └── gsub
│ │ │ │ │ ├── gsub-lookup.js
│ │ │ │ │ ├── lookup-type-1.js
│ │ │ │ │ ├── lookup-type-2.js
│ │ │ │ │ ├── lookup-type-3.js
│ │ │ │ │ ├── lookup-type-4.js
│ │ │ │ │ ├── lookup-type-5.js
│ │ │ │ │ ├── lookup-type-6.js
│ │ │ │ │ ├── lookup-type-7.js
│ │ │ │ │ └── lookup-type-8.js
│ │ │ └── shared
│ │ │ │ ├── class.js
│ │ │ │ ├── coverage.js
│ │ │ │ ├── feature.js
│ │ │ │ ├── itemvariation.js
│ │ │ │ ├── lookup.js
│ │ │ │ ├── script.js
│ │ │ │ └── subtables
│ │ │ │ ├── gpos.js
│ │ │ │ └── gsub.js
│ │ ├── common-layout-table.js
│ │ ├── createTable.js
│ │ ├── simple-table.js
│ │ └── simple
│ │ │ ├── OS2.js
│ │ │ ├── SVG.js
│ │ │ ├── bitmap
│ │ │ ├── CBDT.js
│ │ │ ├── CBLC.js
│ │ │ ├── EBDT.js
│ │ │ ├── EBLC.js
│ │ │ ├── EBSC.js
│ │ │ ├── formats
│ │ │ │ ├── format1.js
│ │ │ │ ├── format17.js
│ │ │ │ ├── format18.js
│ │ │ │ ├── format19.js
│ │ │ │ ├── format2.js
│ │ │ │ ├── format3.js
│ │ │ │ ├── format4.js
│ │ │ │ ├── format5.js
│ │ │ │ ├── format6.js
│ │ │ │ ├── format7.js
│ │ │ │ ├── format8.js
│ │ │ │ └── format9.js
│ │ │ ├── sbix.js
│ │ │ ├── shared.js
│ │ │ └── subtables
│ │ │ │ ├── subtable1.js
│ │ │ │ ├── subtable2.js
│ │ │ │ ├── subtable3.js
│ │ │ │ ├── subtable4.js
│ │ │ │ └── subtable5.js
│ │ │ ├── cff
│ │ │ ├── CFF.js
│ │ │ ├── CFF2.js
│ │ │ └── VORG.js
│ │ │ ├── cmap.js
│ │ │ ├── cmap
│ │ │ ├── README.md
│ │ │ ├── createSubTable.js
│ │ │ ├── format0.js
│ │ │ ├── format10.js
│ │ │ ├── format12.js
│ │ │ ├── format13.js
│ │ │ ├── format14.js
│ │ │ ├── format2.js
│ │ │ ├── format4.js
│ │ │ ├── format6.js
│ │ │ ├── format8.js
│ │ │ └── subtable.js
│ │ │ ├── color
│ │ │ ├── COLR.js
│ │ │ └── CPAL.js
│ │ │ ├── head.js
│ │ │ ├── hhea.js
│ │ │ ├── hmtx.js
│ │ │ ├── maxp.js
│ │ │ ├── name.js
│ │ │ ├── other
│ │ │ ├── DSIG.js
│ │ │ ├── LTSH.js
│ │ │ ├── MERG.js
│ │ │ ├── PCLT.js
│ │ │ ├── VDMX.js
│ │ │ ├── hdmx.js
│ │ │ ├── kern.js
│ │ │ ├── meta.js
│ │ │ ├── vhea.js
│ │ │ └── vmtx.js
│ │ │ ├── post.js
│ │ │ ├── ttf
│ │ │ ├── cvt.js
│ │ │ ├── fpgm.js
│ │ │ ├── gasp.js
│ │ │ ├── glyf.js
│ │ │ ├── loca.js
│ │ │ └── prep.js
│ │ │ └── variation
│ │ │ ├── HVAR.js
│ │ │ ├── MVAR.js
│ │ │ ├── STAT.js
│ │ │ ├── VVAR.js
│ │ │ ├── avar.js
│ │ │ ├── cvar.js
│ │ │ ├── fvar.js
│ │ │ └── gvar.js
│ ├── woff.js
│ └── woff2.js
├── parser.js
└── utils
│ ├── fontface.js
│ ├── shim-fetch.js
│ └── validator.js
└── testing
├── browser
├── matrix
│ ├── index.html
│ └── index.js
├── puppeteer.js
├── server.js
├── test.js
└── tests
│ ├── assert.js
│ ├── test-SFNT.js
│ ├── test.otf.js
│ └── test.ttf.js
├── gsub-recipe.js
├── manual
├── custom
│ ├── brush-grotesk-woff2-gsub.js
│ ├── castoro-parsing.js
│ ├── flaticon-parsing.js
│ ├── issue-127.js
│ ├── issue-130.js
│ ├── issue-85.js
│ └── test.out
├── index.html
└── index.js
└── node
├── athena.ruby.test.js
├── font-profiles
├── athena-ruby.js
├── mehr-nastaliq.js
├── profiles.js
└── source-code-pro.js
├── gsub
└── test-gsub.js
├── issue-114
└── flaticon.test.js
├── mehr.nastaliq.test.js
└── source.code.pro.test.js
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | # github: Pomax
4 | patreon: Bezierinfo
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | protected
3 | node_modules
4 | package-lock.json
5 | test.js
6 | fonts/proprietary
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .vscode
3 | fonts
4 | node_modules
5 | protected
6 | testing
7 | .gitignore
8 | index.html
9 | /index.js
10 | test.js
11 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "DLFT",
4 | "calt",
5 | "ccmp",
6 | "cyrl",
7 | "dflt",
8 | "dlig",
9 | "dnom",
10 | "fina",
11 | "grek",
12 | "isol",
13 | "langsys",
14 | "latn",
15 | "locl",
16 | "medi",
17 | "mset",
18 | "n",
19 | "numr",
20 | "onum",
21 | "rlig",
22 | "sinf"
23 | ]
24 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2020 pomax@nihongoresources.com
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/examples/get-font-name.js:
--------------------------------------------------------------------------------
1 | // This is a Node.js script that loads a font and prints its name.
2 | //
3 | // Run it like this from the command line:
4 | //
5 | // $ node get-font-name.js
6 | //
7 | // It will use the "Recursive" test font in LibFont's ./fonts
8 | // directory, but you can point it to a different font by
9 | // providing the path to the font:
10 | //
11 | // $ node get-font-name.js path/to/font.ttf
12 |
13 | // Import the LibFont library
14 | import { Font } from "../lib-font.js";
15 |
16 | // Create a LibFont object and give it a name
17 | const font = new Font("My Font Name");
18 |
19 | // Set the source font file. We use either the provided font, or
20 | // the Recursive font from the test folder
21 | font.src = process.argv[2] || "../fonts/Recursive_VF_1.064.ttf";
22 |
23 | // Now we're ready to load the font and inspect it!
24 | font.onload = (evt) => {
25 | // Map the details LibFont gathered from the font to the
26 | // "font" variable
27 | const font = evt.detail.font;
28 |
29 | // From all the OpenType tables in the font, take the "name"
30 | // table so we can inspect it further
31 | const { name } = font.opentype.tables;
32 |
33 | // From the name table, take the entry with ID "1". This is
34 | // the Font Family name. More info and names you can grab:
35 | // https://docs.microsoft.com/en-us/typography/opentype/spec/name
36 | const fontname = name.get(1);
37 |
38 | // Tell us the name!
39 | console.log(`This font is called ${fontname}.`);
40 | }
41 |
42 | // If for some reason the font fails to load or parse, throw
43 | // an error
44 | font.onerror = (evt) => {
45 | console.error(evt.msg);
46 | }
47 |
--------------------------------------------------------------------------------
/examples/introduction.js:
--------------------------------------------------------------------------------
1 | // This is the "introduction" example from LibFont's README
2 |
3 | // Import the LibFont library
4 | import { Font } from "../lib-font.js";
5 |
6 | // Create a font object
7 | const myFont = new Font(`Adobe Source Code Pro`);
8 |
9 | // Assign event handling (.addEventListener version supported too, of course)
10 | myFont.onerror = evt => console.error(evt);
11 | myFont.onload = evt => doSomeFontThings(evt);
12 |
13 | // Kick off the font load by setting a source file, exactly as you would
14 | // for an or
7 |
8 |
9 |
10 |
Note: you have to serve this from a 14 | local web server. 15 | It won't work if you open this file from the filesystem.
16 | 17 |Load font:
18 | 19 | 20 | 21 | 61 | 62 |