48 Commits

Author SHA1 Message Date
Libor M.
cf5a77469f Fix for embedding fonts into PDF (font name must not contain spaces) #1314 2024-12-28 14:05:02 +01:00
Devon Govett
f238d1b107
Bump fontkit and linebreak deps (#1367)
* Bump fontkit and linebreak deps

* Bump fontkit to 2.0.0

* Bump

* Drop old node versions

* Bump testing dependencies

* Update pdfjs

* fix jest to compatibility with restructure, update fontkit, refresh snapshots

* Update CHANGELOG.md

---------

Co-authored-by: Libor M. <liborm85@gmail.com>
2024-12-16 08:36:25 +01:00
Libor M.
75a8dbc0aa Fix CIDSet generation only for PDF/A1 subset #1561 2024-12-14 14:06:24 +01:00
Yeechan Lu
946f9cf6dc
Generate ToUnicodeMap bfrange in multiple ranges (#1498) (#1499)
* Generate ToUnicodeMap bfrange in multiple ranges (#1498)

This resolves #1498.

* Add unit test for bfrange lines in toUnicodeMap

* Add changelog line
2024-02-26 10:18:47 -03:00
Andrei Augustin
3904188903
Initial support for PDF/A-1a/b (#1395)
* pdf/a1b support initial commit

Added mixin for support pdf/a1b and a few of the things it requires (xmp metadata, colour profile). Currently, the CIDSet stream is the only error it comes back with the test case I'm using, will try sorting it out next.

* Adding CIDSet when generating PDF/A

PDF/A1 b/a requires a CIDSet. This is not checked by a validator and other converters seem to add a CIDSet with a value of FF FF FF FF 0C, so this commit does the same. When extending support for PDF/A 2/3/4, we may not add a CIDSet (I think for PDF/A3 it's not required?) or we will look for a proper way to generate the CIDSet.

At this point, PDFKit should be able to generate PDF/A1b which can pass veraPDF validation and PDF/A1a if tagged is enabled.

All you have to do is set pdfa: '1a' or pdfa: '1b' in the options passed to new PDFDocument.

* pdf/a intro docs

* generalising subsets, reimplementing pdfa1 and added control over metadata

added a generalised subsets mixin which can pull in a subset at runtime.
reimplemented pdfa1 mixin as some features should be standardised across all subsets, such as storing /Info as xmp metadata for pdf >1.3
added a metadata class and mixing to control and write the metadata to a pdf

* added tests for pdfa1 and metadata and moved joinTokens in helpers

Addeds tests for pdfa1 subset and metadata.
Moved joinTokens into helpers.js as it's now used in at least two places.
Added tests for document to when metadata should be added (pdf version 1.4 or newer) and when it shouldn't (pdf version 1.3)

* updated pdf/a docs to reflect latest changes

* store color profile as icc file

* Updated changelog to include PDF/A support in Unreleased section
2023-01-06 19:25:11 -03:00
Jakub Valenta
63972499c0 lib/font/embedded: Don't put '@' in font tag
Otherwise Adobe Illustrator says "This document uses fonts that are
currently not available on your computer".
2021-03-24 15:25:51 -03:00
Pádraig Galvin
068e9afe05 Explicitly define default value for CIDToGIDMap 2019-09-04 15:04:27 +02:00
Luiz Américo
1e62e6ffe2 Cleanup remaining artifacts from CoffeScript conversion 2019-03-03 19:58:05 -03:00
Luiz Américo
dae45a44ae Rename fontCache to fontLayoutCache 2019-03-03 19:50:14 -03:00
Luiz Américo
b3a943bd9d Add fontCache option 2019-03-03 15:17:08 -03:00
Luiz Américo
a6af76467c Add prettier npm script and run it in *.js files 2019-01-07 20:51:06 -03:00
Luiz Américo
883983aa3d Import test dependencies directly from src through babel-jest. Adapt relative paths accordingly 2018-12-20 13:33:05 -03:00
Luiz Américo
83f5f72431 Convert to EcmaScript (ES6+) (#859) 2018-11-29 08:14:45 -08:00
alafr
34cf8d5fa6
Text baseline & oblique option (#585) 2018-02-02 18:39:57 +01:00
Devon Govett
6e9e58f5d2 Implement word cache around fontkit
Caches the results of fontkit layout calls, which can be expensive depending on the opentype features in the font. Splits up text by words and shapes each individually to increase cache efficiency.
2017-05-29 15:19:55 -07:00
Devon Govett
154801ece7 fontkit removed widthOfString method 2016-08-26 11:31:12 -04:00
Devon Govett
fb0b38934f Match fontkit output for standard fonts 2015-07-26 12:30:14 -07:00
Devon Govett
926ed20285 Fix afm glyph width when not defined 2015-07-26 12:29:52 -07:00
Devon Govett
ed542e5192 Update for latest fontkit 2015-07-26 12:29:32 -07:00
Devon Govett
0cca20a6a4 Fix misspelling 2015-07-26 12:29:19 -07:00
Devon Govett
6b2bea9835 Merge branch 'master' of github.com:devongovett/pdfkit into fontkit
Conflicts:
	lib/font/table.coffee
	lib/font/tables/cmap.coffee
	lib/font/tables/glyf.coffee
	lib/font/tables/head.coffee
	lib/font/tables/hhea.coffee
	lib/font/tables/hmtx.coffee
	lib/font/tables/loca.coffee
	lib/font/tables/maxp.coffee
	lib/font/tables/name.coffee
	lib/font/tables/os2.coffee
	lib/font/tables/post.coffee
2014-11-27 20:51:58 -08:00
Devon Govett
7bab1db1a5 Support passing opentype features to text methods 2014-11-27 20:48:44 -08:00
Devon Govett
f7cc793693 Update fontkit API calls 2014-11-27 20:44:25 -08:00
Devon Govett
38e5b73e58 Move TTF table tags to prototype 2014-09-15 11:35:42 -04:00
yelouafi
9f4c6345c5 Moved @tag definition to the derived Table constructors 2014-09-13 17:30:42 +00:00
yelouafi
c7c20ef6b7 removed @constructor.name line, corrected @tag params 2014-09-12 21:47:46 +00:00
yelouafi
7f8714a40f TTFFont.parse should call *Table constructors with explicit @tag param 2014-09-12 18:34:44 +00:00
Edward Faulkner
3acfa5833d prevent missing ascender from breaking layout 2014-09-11 19:31:21 -04:00
Mihai Bazon
e61366b37f Fix reading cmap table
The data offset must be saved before parsing one entry and restored
thereafter.  Otherwise only the first table is parsed properly, and garbage
is returned for the rest.  Fails on i.e. georgiai.ttf.

When reading the glyphIds, divide count by 2 (we read 16-bit words).
2014-08-16 11:50:52 +03:00
Devon Govett
0d882e0ef0 Remove old font parsing library 2014-07-19 12:51:38 -07:00
Devon Govett
f76f25bbd8 Remove unneeded import 2014-07-19 12:43:20 -07:00
Devon Govett
8e10736ad6 Add kerning support for standard PDF fonts by parsing data in AFM files 2014-07-06 00:16:23 -07:00
Devon Govett
67b0d8da19 Add kerning support for embedded fonts 2014-07-06 00:15:59 -07:00
Devon Govett
0c5f818e23 Split PDFFont class into separate subclasses for embedded and standard fonts 2014-07-06 00:03:12 -07:00
Devon Govett
4ce53698c0 Replace font engine with new fontkit module 2014-07-03 18:57:36 -07:00
Devon Govett
bb9b77cb82 Allow loading fonts from Buffers in addition to filenames 2014-04-12 20:44:19 -07:00
Devon Govett
801981728c Make AFMFont.open different from constructor 2014-04-12 20:35:14 -07:00
Devon Govett
8c51ee077f Make sure that sfnt key exists in dfont so we don't throw random errors 2014-04-09 23:44:31 -07:00
Devon Govett
87fd69b7e5 Don't overwrite cmap method 2014-04-09 23:41:06 -07:00
Devon Govett
1305a9592a Switch to 2 space indentation 2014-03-23 12:25:09 -07:00
Devon Govett
25c0348755 Fix character width calculations (#185, #169)
Follows TTF hmtx rules for missing entries, and encodes WinAnsi first for builtin fonts.
2014-02-16 19:46:35 -08:00
Devon Govett
5b1f030329 Move WinAnsi encoding to AFMFont class 2014-02-16 19:43:25 -08:00
Devon Govett
cbaff9962d Work around silly CoffeeScript bug. Fixes #70. 2012-04-20 11:29:12 -07:00
Devon Govett
bfd4ab3e55 Fix weird DFont parsing issues. Should fix usage of Mac OS X system fonts. Closes #34. 2012-04-04 00:08:18 -07:00
Devon Govett
78c578972d Fix path 2011-07-26 22:02:11 -04:00
Devon Govett
a6ca7c7896 Unicode font support! 2011-07-20 01:54:15 -04:00
Devon Govett
9d90e25664 Font subsetting support. Only includes characters in embedded fonts that are actually used in the document. Please report bugs if you find them! 2011-07-17 01:13:44 -04:00
Devon Govett
9215fc1b02 Initial commit 2011-07-09 22:57:00 -04:00