|
hBasic Manual |
||||||
Fonts
|
||||||
|
Font Families
Font families are built-in fonts on your Android
device. Each family has an additional set of fonts for styles bold, italic, or both.
Families can be specified for the following commands as a string (with optional style extension).
CONSOLE.SET
"FONT <number
|
family>"
DIALOG.SET "TITLE_FONT = <number | family>" CONSOLE|GR|HTML.TITLE title$, fg$,bg$, "<number | family>", align GR.TEXT.SETFONT <number | family$> , style$ , paint % style$ overides any family string style
Styles can be appended to the family name after a dot
(".") e.g
sans-serif.BOLD.
For GR.TEXT.SETFONT, if a style is given both as part
of family name and an argument,
then the argument style$ will override
the style in family$.
Examples
CONSOLE.SET
"FONT
sans-serif"
CONSOLE.SET "FONT sans-serif.BOLD" % use the bold version of family sans-serif GR.TEXT.SETFONT "3.BOLD" % fake bold for loaded font 3 |
||||||
|
Loaded Fonts
Loaded fonts are external fonts loaded with the
FONT.LOAD command (page 95 of legacy manual).
After loading, a font index number is returned. Use the
number to reference the font.
CONSOLE.SET
"FONT number |
family>" DIALOG.SET "TITLE_FONT = <number | family>" CONSOLE|GR|HTML.TITLE title$, fg$,bg$, "<number | family>", align GR.TEXT.SETFONT <number | family$> , style$ , paint Styling
Similar to families, you can also append a style
after a dot;
Examples
CONSOLE.SET
"FONT 3"
% normal
style is default
CONSOLE.SET "FONT 3.BOLD" % use fake bolding for loaded font 3 For GR.TEXT.SETFONT, you may express the font index either as a number or a string. These commands below are all equivalent for setting the font for a paint. GR.TEXT.SETFONT 3, "bold" % name as a number GR.TEXT.SETFONT "3", "bold" % name as a string GR.TEXT.SETFONT "3.bold" % style as part of the anme
Because loaded fonts do not normally carry bold or
italic versions with them, hBasic will attempt to
apply fake bolding or fake italics if a style is requested. For GR.TEXT.SETFONT, you can later change the fake styling with GR.TEXT.BOLD or GR.TEXT.SKEW for the current paint or any given paint. Note that the intermal loaded fonts table is shared between all commands that use it, including graphics commands. An example of loading a font may be found in here. |
||||||
|
Scaled Text
Some commands such as CONSOLE.SET "TEXTSIZE
<size>" default to dip (device independent pixels
or DP) but can also accept scaled pixel sizes (SP).
SP is diffferent to DP, in that furthur scaling is applied according to the android device user preferences (e.g Display settings of device). To honour SP sizes, you must specify with a negative size,
If the user has enlarged the fonts in the device
systems settings, then the font will appear larger than
the equivalent size of 16dp.
To get the perceived scaled pixel density, you can use e.g density_SP returns 320 on a 160 dpi display with a user preference scale of 2X in the device settings. |
||||||