Skip to content

Most visited

Recently visited

navigation

Font | Android Developers

to top
Android APIs
public class

Font

extends BaseObj
java.lang.Object
   ↳ android.renderscript.BaseObj
     ↳ android.renderscript.Font

This class was deprecated in API level 16.
in API 16

This class gives users a simple way to draw hardware accelerated text. Internally, the glyphs are rendered using the Freetype library and an internal cache of rendered glyph bitmaps is maintained. Each font object represents a combination of a typeface, and point size. You can create multiple font objects to represent styles such as bold or italic text, faces, and different font sizes. During creation, the Android system quieries device's screen DPI to ensure proper sizing across multiple device configurations.

Fonts are rendered using screen-space positions and no state setup beyond binding a font to the Renderscript is required. A note of caution on performance, though the state changes are transparent to the user, they do happen internally, and it is more efficient to render large batches of text in sequence. It is also more efficient to render multiple characters at once instead of one by one to improve draw call batching.

Font color and transparency are not part of the font object and you can freely modify them in the script to suit the user's rendering needs. Font colors work as a state machine. Every new call to draw text uses the last color set in the script.

Summary

Nested Classes
enum Font.Style This enum was deprecated in API level 16. in API 16  
Public Methods
static Font create(RenderScript rs, Resources res, String familyName, Font.Style fontStyle, float pointSize)
This method was deprecated in API level 16. in API 16 Accepts one of the following family names as an argument and will attempt to produce the best match with a system font: "sans-serif" "arial" "helvetica" "tahoma" "verdana" "serif" "times" "times new roman" "palatino" "georgia" "baskerville" "goudy" "fantasy" "cursive" "ITC Stone Serif" "monospace" "courier" "courier new" "monaco" Returns default font if no match could be found.
static Font createFromAsset(RenderScript rs, Resources res, String path, float pointSize)
This method was deprecated in API level 16. in API 16
static Font createFromFile(RenderScript rs, Resources res, String path, float pointSize)
This method was deprecated in API level 16. in API 16 Takes a specific file name as an argument
static Font createFromFile(RenderScript rs, Resources res, File path, float pointSize)
This method was deprecated in API level 16. in API 16
static Font createFromResource(RenderScript rs, Resources res, int id, float pointSize)
This method was deprecated in API level 16. in API 16
[Expand]
Inherited Methods
From class android.renderscript.BaseObj
From class java.lang.Object

Public Methods

public static Font create (RenderScript rs, Resources res, String familyName, Font.Style fontStyle, float pointSize)

Added in API level 11

This method was deprecated in API level 16.
in API 16 Accepts one of the following family names as an argument and will attempt to produce the best match with a system font: "sans-serif" "arial" "helvetica" "tahoma" "verdana" "serif" "times" "times new roman" "palatino" "georgia" "baskerville" "goudy" "fantasy" "cursive" "ITC Stone Serif" "monospace" "courier" "courier new" "monaco" Returns default font if no match could be found.

public static Font createFromAsset (RenderScript rs, Resources res, String path, float pointSize)

Added in API level 11

This method was deprecated in API level 16.
in API 16

public static Font createFromFile (RenderScript rs, Resources res, String path, float pointSize)

Added in API level 11

This method was deprecated in API level 16.
in API 16 Takes a specific file name as an argument

public static Font createFromFile (RenderScript rs, Resources res, File path, float pointSize)

Added in API level 11

This method was deprecated in API level 16.
in API 16

public static Font createFromResource (RenderScript rs, Resources res, int id, float pointSize)

Added in API level 11

This method was deprecated in API level 16.
in API 16

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.