Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String font = "format1.ttf";
- Canvas canvas = new Canvas(bmp);
- //font size
- float fontSize = (width/translation.length());
- Paint paint = new Paint();
- paint.setTextSize(fontSize);
- paint.setAntiAlias(true);
- paint.setSubpixelText(true);
- paint.setColor(textColor);
- paint.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), "fonts/"+font));
- paint.setFakeBoldText(true);
- // draw text to the Canvas center
- Rect bounds = new Rect();
- paint.getTextBounds(translation, 0, translation.length(), bounds);
- int x = (bmp.getWidth() - bounds.width())/2;
- int y = (bmp.getHeight() + bounds.height())/2;
- canvas.drawText(translation, x, y, paint);
- createGLTexture(Texture.loadTextureFromBitmap(bmp), index);
- bmp.recycle();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement