pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: problems with PDType0Font and heights of character
Date Thu, 04 May 2017 16:36:44 GMT
Hi Uwe,

Getting the height is tricky... I suggest you have a look at the 
DrawPrintTextLocations.java example, this shows how to get the exact 
height from the glyph. Look for "(font instanceof PDVectorFont)".

The values for ascent etc are often not very reliable; although this 
time it's us who are generating them :-(

I could have a deeper look at the problem, if you want, create a request 
in JIRA (https://issues.apache.org/jira/browse/PDFBOX) with
- the font
- a generated PDF file
- some numbers about what you were expecting

However it isn't sure that it can be solved.


Am 04.05.2017 um 09:19 schrieb Uwe Möser:
> Hi,
> I use the pdfbox with the embedded font DejaVuSansCondensed.ttf as a
> PDType0Font
> type. I get in trouble when I try to position some text in the document.
> The functions getAscent(),getCapHeight(),getXHeight(),getDescent() provided
> by PDFont.getFontDescriptor() delivers values, I do not expect. Also the
> function PDFont.getHeight(*int* code) returns for any code '1.0'. If I use
> a standard PDType1Font everything is fine.
> Is this a bug or do I use this functions in the right way?
> Thank you very much for your help.
> Uwe
> PDDocument document = new PDDocument();
> PDFont fontTTF = PDType0Font.*load*(document, *new* File("/home/xxxx/temp/
> DejaVuSansCondensed.ttf"));
> System.out.println( fontTTF.getFontDescriptor().getAscent());
> System.out.println( fontTTF.getFontDescriptor().getCapHeight());
> System.out.println( fontTTF.getFontDescriptor().getXHeight());
> System.out.println( fontTTF.getFontDescriptor().getDescent());
> System.out.println( fontTTF.getHeight('X'));
> System.out.println( fontTTF.getHeight('x'));

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

View raw message