public class FontTable extends BaseSysTable
FontTableResource
interface). In addition, this implements:
SYSTEM-DIALOG FONT
statement, via the FontTable.FontChooserDialog
PUT-KEY-VALUE FONT ALL
statement, via the saveFontTable()
API
PUT-KEY-VALUE FONT font-num
statement, via the saveFont(long)
API
Currently the legacy fonts mentioned in directory file has default replacements that can be loaded from jar file as resources. Here is the table currently used as replacement rule map.
Legacy proprietary font | Free replacement |
---|---|
Tahoma | Wine Tahoma |
Courier New | Liberation Mono |
Segoe UI | Open Sans |
Microsoft Sans Serif | Liberation Sans |
MS Sans Serif | Lato |
Fixed Sys Excelsior | DejaVu Sans |
Modifier and Type | Class and Description |
---|---|
static class |
FontTable.FontChooserDialog
Builder class that takes care of all options of the
SYSTEM-DIALOG FONT statement. |
private static class |
FontTable.LegacyFont
Structure with dDetails about a given font.
|
private static class |
FontTable.LegacyFontMetrics
Structure containing the legacy metrics, for a certain font.
|
private static class |
FontTable.LegacyTextMetrics
Structure containing the legacy text metrics, for a certain text.
|
private static class |
FontTable.WorkArea
Container for context-local data.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALERT_BOX_FONT
The name of the node containing the alert box font - system font.
|
static java.lang.String |
CUSTOM_FONTS
The name of the node containing the custom fonts (i.e.
|
private static java.util.Map<java.lang.String,byte[]> |
customFonts
A map containing the custom fonts.
|
static java.lang.String |
DEFAULT_FIXED_FONT
The name of the node containing the default fixed font.
|
static java.lang.String |
DEFAULT_FONT
The name of the node containing the default font.
|
private static java.util.Map<java.lang.String,java.lang.String> |
defaultCustomFonts
A map to store predefined custom fonts distributed with package jar
|
private static java.lang.String |
FALLBACK_DEFAULT_FONT
The fallback font, in case the default fonts are not specified.
|
private static java.util.Set<java.lang.String> |
fixedFonts
A set containing the name of the fixed fonts.
|
static java.lang.String |
FONT_ALIASES
The name of the node containing the font aliases.
|
static java.lang.String |
FONT_TABLE
The name of the node containing the font-table.
|
private static java.util.Map<java.lang.String,java.lang.Integer> |
implicitSizes
A map containing the implicit sizes of all fonts.
|
private static java.util.Map<java.lang.String,FontTable.LegacyFontMetrics> |
legacyFontMetrics
A map containing the legacy font metrics.
|
private static java.util.Map<java.lang.String,FontTable.LegacyTextMetrics> |
legacyTextMetrics
A map containing the legacy text metrics.
|
private static ContextLocal<FontTable.WorkArea> |
local
Context local instance of this class.
|
private static java.util.logging.Logger |
LOG
logger
|
static java.lang.String |
MENU_FONT
The name of the node containing the menu font - system font.
|
static java.lang.String |
SORT_NUMBER_FONT
The name of the node containing the font for sort numbers in browse column headers.
|
static java.lang.String |
STACK_TRACE_WINDOW_FONT
The name of the node containing the stack trace window font - system font.
|
static java.lang.String |
SYSTEM_FONT_TABLE
The name of the node containing the system font-table.
|
static java.lang.String |
WINDOW_TITLE_FONT
The name of the node containing the window title font - system font.
|
Constructor and Description |
---|
FontTable() |
Modifier and Type | Method and Description |
---|---|
static handle |
asHandle()
Get a the instance for the FONT-TABLE system handle.
|
private static FontDetails<?> |
buildFontSpecification(java.lang.String fontID,
java.lang.String font)
Build font specifications for the specified font
|
private static FontDetails<?>[] |
buildFontSpecifications(java.lang.String[] fontIDs,
java.lang.String[] fontTable)
Build font specifications for all fonts in the given array.
|
static FontTable.FontChooserDialog |
createFontChooserDialog(int64 fontRef)
Factory method for creating a font chooser dialog.
|
static FontTable.FontChooserDialog |
createFontChooserDialog(long fontRef)
Factory method for creating a font chooser dialog.
|
private static java.lang.String |
generateSystemID()
Generate a system ID to allow us to find the DTD.
|
private static byte[] |
getCustomFontData(java.lang.String fntName,
java.lang.String fntPath)
Load the font data from given location.
|
(package private) static byte[] |
getCustomFontDefinition(java.lang.String name,
boolean bold)
Get the custom definition of this font.
|
(package private) static int |
getImplicitFontSize(java.lang.String name)
Get the font's implicit size, from the
implicitSizes map. |
(package private) static int[] |
getLegacyFontMetrics(java.lang.String key)
Get the legacy metrics for the given font, using the font specified by the given key.
|
(package private) static int[] |
getLegacyTextMetrics(java.lang.String text,
java.lang.String key)
Get the legacy metrics for the given text, using the font specified by the given key.
|
static integer |
getNumEntries()
Get the number of entries in the font-table.
|
static character |
getResourceType()
Get the type of its associated handle.
|
static decimal |
getTextHeightChars()
Get the height in characters unit, of the default font.
|
static decimal |
getTextHeightChars(int64 fontNum)
Get the height in characters unit, of the specified font.
|
static decimal |
getTextHeightChars(long fontNum)
Get the height in characters unit, of the specified font.
|
static integer |
getTextHeightPixels()
Get the height in pixels, of the default font.
|
static integer |
getTextHeightPixels(int64 fontNum)
Get the height in pixels, of the specified font.
|
static integer |
getTextHeightPixels(long fontNum)
Get the height in pixels, of the specified font.
|
static decimal |
getTextWidthChars(character txt)
Get the width of the specified text, in character units, using the default font.
|
static decimal |
getTextWidthChars(character txt,
int64 fontNum)
Get the width of the specified text, in character units, using the specified font.
|
static decimal |
getTextWidthChars(character txt,
long fontNum)
Get the width of the specified text, in character units, using the specified font.
|
static decimal |
getTextWidthChars(java.lang.String txt)
Get the width of the specified text, in character units, using the default font.
|
static decimal |
getTextWidthChars(java.lang.String txt,
int64 fontNum)
Get the width of the specified text, in character units, using the specified font.
|
static decimal |
getTextWidthChars(java.lang.String txt,
long fontNum)
Get the width of the specified text, in character units, using the specified font.
|
static integer |
getTextWidthPixels(character txt)
Get the width of the specified text, in pixels, using the default font.
|
static integer |
getTextWidthPixels(character txt,
int64 fontNum)
Get the width of the specified text, in pixels, using the specified font.
|
static integer |
getTextWidthPixels(character txt,
long fontNum)
Get the width of the specified text, in pixels, using the specified font.
|
static integer |
getTextWidthPixels(java.lang.String txt)
Get the width of the specified text, in pixels, using the default font.
|
static integer |
getTextWidthPixels(java.lang.String txt,
int64 fontNum)
Get the width of the specified text, in pixels, using the specified font.
|
static integer |
getTextWidthPixels(java.lang.String txt,
long fontNum)
Get the width of the specified text, in pixels, using the specified font.
|
static java.lang.Long |
id()
Get this resource's ID.
|
static void |
id(long id)
Set this resource's ID.
|
static handle |
instantiatingProcedure()
Getter for the INSTANTIATING-PROCEDURE attribute.
|
(package private) static boolean |
isLegacyFixedFont(java.lang.String name)
Check if the given font face name is for a fixed font, registered in the
fixedFonts
set. |
private static void |
loadCustomFonts()
Load the custom fonts.
|
private static void |
loadFontMetrics(java.lang.String file)
Load the font metrics from the specified file.
|
private static void |
loadMetricsWorker(org.w3c.dom.NodeList fonts,
java.util.Map<java.lang.String,FontTable.LegacyFontMetrics> m)
Load the font metrics from the specified DOM nodes and load them in the specified map.
|
private static void |
loadTextMetrics(java.lang.String file)
Load the text metrics from the specified file.
|
(package private) static FontDetails<?>[] |
readDefaultFonts()
Read the default fonts.
|
private static void |
readFontAliases()
Read the font aliases.
|
(package private) static FontDetails<?>[] |
readFontTable()
Read the entire font-table.
|
(package private) static java.util.Map<java.lang.String,int[]> |
readLegacyTextMetrics()
Read the legacy text metrics for all the texts and each font defined in the font table, for
this user.
|
static void |
readOnlyError(java.lang.String attribute)
API needed to implement read-only attribute assignment (a 4GL
"feature").
|
(package private) static FontDetails<?>[] |
readSystemFontTable()
Read the font-table with the name of the legacy system fonts.
|
private static java.lang.String |
safeFont(java.lang.String font)
If the given font is
null or empty string, return the
FALLBACK_DEFAULT_FONT . |
static void |
saveFont(int64 fontNum)
Save the the specified font, from the user's font-table, to the environment.
|
static void |
saveFont(long fontNum)
Save the the specified font, from the user's font-table, to the environment.
|
static void |
saveFontTable()
Save the user's font-table to the environment.
|
static void |
setNumEntries(int64 numEntries)
Set the number of entries in the font-table.
|
static void |
setNumEntries(long numEntries)
Set the number of entries in the font-table.
|
(package private) static void |
setThemePreferredFonts(java.util.Map<java.lang.String,java.lang.String> themeFonts,
java.util.Map<java.lang.String,java.lang.String> themeFontAliases)
Set the theme preferred fonts.
|
static boolean |
unknown()
Implementation for the
WrappedResource.unknown() API. |
static boolean |
valid()
Implementation for the
WrappedResource.valid() API. |
private static final java.util.logging.Logger LOG
public static final java.lang.String FONT_TABLE
public static final java.lang.String SYSTEM_FONT_TABLE
public static final java.lang.String WINDOW_TITLE_FONT
public static final java.lang.String ALERT_BOX_FONT
public static final java.lang.String STACK_TRACE_WINDOW_FONT
public static final java.lang.String MENU_FONT
public static final java.lang.String SORT_NUMBER_FONT
public static final java.lang.String CUSTOM_FONTS
public static final java.lang.String FONT_ALIASES
public static final java.lang.String DEFAULT_FONT
public static final java.lang.String DEFAULT_FIXED_FONT
private static final java.lang.String FALLBACK_DEFAULT_FONT
private static java.util.Map<java.lang.String,FontTable.LegacyFontMetrics> legacyFontMetrics
private static java.util.Map<java.lang.String,FontTable.LegacyTextMetrics> legacyTextMetrics
private static java.util.Set<java.lang.String> fixedFonts
private static java.util.Map<java.lang.String,java.lang.Integer> implicitSizes
private static java.util.Map<java.lang.String,byte[]> customFonts
private static java.util.Map<java.lang.String,java.lang.String> defaultCustomFonts
private static final ContextLocal<FontTable.WorkArea> local
public static handle asHandle()
StaticProxy.obtain(Class, Class[])
, using the FontTableResource
interface
and its methods implemented by these classes: FontTable
.public static java.lang.Long id()
public static void id(long id)
This is a no-op for system handles.
id
- The resource's ID.public static boolean valid()
WrappedResource.valid()
API.public static boolean unknown()
WrappedResource.unknown()
API.public static void readOnlyError(java.lang.String attribute)
attribute
- The attribute's name.handle.readOnlyError(handle, String)
public static character getResourceType()
public static handle instantiatingProcedure()
The returned handle will refer a valid external procedure (persistent or not) or will be unknown, in case its instantiating procedure was persistent and has been deleted.
public static decimal getTextHeightChars()
public static decimal getTextHeightChars(long fontNum)
fontNum
- The entry in the font-table.public static decimal getTextHeightChars(int64 fontNum)
fontNum
- The entry in the font-table.public static integer getTextHeightPixels()
public static integer getTextHeightPixels(long fontNum)
fontNum
- The entry in the font-table.public static integer getTextHeightPixels(int64 fontNum)
fontNum
- The entry in the font-table.public static decimal getTextWidthChars(java.lang.String txt)
txt
- The text.public static decimal getTextWidthChars(character txt)
txt
- The text.public static decimal getTextWidthChars(java.lang.String txt, long fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static decimal getTextWidthChars(character txt, long fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static decimal getTextWidthChars(java.lang.String txt, int64 fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static decimal getTextWidthChars(character txt, int64 fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static integer getTextWidthPixels(java.lang.String txt)
txt
- The text.public static integer getTextWidthPixels(character txt)
txt
- The text.public static integer getTextWidthPixels(java.lang.String txt, long fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static integer getTextWidthPixels(character txt, long fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static integer getTextWidthPixels(java.lang.String txt, int64 fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static integer getTextWidthPixels(character txt, int64 fontNum)
txt
- The text.fontNum
- The entry in the font-table.public static integer getNumEntries()
public static void setNumEntries(long numEntries)
numEntries
- The new size of the font-table.public static void setNumEntries(int64 numEntries)
numEntries
- The new size of the font-table.public static void saveFontTable()
public static void saveFont(long fontNum)
PUT-KEY-VALUE FONT font-num
statement.fontNum
- The font-table entry to be saved.public static void saveFont(int64 fontNum)
PUT-KEY-VALUE FONT font-num
statement.fontNum
- The font-table entry to be saved.public static FontTable.FontChooserDialog createFontChooserDialog(int64 fontRef)
fontRef
- The color to be presented to user and changed if the dialog returned is accepted.FontTable.FontChooserDialog.execute()
on this will
result the client to display a theme specific color chooser dialog.public static FontTable.FontChooserDialog createFontChooserDialog(long fontRef)
fontRef
- The color to be presented to user and changed if the dialog returned is accepted.FontTable.FontChooserDialog.execute()
on this will
result the client to display a theme specific color chooser dialog.static void setThemePreferredFonts(java.util.Map<java.lang.String,java.lang.String> themeFonts, java.util.Map<java.lang.String,java.lang.String> themeFontAliases)
themeFonts
- The fonts the current installed Theme
on client prefers.themeFontAliases
- The font aliases currently installed Theme
on client prefers.static FontDetails<?>[] readDefaultFonts()
static FontDetails<?>[] readSystemFontTable()
On index 0, is the window title font. TBD: other fonts.
static FontDetails<?>[] readFontTable()
static byte[] getCustomFontDefinition(java.lang.String name, boolean bold)
null
.name
- The font name.bold
- Flag indicating if this font is bold.null
.static int[] getLegacyFontMetrics(java.lang.String key)
key
- The font's key.static int[] getLegacyTextMetrics(java.lang.String text, java.lang.String key)
text
- The text.key
- The font's key.static java.util.Map<java.lang.String,int[]> readLegacyTextMetrics()
static boolean isLegacyFixedFont(java.lang.String name)
fixedFonts
set.name
- The font name.true
if this is a fixed font in 4GL.static int getImplicitFontSize(java.lang.String name)
implicitSizes
map.name
- The font name.private static void readFontAliases()
private static void loadCustomFonts()
private static byte[] getCustomFontData(java.lang.String fntName, java.lang.String fntPath)
fntName
- The name for custom font.fntPath
- The font file to load data.private static void loadTextMetrics(java.lang.String file)
file
- The XML file with the text metrics.private static void loadFontMetrics(java.lang.String file)
file
- The XML file with the text metrics.private static void loadMetricsWorker(org.w3c.dom.NodeList fonts, java.util.Map<java.lang.String,FontTable.LegacyFontMetrics> m)
fonts
- The DOM nodes defining the font metrics.m
- The map where to load the metrics.private static java.lang.String generateSystemID()
private static java.lang.String safeFont(java.lang.String font)
null
or empty string, return the
FALLBACK_DEFAULT_FONT
. Otherwise, return the given font.private static FontDetails<?>[] buildFontSpecifications(java.lang.String[] fontIDs, java.lang.String[] fontTable)
fontIDs
- An array with the fonts' unique ID.fontTable
- The fonts.private static FontDetails<?> buildFontSpecification(java.lang.String fontID, java.lang.String font)
fontID
- The font unique identification key from the font-table or the system-font-table.
May be null
if no alias is required for this font.font
- The font.