You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Timo Boehme (JIRA)" <ji...@apache.org> on 2011/03/11 13:01:00 UTC
[jira] Created: (PDFBOX-973) 2 byte codes not supported in
PDType1CFont.getStringWidth
2 byte codes not supported in PDType1CFont.getStringWidth
---------------------------------------------------------
Key: PDFBOX-973
URL: https://issues.apache.org/jira/browse/PDFBOX-973
Project: PDFBox
Issue Type: Bug
Components: PDModel
Affects Versions: 1.6.0
Reporter: Timo Boehme
PDType1CFont overrides the method getStringWidth. The width is calculated by getting the code for each character of the string. However it is assumed that the code only has a maximum value of 255 (1 byte) while - as one can see in e.g. getName() two bytes are possible as well. Therefore the line within getStringWidth which reads
width += getFontWidth(new byte[]{(byte)code.intValue()}, 0, 1);
must be replaced
width += ( code < 256 ) ? getFontWidth( new byte[]{ (byte)code.intValue() }, 0, 1 ) :
getFontWidth( new byte[]{ (byte)(code.intValue() >> 8),
(byte) code.intValue() },
0, 2 );
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira