You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2017/03/04 10:11:46 UTC

[jira] [Commented] (PDFBOX-3708) hasGlyph() contradicts encode()

    [ https://issues.apache.org/jira/browse/PDFBOX-3708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15895616#comment-15895616 ] 

Andreas Lehmkühler commented on PDFBOX-3708:
--------------------------------------------

IMHO it is a javadoc issue. The parameter isn't meant to be an unicode character code but a PDF internal charcater code, see PDFStreamEngine#showGlyph

> hasGlyph() contradicts encode()
> -------------------------------
>
>                 Key: PDFBOX-3708
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3708
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.4, 2.1.0
>            Reporter: Tilman Hausherr
>
> {code}
>         PDDocument doc = new PDDocument();
>         PDType0Font font = PDType0Font.load(doc, new FileInputStream("c:/windows/fonts/arial.ttf"));
>         System.out.println(font.hasGlyph('\n'));
>         PDPage page = new PDPage();
>         doc.addPage(page);
>         PDPageContentStream cs = new PDPageContentStream(doc, page);
>         cs.beginText();
>         cs.setFont(font, 100);
>         cs.showText("\n");
> {code}
> The output:
> {code}
> true
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+000A in font ArialMT
> 	at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:402)
> 	at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
> 	at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:316)
> 	at org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStream.java:362)
> {code}
> Either this is a bug in hasGlyph(), or it is a documentation (javadoc) problem, e.g. because the parameter to hasGlyph isn't a character code but something else, then this should be clarified.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

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