A theme_font is a font whose name describes its role
rather than its appearance. The font aliases, such as normal, bold
and tt, are theme fonts. A theme font is derived from
another font and copies its family, style, weight and points. Unlike
other fonts, a theme font is not shared with the fonts that have the
same properties:
normal and font(sans, normal, 12) are
different objects. Changing the font a theme font is derived from
changes the theme font in place, so everything that uses it follows:
?- send(new(P, picture), open),
send(P, display, text('Hello world', left, normal)).
?- get(@pce, convert, normal, font, F),
send(F, derived_from, font(serif, italic, 20)),
send(@display_manager, fonts_changed).
Theme fonts are created from the class variables font.system_fonts
and font.user_fonts when the first font is
used. Changing these class variables and sending display_manager->fonts_changed
updates the theme fonts. Theme fonts are in the hash table @font_aliases,
which maps their name to the theme font, and in the chain
@theme_fonts. They are protected, so they are never
garbage collected.
A theme font may be derived from another theme font. It then takes
the font the other theme font is derived from at that moment: it does
not follow later changes to the other theme font. Methods that create a
new font from a theme font, such as font<-rescale,
create an ordinary font.
The class variable editor saves a theme font by its name. Its font items have a button to select a theme font.
.g., normal.
This is the key in
@font_aliases.<-lookup
returns it after setting theme_font->derived_from.->fonts_changed
after changing theme fonts.->derived_from
and return it. This makes creating a theme font again a way to change
it.