title: iText pdf not displaying Chinese characters when using NOTO fonts or Source Hans
body: <p>I am trying to use NOTO fonts (<a href="https://www.google.com/get/noto/" rel="nofollow noreferrer">https://www.google.com/get/noto/</a>) to display Chinese characters. Here is my sample code,a modified sample code from iText.</p>
  
  <pre><code>public void createPdf(String filename) throws IOException, DocumentException {
  
      Document document = new Document();
      PdfWriter.getInstance(document, new FileOutputStream(filename));
      document.open();
  
      //This is simple English Font
      FontFactory.register("c:/temp/fonts/NotoSerif-Bold.ttf", "my_nato_font");
      Font myBoldFont = FontFactory.getFont("my_nato_font");
      BaseFont bf = myBoldFont.getBaseFont();
      document.add(new Paragraph(bf.getPostscriptFontName(), myBoldFont));
  
  
      //This is Chinese font
  
  
      //Option 1 :
      Font myAdobeTypekit = FontFactory.getFont("SourceHanSansSC-Regular", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
  
      //Option 2 :
       /*FontFactory.register("C:/temp/AdobeFonts/source-han-sans-1.001R/OTF/SimplifiedChinese/SourceHanSansSC-Regular.otf", "my_hans_font");
       Font myAdobeTypekit = FontFactory.getFont("my_hans_font", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);*/
  
  
  
      document.add(Chunk.NEWLINE);
      document.add(new Paragraph("高興", myAdobeTypekit));
      document.add(Chunk.NEWLINE);
  
      //simplified chinese
      document.add(new Paragraph("朝辞白帝彩云间", myAdobeTypekit));
      document.add(Chunk.NEWLINE);
  
      document.add(new Paragraph("高兴", myAdobeTypekit));
      document.add(new Paragraph("The Source Han Sans Traditional Chinese ", myAdobeTypekit));
  
  
      document.close();
  }
  </code></pre>
  
  <p>I have downloaded the fonts files on my machine. I am using two approaches</p>
  
  <ol>
  <li><p>To use the equivalent font family in Adobe</p></li>
  <li><p>Embed the otf file in pdf</p></li>
  </ol>
  
  <p>Using approach 1, I would expect the Chinese characters to be displayed in pdf but English text is displayed and it is blank for Chinese characters.</p>
  
  <p>Using approach 2, when I try embedding the fonts with pdf, which is not the path I would like to take, there is error in opening pdf.
  <img src="https://i.stack.imgur.com/sfRkF.png" alt="enter image description here"></p>
  
  <p>Update :
  If I look at this example <a href="http://itextpdf.com/examples/iia.php?id=214" rel="nofollow noreferrer">http://itextpdf.com/examples/iia.php?id=214</a></p>
  
  <p>and in this code</p>
  
  <pre><code>public void createPdf(String filename, boolean appearances, boolean font)
      throws IOException, DocumentException {
      // step 1
      Document document = new Document();
      // step 2
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
      // step 3
      document.open();
      // step 4
      writer.getAcroForm().setNeedAppearances(appearances);
      TextField text = new TextField(writer, new Rectangle(36, 806, 559, 780), "description");
      text.setOptions(TextField.MULTILINE);
      if (font) {
          BaseFont unicode =
              BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
          text.setExtensionFont(BaseFont.createFont());
          ArrayList&lt;BaseFont&gt; list = new ArrayList&lt;BaseFont&gt;();
          list.add(unicode);
          text.setSubstitutionFonts(list);
          BaseFont f= (BaseFont)text.getSubstitutionFonts().get(0);
          System.out.println(f.getPostscriptFontName());
  
      }
      text.setText(TEXT);
  
      writer.addAnnotation(text.getTextField());
      // step 5
      document.close();
  }
  </code></pre>
  
  <p>I substitute, c:/windows/fonts/arialuni.ttf with C:/temp/fonts/NotoSansCJKtc-Thin.otf , I do not see the Chinese characters. The text to convert now is</p>
  
  <pre><code>public static final String TEXT = "These are the protagonists in 'Hero', a movie by Zhang Yimou:\n"
      + "\u7121\u540d (Nameless), \u6b98\u528d (Broken Sword), "
      + "\u98db\u96ea (Flying Snow), \u5982\u6708 (Moon), "
      + "\u79e6\u738b (the King), and \u9577\u7a7a (Sky).";
  </code></pre>