mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Add kerning support for embedded fonts
This commit is contained in:
parent
163562c50a
commit
67b0d8da19
@ -20,6 +20,7 @@ class EmbeddedFont extends PDFFont
|
||||
encode: (text) ->
|
||||
features = ['ccmp', 'liga', 'dlig', 'kern']
|
||||
glyphs = @font.glyphsForString text, features
|
||||
advances = @font.advancesForGlyphs glyphs, features
|
||||
|
||||
res = []
|
||||
for glyph, i in glyphs
|
||||
@ -28,8 +29,9 @@ class EmbeddedFont extends PDFFont
|
||||
|
||||
@widths[gid] ?= @font.widthOfGlyph glyph.id
|
||||
@unicode[gid] ?= glyph.codePoints
|
||||
advances[i] -= @widths[gid]
|
||||
|
||||
return res.join ''
|
||||
return [res, advances]
|
||||
|
||||
widthOfString: (string, size) ->
|
||||
features = ['ccmp', 'liga', 'dlig', 'kern']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user