I am developing an app where normal text is converted to braille text and later i want the converted text to be printed into a pdf.
Currently i have just converted text by using a custom font for braille
tvTo.setText(edFrom.getText().toString());
Typeface font = Typeface.createFromAsset(getAssets(), "braille_outline.ttf");
tvTo.setTypeface(font);
Now, when i want to print this text i just did
String toPrint = tvTo.getText().toString();
But this results in normal text rather then the converted typeface font.
Any help would be appreciated. Thanks
I don't know anything about generating a PDF. But I don't think a TextView will help you here. Instead, to draw your text directly to a bitmap, you can set a typeface on a Paint:
TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setTypeface(font);
and then draw your text on a Canvas
, if it is short:
canvas.drawText(string, 0, 0, textPaint)
If it's longer and you need the lines to wrap, use a StaticLayout
and draw that to the canvas. http://developer.android.com/reference/android/text/StaticLayout.html