title: how to create an emoji image with graphics2d and google noto color font
body: <p>I wrote a java program to render an emoji and create a local image file with it. To do that I downloaded Google's "Noto Color Emoji" font from google website.</p>
  
  <p>This is mi code:</p>
  
  <pre><code>package com.test;
  
  import javax.imageio.ImageIO;
  import java.awt.*;
  import java.awt.font.FontRenderContext;
  import java.awt.geom.Rectangle2D;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  
  public class Test {
  
  public static void main(String[] args) throws IOException {
      String string = "";
      BufferedImage image;
  
      Font font = null;
      try {
          font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("/home/sandra/.fonts/NotoColorEmoji.ttf"));
      } catch (FontFormatException e) {
          e.printStackTrace();
      }
  
      image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
  
      Graphics2D g2 = image.createGraphics();
      g2.setFont(font);
      g2.drawString(string, 0, g2.getFontMetrics().getAscent());
      g2.dispose();
  
      File f = new File("image.png");
      if (!f.exists()) {
          if (!f.createNewFile()) {
              System.err.println("Can't create image file.");
          }
      }
      try {
          ImageIO.write(image, "png", f);
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I tried to run it in both mac and linux (ubuntu) and the output in both cases is a black square.</p>
  
  <p>Am I missing anything obvious? I also tried these commands mentioned at the end of this post (<a href="https://github.com/notwaldorf/ama/issues/53" rel="nofollow noreferrer">https://github.com/notwaldorf/ama/issues/53</a>) but there is no difference on the output image.</p>
  
  <p>I would appreciate any help on this as I'm quite new on emoji display.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Sandra</p>