Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4643

No glyph for U+2032 in font TimesNewRomanPSMT

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: 2.0.16
    • Fix Version/s: None
    • Component/s: PDModel
    • Labels:
      None

      Description

      I have the following Java codes for testing PDFBox (2.0.16) and got exception for the unicode U+2032 (prime), but the font i use is "Time New Roman" which should support the unicode, how to fix the issue? thanks

      import java.io.InputStream;
      import org.apache.pdfbox.pdmodel.PDDocument;
      import org.apache.pdfbox.pdmodel.PDPage;
      import org.apache.pdfbox.pdmodel.common.PDRectangle;
      import org.apache.pdfbox.pdmodel.font.PDFont;
      import org.apache.pdfbox.pdmodel.font.PDType0Font;
      
      public class PDFFonts
      {
          public static void main(String args[])
          {
              try
              {
                  PDDocument document = new PDDocument();
                  PDPage page = new PDPage(PDRectangle.A4);
                  document.addPage(page);
                  InputStream starWarsFontStream = PDFFonts.class.getResourceAsStream("/times-new-roman.ttf");
                  PDFont font = PDType0Font.load(document, starWarsFontStream, false);
                  float num = font.getStringWidth("atal period (pre-na′tal");
                  System.out.println(num);
              }
              catch (Exception e)
              {
                  e.printStackTrace();
              }
          }
      }
      

      Here are exceptions:

      java.lang.IllegalArgumentException: No glyph for U+2032 in font TimesNewRomanPSMT
      at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:404)
      at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:342)
      at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:323)
      at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:352)
      at com.hma.eng.PDFFonts.main(PDFFonts.java:34)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hailima hailima
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: