User:Alissa Sabre/Memo on LLFont, LLFontGL, and related classes

From Second Life Wiki
Jump to navigation Jump to search

LLFont and LLFontGL classes provide low-level text drawing functions. The classes are used by other UI component classes.

Classes

LLFont (llrender/llfont.{h,cpp}) is the base class, and LLFontGL (llrender/llfontgl.{h,cpp}) is the derived class.

LLFontManager (piggyback in llrender/llfont.{h,cpp}) does some initialization and cleanup of the FreeType library through its initClass() and cleanupClass() static methods. It does nothing else. It doesn not manage any fonts.

Other classes are used only by LLFont/LLFontGL classes and not for public use.

LLFont

Constructors and instances

Although LLFont has a public constructor (LLFont(LLImageRaw *), it is intended to be used by LLFontGL only. I have no idea why it is declared public.

The constructor is called directly to create an LLFont instance and indirectly to initialize the LLFont portion of an LLFontGL instance. However, the LLFont instances are only used by LLFontGL class, and there are not available to public.

Users of LLFont/LLFontGL classes should consider there are no LLFont instances.

Members

Although LLFont class has several public member functions, they are only used by LLFont/LLFontGL classes with one exception. Users of LLFont/LLFontGL never use other LLFont members.

The only exception is the LLFont::FIRST_CHAR. It is an int constant, whose value is, despite of the name, the largest value of the ASCII control codes. Currently, it is used only once in llui/lltexteditor.cpp to identify ASCII control codes, so that it can remove (possibly harmful) control codes from the data received from the system's clipboard during the paste operation.

Some LLFont members are never used even by LLFont/LLFontGL implementation. I guess they are remnants from the earlier versions of the viewer.

LLFontGL

LLFontManager

There is a global variable of type LLFontManager *, gFontManagerp. Although it has global scope, it is only used in static member functions of LLFontManager class. I believe the variable is better to be a private static member of LLFontManager class.

LLFontManager has a public constructor. However, it is only used once in LLFontManager class to set the gFontManagerp. Moreover, the constructor updates global variable used by the FreeType library, and if two or more instances of LLFontManger are ever constructed, the FreeType library breaks. I believe LLFontManager::LLFontManager() should be declared private.