I want to draw a text to a paint. How to draw it with a custom font (ex Helvetica ) and bold also? I would preffer to use a system font and not create it from assets. Thanks.
To change font styles in GO Launcher, copy the TTF or OTF font files on your phone. Long press on the home screen and select GO Settings. Choose Font–>Select Font. Pick the font you want or tap Scan to add files stored on your device.
Fonts are compiled in R file and are automatically available in the system as a resource. You can then access these fonts with the help of the font resource type.
If by "custom font" you mean a font that you are supplying as an asset, the following code should work:
Typeface plain = Typeface.createFromAsset(assetManager, pathToFont); Typeface bold = Typeface.create(plain, Typeface.DEFAULT_BOLD) Paint paint = new Paint(); paint.setTypeface(bold); canvas.drawText("Sample text in bold",0,0,paint);
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