Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. String font = "format1.ttf";
  2. Canvas canvas = new Canvas(bmp);
  3.  
  4. //font size
  5. float fontSize = (width/translation.length());
  6.  
  7. Paint paint = new Paint();
  8. paint.setTextSize(fontSize);
  9. paint.setAntiAlias(true);
  10. paint.setSubpixelText(true);
  11. paint.setColor(textColor);
  12.  
  13. paint.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), "fonts/"+font));
  14. paint.setFakeBoldText(true);
  15.  
  16. // draw text to the Canvas center
  17. Rect bounds = new Rect();
  18. paint.getTextBounds(translation, 0, translation.length(), bounds);
  19.  
  20. int x = (bmp.getWidth() - bounds.width())/2;
  21. int y = (bmp.getHeight() + bounds.height())/2;
  22.  
  23. canvas.drawText(translation, x, y, paint);
  24.  
  25. createGLTexture(Texture.loadTextureFromBitmap(bmp), index);
  26.  
  27. bmp.recycle();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement