Anti-alias fonts on android?

Is there a way to render text with custom fonts (although I assume the system font is probably not much different) in a visually pleasing way?

I draw my text on canvas using the paint that I assigned to the custom font.

the only command I found remotely related to anti-aliasing is the “setAntiAlias” paint. but the text still looks awful. almost as bad as the lack of smoothing in general in Photoshop.

so ... is there a way to do this?

and ... since this is for the game, bitmap fonts are a publicly available alternative, but since I want the correct spacing between letters, I will need to program a rather complex bitmap font class to achieve this. because I did not find an existing one. only libgdx seems to contain one. but it is tightly integrated with the library, and much needs to be changed. therefore, if anyone knows about it that does not require it, it will also be very helpful.

from my code as a link, although it is so basic and works fine that I do not think it is relevant:

textPaint = new Paint(); textPaint.setTextSize(size); textPaint.setAntiAlias(true); textPaint.setARGB(0xff, 0xff, 0xff, 0xff); textPaint.setTypeface(Typeface.createFromAsset(pView.getContext().getAssets(), "fonts/cordia.ttf")); ... canvas.drawText(text, (int)(dimension / 2 - textwidth / 2), (int)(dimension / 2 - size / 2), textPaint); 
+4
source share
1 answer

You can create freetype (http://freetype.org/) for Android. It has only zlib dependency, and the resulting fonts are very nice. Most patent issues have been resolved recently (patent expired).

+1
source

All Articles