How can I condense (or expand) glyphs in a text run?

54 views
Skip to first unread message

Support

unread,
Feb 1, 2008, 3:08:13 PM2/1/08
to PDFTron PDFNet SDK
Q: The Truetype font "Lucida Sans Typewriter Regular" is horizontally
stretched in PDFs saved by PDFTron, in comparison to on-screen GDI
output, and Wordpad. How can I condense (or expand) glyphs in a text
run?

----
A: When you embed/create a new PDF font PDFNet will use the default
advance width table available in the font. Different software
applications may choose to also use additional kerning tables or to
control individual character placements.

There are several ways to adjust character widths after creating the
font.

- You can condense characters using
element.GetGState().SetCharSpacing(-0.25); A positive value has the
effect of expanding the distance between glyphs, whereas the negative
values condense glyphs. For more info, please see documentation
SetCharSpacing() method and section 5.2.1 'Character Spacing' in PDF
Reference Manual. Besides character spacing you may also want to
adjust the 'word spacing' and the 'horizontal scale' attribute.

- Using SDF/Cos API you can explicitly modify the 'Widths' array in
the font dictionary or even replace it with a new table.

- You can also individually place each character by creating a
separate text run for each glyph.
Reply all
Reply to author
Forward
0 new messages