-Font init cleanup. Now has a dedicated position in startup initilization.

This commit is contained in:
Shyotl
2011-12-10 22:45:42 -06:00
parent ffb285c6ff
commit 81499fc6ea
6 changed files with 60 additions and 39 deletions

View File

@@ -125,31 +125,6 @@ bool findOrCreateFont(LLFontGL*& fontp, const LLFontDescriptor& desc)
return (fontp != NULL);
}
// static
BOOL LLFontGL::initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale,
const std::string& app_dir,
const std::vector<std::string>& xui_paths,
bool create_gl_textures)
{
sVertDPI = (F32)llfloor(screen_dpi * y_scale);
sHorizDPI = (F32)llfloor(screen_dpi * x_scale);
sScaleX = x_scale;
sScaleY = y_scale;
sAppDir = app_dir;
// Font registry init
if (!sFontRegistry)
{
sFontRegistry = new LLFontRegistry(xui_paths,create_gl_textures);
sFontRegistry->parseFontInfo("fonts.xml");
}
else
{
sFontRegistry->reset();
}
return loadDefaultFonts();
}
void LLFontGL::destroyGL()
{
@@ -956,6 +931,27 @@ void LLFontGL::removeEmbeddedChar( llwchar wc ) const
}
}
// static
void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures)
{
sVertDPI = (F32)llfloor(screen_dpi * y_scale);
sHorizDPI = (F32)llfloor(screen_dpi * x_scale);
sScaleX = x_scale;
sScaleY = y_scale;
sAppDir = app_dir;
// Font registry init
if (!sFontRegistry)
{
sFontRegistry = new LLFontRegistry(xui_paths,create_gl_textures);
sFontRegistry->parseFontInfo("fonts.xml");
}
else
{
sFontRegistry->reset();
}
}
// Force standard fonts to get generated up front.
// This is primarily for error detection purposes.
// Don't do this during initClass because it can be slow and we want to get

View File

@@ -90,15 +90,9 @@ public:
LLFontGL();
~LLFontGL();
void init(); // Internal init, or reinitialization
void reset(); // Reset a font after GL cleanup. ONLY works on an already loaded font.
static BOOL initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale,
const std::string& app_dir,
const std::vector<std::string>& xui_paths,
bool create_gl_textures = true);
void destroyGL();
/* virtual*/ BOOL loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback);
@@ -173,6 +167,8 @@ public:
void addEmbeddedChar( llwchar wc, LLTexture* image, const LLWString& label) const;
void removeEmbeddedChar( llwchar wc ) const;
static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures = true);
// Load sans-serif, sans-serif-small, etc.
// Slow, requires multiple seconds to load fonts.
static bool loadDefaultFonts();