We have an App for iOS that renders an enormous amount of text: http://itunes.apple.com/br/app/biblia-sagrada/id370178518?mt=8
We use CoreText to render text and give the user the ability to change formatting, font-size and font face.
We are trying to port it to Android but I'm not sure if there's a substitute for CoreText in Android.
The equivalent to iOS' CoreText in Android is the drawText
APIs, part of the Canvas class, Canvas.drawText()
, Canvas.drawPosText()
, etc. see javadoc for Canvas for more detail. These graphics APIs use Skia underneath.
The functionalities that these graphics APIs provide are not the same as those in iOS, say there's no CTFramesetter
equivalent that helps you layout text and handle line breaks for you. With the drawText
APIs, you can only draw one line at a time, you will have to handle line breaks yourself, It is like using CTTypesetter
in iOS. For laying out text, see Paint.breakText
and Paint.measureText
.
For changing font size & font face, you can set related attributes in the Paint
object, which is passed as the last parameter to the drawText
APIs.
Snippet:
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextSize(14);
String text = "Hello world!";
canvas.drawText(text, 0, 100, paint);
Note: The coordinate system used in the Android drawText
APIs is from left-top
corner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With