Tilman Hausherr created PDFBOX-5812:
---------------------------------------

             Summary: IllegalStateException are thrown by surrogate pair 
character 𩸽
                 Key: PDFBOX-5812
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5812
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 3.0.2 PDFBox
            Reporter: Tilman Hausherr
         Attachments: NotoSansJP-Regular.ttf

As reported by Toshiaki Ito in the users mailing list
https://lists.apache.org/thread/y8z4k5vyc0t22d4c2hwzr7kzmo5zv08s
{code}
public static void main(String[] args) throws IOException {

    final String fontPath = "NotoSansJP-Regular.ttf";
    final String out = "output.pdf";

    // Atka Mackerel in Japanese kanji. (surrogate pair)
    final String message = "\uD867\uDE3D";

    try (PDDocument doc = new PDDocument()) {
      PDPage page = new PDPage();
      doc.addPage(page);
      PDFont font = PDType0Font.load(doc, new File(fontPath));

      try (PDPageContentStream contents = new PDPageContentStream(doc, page)) {
        contents.beginText();
        contents.setFont(font, 64);
        contents.newLineAtOffset(100, 700);
        contents.showText(message);
        contents.endText();
      }

      doc.save(out);
      System.out.println(out + " created!");
    }
  }
{code}

{noformat}
**** StackTrace ****
Exception in thread "main" java.lang.IllegalStateException: could not
find the glyphId for the character: ?
    at 
org.apache.pdfbox.pdmodel.PDAbstractContentStream.applyGSUBRules(PDAbstractContentStream.java:1651)
    at 
org.apache.pdfbox.pdmodel.PDAbstractContentStream.encodeForGsub(PDAbstractContentStream.java:1632)
    at 
org.apache.pdfbox.pdmodel.PDAbstractContentStream.showTextInternal(PDAbstractContentStream.java:302)
    at 
org.apache.pdfbox.pdmodel.PDAbstractContentStream.showText(PDAbstractContentStream.java:266)
    at 
org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStream.java:37)
    at org.example.App.main(App.java:30)
{noformat}

It worked with 2.0.31 and I've just confirmed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to