79 Commits

Author SHA1 Message Date
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
Laszlo Balogh
18927a5d91 Fixed diminishing left-margin 2014-11-21 16:37:30 +00:00
Devon Govett
09ed15b2e4 Fix unicode annotations 2014-08-29 11:49:20 -04:00
Devon Govett
65f40376cd Merge branch 'master' into fontkit
Conflicts:
	lib/font.coffee
2014-08-10 10:56:30 -04:00
Devon Govett
e58a7ce809 Formatting 2014-07-14 20:48:00 -07:00
jkol
64df00fa13 Added "valign" option to image "fit" scaling
valign can be set to "center" or "bottom" now and when "valign" === "center" is combined with "align" === "center" any aspect ratio image can be centered into a bounding area.
2014-07-14 18:23:11 -05:00
Devon Govett
163562c50a Add support for kerning data to the text mixin 2014-07-06 00:15:31 -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
6a2c306680 Don't include newlines in text fragments 2014-07-03 14:58:50 -07:00
Ryan Wersal
c77add8f56 Remove text state handling as it doesn't surive graphic stack saves/restores
Saving and/or restoring the graphics state causes each text object to have to
reinitialize that text state. As a result, the mode/characterSpacing commands
would not get re-added until their value(s) had changed.
2014-05-10 01:11:06 -05:00
Ryan Wersal
aadc589a62 Improve sizing of text underline 2014-05-09 00:05:17 -05:00
Devon Govett
a6f6f4df8a Don't use trimRight since it isn't supported in IE 2014-04-14 09:58:26 -07:00
Devon Govett
4b8b031188 Don't embed fonts until they are actually used 2014-04-12 20:45:15 -07:00
Devon Govett
bb9b77cb82 Allow loading fonts from Buffers in addition to filenames 2014-04-12 20:44:19 -07:00
Devon Govett
665fd935ef Make loading images from buffers way faster by not converting to a string inadvertently 2014-04-06 19:19:17 -07:00
Devon Govett
8eece7e9ea Make sure heightOfString doesn't break pages 2014-03-29 20:36:10 -07:00
Devon Govett
c72b50927c Add heightOfString method that uses the line wrapper without actually adding content to the document.
Very useful for layout purposes
2014-03-29 20:22:21 -07:00
Devon Govett
cf564ac3da Fixes for text justification 2014-03-29 19:56:36 -07:00
Devon Govett
f8a40dba76 Make PDFDocument a node stream 2014-03-23 17:11:48 -07:00
Devon Govett
1305a9592a Switch to 2 space indentation 2014-03-23 12:25:09 -07:00
Devon Govett
350863bfda Fix the ellipse method 2014-02-24 23:25:41 -08:00
Devon Govett
c1319acff8 Allow 0 opacities 2014-02-24 01:09:27 -08:00
Devon Govett
cb81273b49 Trim spaces from the ends of lines when right aligning 2014-02-17 22:02:55 -08:00
Devon Govett
18512661b5 Apply current transformation to annotations 2014-02-17 22:01:49 -08:00
Devon Govett
3f15f761e2 Calculate lineWidth of underline/strike based on font size 2014-02-17 02:34:27 -08:00
Devon Govett
7df3ccdf4d Add link, underline, and strike options to text method. #183
Should make it way easier to do these common things.
2014-02-17 02:21:29 -08:00
Devon Govett
6a323bf0a2 Make sure justified wordSpacing value is always > 0 2014-02-17 02:19:11 -08:00
Devon Govett
9357ff5a4a Extend text options for continued segments 2014-02-17 02:18:40 -08:00
Devon Govett
00c6dabf3c Stop wrapping text after filling specified height, and add ellipsis option. Fixes #149.
No longer makes new pages after user specified heights, but still does so if no height is given (page edge by default). This works with multiple columns too. It will fill the columns in the horizontal and vertical space provided and then stop, rather than going to a new page.

Also adds the `ellipsis` option which can be used to append an ellipsis character like `…` to the end of the cut off text. If you set `ellipsis: true`, it will use the default ellipsis character, but you can also set the option to any string you want to use.
2014-02-16 20:08:19 -08:00
Devon Govett
630bfd74a6 Make sure we don't divide by zero when calculating justification word spacing 2014-02-16 15:54:42 -08:00
Devon Govett
5a74677c66 Store continuedX on the line wrapper instead of the document, since the line wrapper is now reused 2014-02-16 14:48:40 -08:00
Devon Govett
7fafa309b8 Use the same line wrapper instance when text is continued, fixes multicolumns 2014-02-16 14:41:26 -08:00
Devon Govett
b0de8975f9 Fix justification of embedded TTF fonts. Closes #52.
Encodes each word separately instead of relying on Tw operator, which only supports character code 32, which isn't used by embedded fonts.

Still to do: proper unicode word breaking with support for non-space separated languages.
2014-02-16 13:10:18 -08:00
Devon Govett
ebeca3c680 Add continued option to text so that text with inline styles can be created. Closes #60, #180, #189.
The following example adds text with three sections (part1, part2, part3) in different fonts and colors.

doc.font('Helvetica', 13)
   .text(part1, 100, 300, { continued: yes, indent: 50 })
   .fillColor('red')
   .text(part2, { indent: 50, continued: yes })
   .font('Times', 13)
   .fillColor('green')
   .text(part3)
2014-02-16 11:56:31 -08:00
Devon Govett
4b3d2c9e30 Save the fill color and restore it after the line wrapper makes a new page 2014-02-16 11:50:59 -08:00
Devon Govett
df43e0eeb0 Set opacity to 1 if none passed to fillColor and strokeColor 2014-02-16 11:49:09 -08:00
Devon Govett
518d545538 Fix some justification issues 2014-02-16 02:00:29 -08:00
Devon Govett
ef6578a486 Rewrite the line wrapper to use an implementation of the Unicode Line Breaking Algorithm
Should solve a huge number of issues. The regular express based word matching from before was not good. It was overzealous and caused the most bugs of anything in the project. It also didn't work at all for languages like Chinese which don't have spaces between words.

The new wrapping algorithm supports all of this. It is a separate module at http://github.com/devongovett/linebreak.
2014-02-16 02:00:18 -08:00
Devon Govett
8c83de3354 Allow setting dash spacing to 0. Closes #102 2014-02-15 01:01:38 -08:00
Brian Downing
5fc69d96c8 Fix setting text x or y to 0
Because of the use of the construction "@x = x or @x" there was no way
to set x (or y) to 0, since 0 is falsy.  Fix to use separate outer tests
and unconditional assignment.
2013-12-01 21:38:38 -06:00
Devon Govett
27c17cf454 Fix behavior of text wrapping with x/y without width. Use options.lineBreak = false to disable linebreaking 2013-11-09 23:13:50 -08:00
Devon Govett
a7c0a63d76 Merge pull request #167 from Nathanaela/Fix_Eating_Chars
Fixes the eating of prefix characters:
2013-11-09 22:43:58 -08:00
Devon Govett
f95a68c149 Clean up, and release 0.2.3 2013-11-09 22:41:15 -08:00
Devon Govett
5ef0bd8ac3 Merge pull request #78 from wabbit/master
Added image alignment to the image fit option
2013-11-09 22:38:49 -08:00
Nathanael Anderson
e5bbe4dfce Fixes the eating of prefix characters:
;:.-/\?!
2013-10-24 12:43:25 -05:00
Julian Gruber
6775d194a1 make registerFont chainable 2013-06-28 10:51:23 +02:00
Devon Govett
2493e0c34c Add gradient support (both linear and radial). Closes #95. 2013-05-12 20:29:53 -07:00
Devon Govett
587456daad Fix some transform stuff 2013-05-12 20:27:03 -07:00