Font
Summary
Enumerations |
|
---|---|
Anonymous Enum 26{
|
enum |
Anonymous Enum 27{
|
enum |
Typedefs |
|
---|---|
AFont
|
typedefstruct AFont
AFont provides information of the single font configuration. |
AFontMatcher
|
typedefstruct AFontMatcher
AFontMatcher performs match operation on given parameters and available font files. |
ASystemFontIterator
|
typedefstruct ASystemFontIterator
ASystemFontIterator provides access to the system font configuration. |
Functions |
|
---|---|
AFontMatcher_create()
|
AFontMatcher *_Nonnull
Select the best font from given parameters.
|
AFontMatcher_destroy(AFontMatcher *_Nonnull matcher)
|
void
Destroy the matcher object.
|
AFontMatcher_match(const AFontMatcher *_Nonnull matcher, const char *_Nonnull familyName, const uint16_t *_Nonnull text, const uint32_t textLength, uint32_t *_Nullable runLengthOut)
|
AFont *_Nonnull
Performs the matching from the generic font family for the text and select one font.
|
AFontMatcher_setFamilyVariant(AFontMatcher *_Nonnull matcher, uint32_t familyVariant)
|
void
Set family variant to matcher.
|
AFontMatcher_setLocales(AFontMatcher *_Nonnull matcher, const char *_Nonnull languageTags)
|
void
Set font locales to matcher.
|
AFontMatcher_setStyle(AFontMatcher *_Nonnull matcher, uint16_t weight, bool italic)
|
void
Set font style to matcher.
|
AFont_close(AFont *_Nullable font)
|
void
Close an AFont.
|
AFont_getAxisCount(const AFont *_Nonnull font)
|
size_t
Return a count of font variation settings associated with the current font.
|
AFont_getAxisTag(const AFont *_Nonnull font, uint32_t axisIndex)
|
uint32_t
Return an OpenType axis tag associated with the current font.
|
AFont_getAxisValue(const AFont *_Nonnull font, uint32_t axisIndex)
|
float
Return an OpenType axis value associated with the current font.
|
AFont_getCollectionIndex(const AFont *_Nonnull font)
|
size_t
Return a font collection index value associated with the current font.
|
AFont_getFontFilePath(const AFont *_Nonnull font)
|
const char *_Nonnull
Return an absolute path to the current font file.
|
AFont_getLocale(const AFont *_Nonnull font)
|
const char *_Nullable
Return a IETF BCP47 compliant language tag associated with the current font.
|
AFont_getWeight(const AFont *_Nonnull font)
|
uint16_t
Return a weight value associated with the current font.
|
AFont_isItalic(const AFont *_Nonnull font)
|
bool
Return true if the current font is italic, otherwise returns false.
|
ASystemFontIterator_close(ASystemFontIterator *_Nullable iterator)
|
void
Close an opened system font iterator, freeing any related resources.
|
ASystemFontIterator_next(ASystemFontIterator *_Nonnull iterator)
|
AFont *_Nullable
Move to the next system font.
|
ASystemFontIterator_open()
|
ASystemFontIterator *_Nullable
Create a system font iterator.
|
Enumerations
Anonymous Enum 26
Declared inandroid/font.h
Anonymous Enum 26
Anonymous Enum 27
Declared inandroid/font_matcher.h
Anonymous Enum 27
Typedefs
AFont
Declared inandroid/font.h
struct AFont AFont
AFont provides information of the single font configuration.
AFontMatcher
Declared inandroid/font_matcher.h
struct AFontMatcher AFontMatcher
AFontMatcher performs match operation on given parameters and available font files.
This matcher is not a thread-safe object. Do not pass this matcher to other threads.
ASystemFontIterator
Declared inandroid/system_fonts.h
struct ASystemFontIterator ASystemFontIterator
ASystemFontIterator provides access to the system font configuration.
ASystemFontIterator is an iterator for all available system font settings. This iterator is not a thread-safe object. Do not pass this iterator to other threads.
Functions
AFontMatcher_create
Declared inandroid/font_matcher.h
AFontMatcher *_Nonnull AFontMatcher_create()
Select the best font from given parameters.
Creates a new AFontMatcher object.
Available since API level 29.
AFontMatcher_destroy
Declared inandroid/font_matcher.h
void AFontMatcher_destroy( AFontMatcher *_Nonnull matcher )
Destroy the matcher object.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
AFontMatcher_match
Declared inandroid/font_matcher.h
AFont *_Nonnull AFontMatcher_match( const AFontMatcher *_Nonnull matcher, const char *_Nonnull familyName, const uint16_t *_Nonnull text, const uint32_t textLength, uint32_t *_Nullable runLengthOut )
Performs the matching from the generic font family for the text and select one font.
For more information about generic font families, read W3C spec
Even if no font can render the given text, this function will return a non-null result for drawing Tofu character.
Available since API level 29.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Returns |
a font to be used for given text and params. You need to release the returned font by AFont_close when it is no longer needed.
|
AFontMatcher_setFamilyVariant
Declared inandroid/font_matcher.h
void AFontMatcher_setFamilyVariant( AFontMatcher *_Nonnull matcher, uint32_t familyVariant )
Set family variant to matcher.
If this function is not called, the matcher performs with AFAMILY_VARIANT_DEFAULT.
Available since API level 29.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
AFontMatcher_setLocales
Declared inandroid/font_matcher.h
void AFontMatcher_setLocales( AFontMatcher *_Nonnull matcher, const char *_Nonnull languageTags )
Set font locales to matcher.
If this function is not called, the matcher performs with empty locale list.
Available since API level 29.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
AFontMatcher_setStyle
Declared inandroid/font_matcher.h
void AFontMatcher_setStyle( AFontMatcher *_Nonnull matcher, uint16_t weight, bool italic )
Set font style to matcher.
If this function is not called, the matcher performs with AFONT_WEIGHT_NORMAL with non-italic style.
Available since API level 29.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
AFont_close
Declared inandroid/font.h
void AFont_close( AFont *_Nullable font )
Close an AFont.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
AFont_getAxisCount
Declared inandroid/font.h
size_t AFont_getAxisCount( const AFont *_Nonnull font )
Return a count of font variation settings associated with the current font.
The font variation settings are provided as multiple tag-values pairs.
For example, bold italic font may have following font variation settings: 'wght' 700, 'slnt' -12 In this case, AFont_getAxisCount returns 2 and AFont_getAxisTag and AFont_getAxisValue will return following values.
AFont* font = ASystemFontIterator_next(ite); // Returns the number of axes AFont_getAxisCount(font); // Returns 2 // Returns the tag-value pair for the first axis. AFont_getAxisTag(font, 0); // Returns 'wght'(0x77676874) AFont_getAxisValue(font, 0); // Returns 700.0 // Returns the tag-value pair for the second axis. AFont_getAxisTag(font, 1); // Returns 'slnt'(0x736c6e74) AFont_getAxisValue(font, 1); // Returns -12.0
For more information about font variation settings, read Font Variations Table
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
a number of font variation settings.
|
AFont_getAxisTag
Declared inandroid/font.h
uint32_t AFont_getAxisTag( const AFont *_Nonnull font, uint32_t axisIndex )
Return an OpenType axis tag associated with the current font.
See AFont_getAxisCount for more details.
Available since API level 29.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
an OpenType axis tag value for the given font variation setting.
|
AFont_getAxisValue
Declared inandroid/font.h
float AFont_getAxisValue( const AFont *_Nonnull font, uint32_t axisIndex )
Return an OpenType axis value associated with the current font.
See AFont_getAxisCount for more details.
Available since API level 29.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
a float value for the given font variation setting.
|
AFont_getCollectionIndex
Declared inandroid/font.h
size_t AFont_getCollectionIndex( const AFont *_Nonnull font )
Return a font collection index value associated with the current font.
In case the target font file is a font collection (e.g. .ttc or .otc), this returns a non-negative value as an font offset in the collection. This always returns 0 if the target font file is a regular font.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
a font collection index.
|
AFont_getFontFilePath
Declared inandroid/font.h
const char *_Nonnull AFont_getFontFilePath( const AFont *_Nonnull font )
Return an absolute path to the current font file.
Here is a list of font formats returned by this method:
- OpenType
- OpenType Font Collection
- TrueType
- TrueType Collection
The font file returned is guaranteed to be opend with O_RDONLY. Note that the returned pointer is valid until AFont_close() is called for the given font.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
a string of the font file path.
|
AFont_getLocale
Declared inandroid/font.h
const char *_Nullable AFont_getLocale( const AFont *_Nonnull font )
Return a IETF BCP47 compliant language tag associated with the current font.
For information about IETF BCP47, read Locale.forLanguageTag(java.lang.String)
Note that the returned pointer is valid until AFont_close() is called.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
a IETF BCP47 compliant language tag or nullptr if not available.
|
AFont_getWeight
Declared inandroid/font.h
uint16_t AFont_getWeight( const AFont *_Nonnull font )
Return a weight value associated with the current font.
The weight values are positive and less than or equal to 1000. Here are pairs of the common names and their values.
Value | Name | NDK Definition |
100 | Thin | AFONT_WEIGHT_THIN |
200 | Extra Light (Ultra Light) | AFONT_WEIGHT_EXTRA_LIGHT |
300 | Light | AFONT_WEIGHT_LIGHT |
400 | Normal (Regular) | AFONT_WEIGHT_NORMAL |
500 | Medium | AFONT_WEIGHT_MEDIUM |
600 | Semi Bold (Demi Bold) | AFONT_WEIGHT_SEMI_BOLD |
700 | Bold | AFONT_WEIGHT_BOLD |
800 | Extra Bold (Ultra Bold) | AFONT_WEIGHT_EXTRA_BOLD |
900 | Black (Heavy) | AFONT_WEIGHT_BLACK |
Note that the weight value may fall in between above values, e.g. 250 weight.
For more information about font weight, read OpenType usWeightClass
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
a positive integer less than or equal to AFONT_WEIGHT_MAX is returned.
|
AFont_isItalic
Declared inandroid/font.h
bool AFont_isItalic( const AFont *_Nonnull font )
Return true if the current font is italic, otherwise returns false.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
true if italic, otherwise false.
|
ASystemFontIterator_close
Declared inandroid/system_fonts.h
void ASystemFontIterator_close( ASystemFontIterator *_Nullable iterator )
Close an opened system font iterator, freeing any related resources.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
ASystemFontIterator_next
Declared inandroid/system_fonts.h
AFont *_Nullable ASystemFontIterator_next( ASystemFontIterator *_Nonnull iterator )
Move to the next system font.
Available since API level 29.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
a font. If no more font is available, returns nullptr. You need to release the returned font with AFont_close() when it is no longer needed.
|
ASystemFontIterator_open
Declared inandroid/system_fonts.h
ASystemFontIterator *_Nullable ASystemFontIterator_open()
Create a system font iterator.
Use ASystemFontIterator_close() to close the iterator.
Available since API level 29.
Details | |
---|---|
Returns |
a pointer for a newly allocated iterator, nullptr on failure.
|