Skinning How To/The XML files/fonts.xml

From Second Life Wiki
Jump to: navigation, search
  • This page is a stub; feel free to add to it.
  • This page is current as of the SL Viewer version 1.23.


fonts.xml

This file defines the font selection for the default skin of the viewer, and is located in the primary folder \SecondLife\skins\default\xui\en-us.

A customized alternate font specification can therefore be created in any other viewer skin and/or language, such as for French in the Silver skin, by creating a complementary file in \SecondLife\skins\silver\xui\fr

Notes

  • The old, static fonts have been removed and replaced with equivalent calls into the font registry (LLFontRegistry, and support class LLFontDescriptor)
  • fonts.xml is read only once, at viewer startup.
  • fonts.xml contains a <fonts> node with two types of child nodes:
    • < font > associates a name/style combination with one or more font files (< file >).
      • These can be overridden per skin or per language, and can be specialized per OS (<os name="Windows">, <os name="Mac"> if needed.
    • < font_size > associates a name, like "Large", with a specific point size.
  • Within any other XML file that specifies a GUI widget, the requested font/size/and style can all be specified as usual.
    • The viewer gives the best match font for the requested style, so for example if you request a bold italic style, and only a bold font with that name has been declared, you'll get the bold font with the pseudo-italic effects added.
    • the font-style and font_style inconsistency remains in other XML files - the new font handling code allows either form to be used.
    • The font handling preserves backwards compatible naming, so names like SansSerifBold are still recognized. The new-code does this by declare a font with name=SansSerif and style=BOLD. Under the hood both of these get mapped to the same thing.
    • The corresponding font declarations in settings.xml have been removed.
      • However, ChatFontSize remains, which is really just a small/large flag
      • Also FontScreenDPI remains, which still acts more like a global setting rather than a skin feature.

Localization/overlay

  • Combining different skinned or localized versions of fonts.xml is handled by different code than the localization overlay code. This is because the existing localization overlay code only works for named objects and attributes
    • Localized versions of fonts.xml are being handled by new code that does not require the same stringency of unique name= nodes. This allows for lists of unnamed <file></file> entries in this file.
    • Fonts.xml can therefore have multiple occurrences of the same name= associated with different styles, such as:
 <font name="Helvetica"
	comment="Name of Helvetica font">
    <file>arial.ttf</file>
  </font>

  <font name="Helvetica"
	comment="Name of Helvetica font (bold)"
	font_style="BOLD">
    <file>arialbd.ttf</file>
  </font>

  <font name="Helvetica"
	comment="Name of Helvetica font (italic)"
	font_style="ITALIC">
    <file>ariali.ttf</file>
  </font>

  <font name="Helvetica"
	comment="Name of Helvetica font (bold italic)"
	font_style="BOLD|ITALIC">
    <file>arialbi.ttf</file>
  </font>
  • Essentially the unique identifier is a combination of BOTH name="foo" AND font_style="bar". Such a matching entry in another skins folder will be overridden for that skin.


floater_font_test.xml

The visual usage of each of the fonts defined in the standard fonts.xml file can be displayed in the viewer by opening a test floater via Advanced > XUI > Font Test.

This Font Test window is defined in floater_font_test.xml

  • The first time you open this, it will take several seconds to load - it just exposes the slowness of font construction because it creates more of them than normally used.
  • The Font Test floater demonstrates the current standard UI fonts of the viewer (SansSerif in various sizes, SansSerif Bold, and Monospace) and also exercises the new capability to display fonts on the fly.
  • Each line documents its own expected appearance. Deju Vu and Helvetica should appear correctly on any system with those particular fonts defined (including at least most Windows boxes). OverrideTest could vary appearance depending on language and skin - silver skin/french, the font for this line is overridden intentionally. So it varies as documented by the text string, which itself can be overridden in those cases.