How do I optimize and embed my font data?

Only some Altia DeepScreen hardware targets have an on-board FreeType font engine. For devices that do not have an on-board font engine, the font characters you use in your .dsn (Altia Design) file must be embedded. Especially when using Unicode fonts with thousands of characters per font, it is important to optimize which characters you embed in order to reduce the size of your GUI's resource files.

This is accomplished with the FONTRANGEFLAG option which is configured in the .gen file for your DeepScreen target. Below is the description of the feature and some example font ranges. You will need 1 range per font, per size. You can have up to 1024 ranges.

This starts by creating a custom .gen file. At code generation time, a .gen file is chosen in the File List: field of the Code Generation Options dialog.  There is a Browse… button to select the .gen file. Press that button. In the file chooser dialog, make a copy of the .gen file that you are currently using and paste it into the same folder (that is, highlight it, do Ctrl+C and then Ctrl+V and you’ll have a new copy of the .gen file in the same folder).  Rename the new .gen file to your liking, but be sure to keep the .gen extension. The .gen file is a regular text file.  Open your new .gen file in Notepad and do a search for the word: FONTRANGEFLAG

There should be a description of how to set %FONTRANGEFLAG% lines. Some DeepScreen products have better descriptions than others.  Here is one of the better descriptions. NOTE: Many .gen files mistakenly say that there is only up to 16 supported font range flags. This is a known issue and is being corrected, but the correct max value is 1024.

# FONTRANGEFLAG Syntax: %FONTRANGEFLAG% fontname [x-y]...
# %FONTRANGEFLAG% lines only work if there is a %FONTIMAGEFLAG% line as well.
# A %FONTRANGEFLAG% line allows for bounding the font range imaging to a
# limited set of characters. This is especially useful when generating code
# for Unicode with a font that has many 1000s of Unicode character glyphs.
# fontname - A font name specification in the Altia X11-like style as in:
# -helvetica-bold-r-normal--180-*
# Or if the font was specified with just a name like CustomFont
# and a point size of 13 using the Altia Design 8.0 or newer
# font chooser name and point size fields, the font name in this
# file would look like:
# -msdpi-CustomFont-medium-r-normal---130------"
# If the font name has spaces, enclose it in double-quotes as in:
# "-msdpi-Arial Unicode MS-bold-r-normal---130------"
# To catch all fonts use "*" for the font name (without the
# double-quotes around it). A %FONTRANGEFLAG% line with "*" as
# the font name must be the last %FONTRANGEFLAG% line or the
# only %FONTRANGEFLAG% line.
# A %FONTRANGEFLAG% line can only have one fontname in it. Use
# another %FONTRANGEFLAG% line to specify a range for another
# font, and so on, with a final %FONTRANGEFLAG% line that has
# a fontname of "*" (to do ranging of all other font names not
# explicitly specified).
# [x-y]... - Specify ranges of characters to include for the font (or fonts
# if the fontname is "*"). x or y can be a literal character
# (like [A-Z]), a decimal value giving the character code value
# for the character ([\112-\127]), or a hex value instead of
# of decimal ([\0x70-\0x7f]). The first item must be greater
# than or equal to the second. The number of ranges supported
# on a single %FONTRANGEFLAG% line is 1024. The code generator
# does not process .gen lines in excess of 17600 characters.
# Assuming 200 characters for the %FONTRANGEFLAG% and the
# fontname and 17 characters per range as the worst case
# (e.g., [\0x1100-\0x1200]), there is room for 1024 font ranges
# on a line. If a %FONTRANGEFLAG% line exceeds 17600 characters,
# only the ranges specified beyond the 17600 are ignored.
# To define a range that is only for a single character, use
# something like: [\0x1000-\0x1000]
# More than one %FONTRANGEFLAG% line is supported where each line must have
# a unique fontname field. If desired, the last %FONTRANGEFLAG% line can
# have "*" (without the double-quotes) as the fontname to generate fonts for
# a range or ranges independent of the font's name. If a line has a fontname
# of "*", it should be the last %FONTRANGEFLAG% line. There cannot be more
# than one %FONTRANGEFLAG% line for the same fontname or more than one line
# with a fontname of "*". In other words, there is one line allowed for
# each unique fontname which means at most 1024 ranges per each fontname.
# If more than one line has the same fontname, only the first occurrence is
# processed and the others are ignored (but do not depend on this behavior).
# Static text Labels automatically add the characters they use independent
# of any specified font ranges. In other words, if they use chars outside
# of a specified range, the chars get processed and added to the generated
# code just as if they were specified in a font range. The font ranges
# are just for minimizing the processed characters for dynamic text
# objects such as Text I/Os or Multi-Line Text objects (MLTOs). Using
# static text Labels to define the characters to be imaged at code
# generation time can work as an alternative to defining many ranges in
# this .gen file. For example, have a card of a Deck somewhere in the
# design (that is easy to get to) containing Labels for all required
# characters for all font names and all font sizes (probably only works
# OK when there is a somewhat limited set of characters, fonts, and sizes).
# Here is an example %FONTRANGEFLAG% line that would limit the imaging
# of characters to the range of space (character value 32) through tilde
# (character value 126). The line is commented out.
# %FONTRANGEFLAG% * [\32-~]

# Below is an example of a %FONTRANGEFLAG% line for Unicode code gen. To
# constrain the size of generated code, it declares 10 specific ranges.
# Change these to suit specific situations. The ranges in this example are:
# 0x20 - 0x17f Basic Latin thru Latin Extended-A
# 0x1100 - 0x11f9 Korean Hangul Jamo
# 0x3040 - 0x312f Japanese Hiragana, Japanese Katakana, Chinese Bopomofo
# 0x4e00 - 0x4eff Small subset of CJK Unified Ideograph section
# 0xffe0 - 0xffee Fullwidth money symbols
# 0x3130 - 0x316f Korean Hangul Compatability Jamo for unicodeAPI.dsn test
# 0x5930 - 0x593f Sm subset of CJK Unified Ideograph for unicodeAPI.dsn test
# 0x7530 - 0x753f Sm subset of CJK Unified Ideograph for unicodeAPI.dsn test
# 0x8c40 - 0x8c4f Sm subset of CJK Unified Ideograph for unicodeAPI.dsn test
# 0x96c0 - 0x96cf Sm subset of CJK Unified Ideograph for unicodeAPI.dsn test
%FONTRANGEFLAG% * [\0x20-\0x17f][\0x1100-\0x11f9][\0x3040-\0x312f][\0x4e00-\0x4eff][\0xffe0-\0xffee][\0x3130-\0x316f][\0x5930-\0x593f][\0x7530-\0x753f][\0x8c40-\0x8c4f][\0x96c0-\0x96cf]

# By default, limit the range to space (character value 32) through
# lower-case y with diaeresis (character value 255).
# IMPORTANT NOTE: Place all custom font ranges before this line.
%FONTRANGEFLAG% * [\32-\255]

Have more questions? Submit a request


Please sign in to leave a comment.