@react-pdf/fontkit
Advanced tools
Comparing version 1.11.0 to 1.12.0
{ | ||
"name": "@react-pdf/fontkit", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "An advanced font engine for Node and the browser", | ||
@@ -17,2 +17,3 @@ "keywords": [ | ||
"prepublish": "make", | ||
"watch": "rimraf ./dist && rollup -c -w", | ||
"coverage": "BABEL_ENV=cover nyc mocha" | ||
@@ -33,5 +34,3 @@ }, | ||
"@react-pdf/unicode-properties": "^2.2.0", | ||
"brfs": "^1.4.0", | ||
"brotli": "^1.2.0", | ||
"browserify-optional": "^1.0.0", | ||
"clone": "^1.0.1", | ||
@@ -62,4 +61,6 @@ "deep-equal": "^1.0.0", | ||
"nyc": "^10.3.2", | ||
"rimraf": "^2.6.1", | ||
"rollup": "^0.52.2", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-bundle-size": "https://github.com/vimeo/rollup-plugin-bundle-size", | ||
"rollup-plugin-ignore": "^1.0.3", | ||
@@ -66,0 +67,0 @@ "rollup-plugin-json": "^2.1.0", |
102
README.md
@@ -6,2 +6,3 @@ # fontkit | ||
## Fork changes | ||
- Ship parsed tries for browser compatibility | ||
@@ -15,12 +16,12 @@ - Ship node and browser separate builds (ignoring node dependencies) | ||
* Suports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collection (.ttc), and Datafork TrueType (.dfont) font files | ||
* Supports mapping characters to glyphs, including support for ligatures and other advanced substitutions (see below) | ||
* Supports reading glyph metrics and laying out glyphs, including support for kerning and other advanced layout features (see below) | ||
* Advanced OpenType features including glyph substitution (GSUB) and positioning (GPOS) | ||
* Apple Advanced Typography (AAT) glyph substitution features (morx table) | ||
* Support for getting glyph vector paths and converting them to SVG paths, or rendering them to a graphics context | ||
* Supports TrueType (glyf) and PostScript (CFF) outlines | ||
* Support for color glyphs (e.g. emoji), including Apple’s SBIX table, and Microsoft’s COLR table | ||
* Support for AAT variation glyphs, allowing for nearly infinite design control over weight, width, and other axes. | ||
* Font subsetting support - create a new font including only the specified glyphs | ||
- Suports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collection (.ttc), and Datafork TrueType (.dfont) font files | ||
- Supports mapping characters to glyphs, including support for ligatures and other advanced substitutions (see below) | ||
- Supports reading glyph metrics and laying out glyphs, including support for kerning and other advanced layout features (see below) | ||
- Advanced OpenType features including glyph substitution (GSUB) and positioning (GPOS) | ||
- Apple Advanced Typography (AAT) glyph substitution features (morx table) | ||
- Support for getting glyph vector paths and converting them to SVG paths, or rendering them to a graphics context | ||
- Supports TrueType (glyf) and PostScript (CFF) outlines | ||
- Support for color glyphs (e.g. emoji), including Apple’s SBIX table, and Microsoft’s COLR table | ||
- Support for AAT variation glyphs, allowing for nearly infinite design control over weight, width, and other axes. | ||
- Font subsetting support - create a new font including only the specified glyphs | ||
@@ -34,22 +35,21 @@ ## Installation | ||
```javascript | ||
var fontkit = require('fontkit'); | ||
var fontkit = require('fontkit') | ||
// open a font synchronously | ||
var font = fontkit.openSync('font.ttf'); | ||
var font = fontkit.openSync('font.ttf') | ||
// layout a string, using default shaping features. | ||
// returns a GlyphRun, describing glyphs and positions. | ||
var run = font.layout('hello world!'); | ||
var run = font.layout('hello world!') | ||
// get an SVG path for a glyph | ||
var svg = run.glyphs[0].path.toSVG(); | ||
var svg = run.glyphs[0].path.toSVG() | ||
// create a font subset | ||
var subset = font.createSubset(); | ||
var subset = font.createSubset() | ||
run.glyphs.forEach(function(glyph) { | ||
subset.includeGlyph(glyph); | ||
}); | ||
subset.includeGlyph(glyph) | ||
}) | ||
subset.encodeStream() | ||
.pipe(fs.createWriteStream('subset.ttf')); | ||
subset.encodeStream().pipe(fs.createWriteStream('subset.ttf')) | ||
``` | ||
@@ -79,8 +79,8 @@ | ||
* `postscriptName` | ||
* `fullName` | ||
* `familyName` | ||
* `subfamilyName` | ||
* `copyright` | ||
* `version` | ||
- `postscriptName` | ||
- `fullName` | ||
- `familyName` | ||
- `subfamilyName` | ||
- `copyright` | ||
- `version` | ||
@@ -91,18 +91,18 @@ ### Metrics | ||
* `unitsPerEm` - the size of the font’s internal coordinate grid | ||
* `ascent` - the font’s [ascender](http://en.wikipedia.org/wiki/Ascender_(typography)) | ||
* `descent` - the font’s [descender](http://en.wikipedia.org/wiki/Descender) | ||
* `lineGap` - the amount of space that should be included between lines | ||
* `underlinePosition` - the offset from the normal underline position that should be used | ||
* `underlineThickness` - the weight of the underline that should be used | ||
* `italicAngle` - if this is an italic font, the angle the cursor should be drawn at to match the font design | ||
* `capHeight` - the height of capital letters above the baseline. See [here](http://en.wikipedia.org/wiki/Cap_height) for more details. | ||
* `xHeight`- the height of lower case letters. See [here](http://en.wikipedia.org/wiki/X-height) for more details. | ||
* `bbox` - the font’s bounding box, i.e. the box that encloses all glyphs in the font | ||
- `unitsPerEm` - the size of the font’s internal coordinate grid | ||
- `ascent` - the font’s [ascender](<http://en.wikipedia.org/wiki/Ascender_(typography)>) | ||
- `descent` - the font’s [descender](http://en.wikipedia.org/wiki/Descender) | ||
- `lineGap` - the amount of space that should be included between lines | ||
- `underlinePosition` - the offset from the normal underline position that should be used | ||
- `underlineThickness` - the weight of the underline that should be used | ||
- `italicAngle` - if this is an italic font, the angle the cursor should be drawn at to match the font design | ||
- `capHeight` - the height of capital letters above the baseline. See [here](http://en.wikipedia.org/wiki/Cap_height) for more details. | ||
- `xHeight`- the height of lower case letters. See [here](http://en.wikipedia.org/wiki/X-height) for more details. | ||
- `bbox` - the font’s bounding box, i.e. the box that encloses all glyphs in the font | ||
### Other properties | ||
* `numGlyphs` - the number of glyphs in the font | ||
* `characterSet` - an array of all of the unicode code points supported by the font | ||
* `availableFeatures` - an array of all [OpenType feature tags](https://www.microsoft.com/typography/otspec/featuretags.htm) (or mapped AAT tags) supported by the font (see below for a description of this) | ||
- `numGlyphs` - the number of glyphs in the font | ||
- `characterSet` - an array of all of the unicode code points supported by the font | ||
- `availableFeatures` - an array of all [OpenType feature tags](https://www.microsoft.com/typography/otspec/featuretags.htm) (or mapped AAT tags) supported by the font (see below for a description of this) | ||
@@ -121,2 +121,8 @@ ### Character to glyph mapping | ||
#### `font.glyphsForString(string)` | ||
This method returns an array of Glyph objects for the given string. This is only a one-to-one mapping from characters | ||
to glyphs. For most uses, you should use `font.layout` (described below), which provides a much more advanced mapping | ||
supporting AAT and OpenType shaping. | ||
### Glyph metrics and layout | ||
@@ -126,2 +132,6 @@ | ||
#### `font.widthOfGlyph(glyph_id)` | ||
Returns the advance width (described above) for a single glyph id. | ||
#### `font.layout(string, features = [])` | ||
@@ -161,5 +171,5 @@ | ||
#### `font.getGlyph(glyph_id)` | ||
#### `font.getGlyph(glyph_id, codePoints = [])` | ||
Returns a glyph object for the given glyph id. | ||
Returns a glyph object for the given glyph id. You can pass the array of code points this glyph represents for your use later, and it will be stored in the glyph object. | ||
@@ -190,8 +200,8 @@ #### `font.createSubset()` | ||
* `id` - the glyph id in the font | ||
* `codePoints` - an array of unicode code points that are represented by this glyph. There can be multiple code points in the case of ligatures and other glyphs that represent multiple visual characters. | ||
* `path` - a vector Path object representing the glyph | ||
* `bbox` - the glyph’s bounding box, i.e. the rectangle that encloses the glyph outline as tightly as possible. | ||
* `cbox` - the glyph’s control box. This is often the same as the bounding box, but is faster to compute. Because of the way bezier curves are defined, some of the control points can be outside of the bounding box. Where `bbox` takes this into account, `cbox` does not. Thus, `cbox` is less accurate, but faster to compute. See [here](http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-2) for a more detailed description. | ||
* `advanceWidth` - the glyph’s advance width. | ||
- `id` - the glyph id in the font | ||
- `codePoints` - an array of unicode code points that are represented by this glyph. There can be multiple code points in the case of ligatures and other glyphs that represent multiple visual characters. | ||
- `path` - a vector Path object representing the glyph | ||
- `bbox` - the glyph’s bounding box, i.e. the rectangle that encloses the glyph outline as tightly as possible. | ||
- `cbox` - the glyph’s control box. This is often the same as the bounding box, but is faster to compute. Because of the way bezier curves are defined, some of the control points can be outside of the bounding box. Where `bbox` takes this into account, `cbox` does not. Thus, `cbox` is less accurate, but faster to compute. See [here](http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-2) for a more detailed description. | ||
- `advanceWidth` - the glyph’s advance width. | ||
@@ -198,0 +208,0 @@ ### `glyph.render(ctx, size)` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
274
3396370
27
55292
- Removedbrfs@^1.4.0
- Removedbrowserify-optional@^1.0.0
- Removedacorn@7.4.1(transitive)
- Removedbrfs@1.6.1(transitive)
- Removedbuffer-equal@0.0.1(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedconvert-source-map@1.9.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddeep-is@0.1.4(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removedescodegen@1.9.12.1.0(transitive)
- Removedesprima@3.1.34.0.1(transitive)
- Removedestraverse@4.3.05.3.0(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfalafel@2.2.5(transitive)
- Removedfast-levenshtein@2.0.6(transitive)
- Removedhas@1.0.4(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedisarray@1.0.02.0.5(transitive)
- Removedlevn@0.3.0(transitive)
- Removedmagic-string@0.22.5(transitive)
- Removedmerge-source-map@1.0.4(transitive)
- Removedminimist@1.2.8(transitive)
- Removedobject-inspect@1.4.1(transitive)
- Removedoptionator@0.8.3(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedprelude-ls@1.1.2(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedquote-stream@1.0.2(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedshallow-copy@0.0.1(transitive)
- Removedsource-map@0.5.70.6.1(transitive)
- Removedstatic-eval@2.1.1(transitive)
- Removedstatic-module@2.2.5(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedtype-check@0.3.2(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvlq@0.2.3(transitive)
- Removedword-wrap@1.2.5(transitive)
- Removedxtend@4.0.2(transitive)