pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: Character widths
Date Mon, 01 Aug 2016 21:51:01 GMT

> On 1 Aug 2016, at 14:12, Aaron Mulder <ammulder@gmail.com> wrote:
> 
> On Mon, Aug 1, 2016 at 2:23 PM, John Hewson <john@jahewson.com> wrote:
>> That’s correct. getStringWidth is for use when creating new PDFs only, and we don’t
>> implement kerning, so the width you get will be “correct” with respect to the
text
>> in the newly created PDF.
> 
> So, I guess I don't understand this part.
> 
> My impression was that if you wrote something like "/Helvetica 12 Tf
> (AVAVAV) Tj" to the PDF document, a reader displaying the document
> would use the standard-14 Helvetica font to draw the string "AVAVAV"
> to the screen, and because that font implements kerning for those
> character combinations, the reader would display the text as more
> compressed horizontally than in the absence of kerning.

No, PDF is rather unusual in this respect. Any kerns have to be specified
manually in the Tj array. The idea being that the PDF renderer is a “dumb”
client:

e.g. "AWAY again” with A-W-A kerned:

[ (A) 120 (W) 120 (A) 95 (Y again) ] TJ

See p251 of ISO 32000 for more details.

— John

> So my expectation is that if you did the commands above and then drew
> a box around it using the horizontal dimension provided by
> getStringWidth("AVAVAV"), your box would display as slightly larger
> than the visible text width due to the absence of kerning in
> calculating the box size based on the text width at the time you wrote
> the document, but the presence of kerning in rendering the text in the
> reader.
> 
> Where am I going wrong there?
> 
> Thanks,
>       Aaron
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message