title: complex text rendering by avoiding the built in canvas.drawText - any way to render text to a bitmap and then display in an imageview instead?
body: <p>I've been struggling with androids limited support for complex text rendering, particularly lack of arabic support for ligatures and shaping.  Although you can get around the shaping problem by using the specific unicode escape codes to display the arabic string, it doesn't handle displaying diacratics correctly since it renders them on top of each other.  </p>
  
  <p>The text renders properly on a graphic using java.awt.Graphics2D but that isn't supported in android, that code is: </p>
  
  <pre><code>InputStream is = converter.class.getResourceAsStream("ARIAL.TTF");
  Font font = Font.createFont(Font.TRUETYPE_FONT, is);
  Font medium_font = font.deriveFont(32f);
  
  
  BufferedImage sizedBufferedImage = new BufferedImage((rounded_width+10),(rounded_height+14), BufferedImage.TYPE_INT_ARGB);
  Graphics2D g_sized = sizedBufferedImage.createGraphics();
  g_sized.setColor(Color.black);
  g_sized.setFont(medium_font);
  g_sized.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  
  g_sized.drawString(word_arabic, 5, 7+max_ascent);
  
  ByteArrayOutputStream imgoutstr = new ByteArrayOutputStream();
  ImageIO.write(sizedBufferedImage, "png", imgoutstr);
  </code></pre>
  
  <p>I can then get the Graphics2D object into a Bitmap using the ImageIO class and finally display it into an ImageView.  I need to do this at runtime because the strings are coming from a database.  </p>
  
  <p>My problem is I can't find any alternative way of writing the word into a graphics object that I can then eventually get into a drawable/bitmap for display in android as an imageview, I'm trying to bypass androids text rendering and use an alternative text renderer that fully supports unicode and can handle the complext text rendering I need.  Putting it into an image allows me to have android display the word verbatim as an image rather than trying to render it.  </p>
  
  <p>Is there any way to draw text into a graphics object instead of androids canvas, eventually putting the rendered graphics object into a bitmap that android can use?  Androids canvas.drawString doesn't render the string properly and renders text differently than Graphics2D for complex text.</p>