SL-16141 Load fonts and generate glyphs on startup
parent
dc972623a9
commit
2238f89db7
|
|
@ -547,9 +547,19 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, S32 begin_offset, S32 max_chars
|
|||
return cur_x / sScaleX;
|
||||
}
|
||||
|
||||
void LLFontGL::generateASCIIglyphs()
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED
|
||||
for (U32 i = 32; (i < 127); i++)
|
||||
{
|
||||
mFontFreetype->getGlyphInfo(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels
|
||||
S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, EWordWrapStyle end_on_word_boundary) const
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED
|
||||
if (!wchars || !wchars[0] || max_chars == 0)
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -829,6 +839,8 @@ void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::st
|
|||
{
|
||||
sFontRegistry->reset();
|
||||
}
|
||||
|
||||
LLFontGL::loadDefaultFonts();
|
||||
}
|
||||
|
||||
// Force standard fonts to get generated up front.
|
||||
|
|
@ -838,6 +850,7 @@ void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::st
|
|||
// static
|
||||
bool LLFontGL::loadDefaultFonts()
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED
|
||||
bool succ = true;
|
||||
succ &= (NULL != getFontSansSerifSmall());
|
||||
succ &= (NULL != getFontSansSerif());
|
||||
|
|
@ -845,10 +858,18 @@ bool LLFontGL::loadDefaultFonts()
|
|||
succ &= (NULL != getFontSansSerifHuge());
|
||||
succ &= (NULL != getFontSansSerifBold());
|
||||
succ &= (NULL != getFontMonospace());
|
||||
succ &= (NULL != getFontExtChar());
|
||||
return succ;
|
||||
}
|
||||
|
||||
void LLFontGL::loadCommonFonts()
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED
|
||||
getFont(LLFontDescriptor("SansSerif", "Small", BOLD));
|
||||
getFont(LLFontDescriptor("SansSerif", "Large", BOLD));
|
||||
getFont(LLFontDescriptor("SansSerif", "Huge", BOLD));
|
||||
getFont(LLFontDescriptor("Monospace", "Medium", 0));
|
||||
}
|
||||
|
||||
// static
|
||||
void LLFontGL::destroyDefaultFonts()
|
||||
{
|
||||
|
|
@ -1015,7 +1036,7 @@ LLFontGL* LLFontGL::getFontSansSerifBig()
|
|||
//static
|
||||
LLFontGL* LLFontGL::getFontSansSerifHuge()
|
||||
{
|
||||
static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif","Large",0));
|
||||
static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif","Huge",0));
|
||||
return fontp;
|
||||
}
|
||||
|
||||
|
|
@ -1026,12 +1047,6 @@ LLFontGL* LLFontGL::getFontSansSerifBold()
|
|||
return fontp;
|
||||
}
|
||||
|
||||
//static
|
||||
LLFontGL* LLFontGL::getFontExtChar()
|
||||
{
|
||||
return getFontSansSerif();
|
||||
}
|
||||
|
||||
//static
|
||||
LLFontGL* LLFontGL::getFont(const LLFontDescriptor& desc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,12 +160,15 @@ public:
|
|||
|
||||
const LLFontDescriptor& getFontDesc() const;
|
||||
|
||||
void generateASCIIglyphs();
|
||||
|
||||
|
||||
static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, bool create_gl_textures = true);
|
||||
|
||||
// Load sans-serif, sans-serif-small, etc.
|
||||
// Slow, requires multiple seconds to load fonts.
|
||||
static bool loadDefaultFonts();
|
||||
static void loadCommonFonts();
|
||||
static void destroyDefaultFonts();
|
||||
static void destroyAllGL();
|
||||
|
||||
|
|
@ -190,7 +193,6 @@ public:
|
|||
static LLFontGL* getFontSansSerifBig();
|
||||
static LLFontGL* getFontSansSerifHuge();
|
||||
static LLFontGL* getFontSansSerifBold();
|
||||
static LLFontGL* getFontExtChar();
|
||||
static LLFontGL* getFont(const LLFontDescriptor& desc);
|
||||
// Use with legacy names like "SANSSERIF_SMALL" or "OCRA"
|
||||
static LLFontGL* getFontByName(const std::string& name);
|
||||
|
|
|
|||
|
|
@ -597,6 +597,11 @@ LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& desc)
|
|||
<<" style=[" << ((S32) desc.getStyle()) << "]"
|
||||
<< " size=[" << desc.getSize() << "]" << LL_ENDL;
|
||||
}
|
||||
else
|
||||
{
|
||||
//generate glyphs for ASCII chars to avoid stalls later
|
||||
fontp->generateASCIIglyphs();
|
||||
}
|
||||
return fontp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1963,6 +1963,13 @@ LLViewerWindow::LLViewerWindow(const Params& p)
|
|||
}
|
||||
|
||||
LLFontManager::initClass();
|
||||
// Init font system, load default fonts and generate basic glyphs
|
||||
// currently it takes aprox. 0.5 sec and we would load these fonts anyway
|
||||
// before login screen.
|
||||
LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"),
|
||||
mDisplayScale.mV[VX],
|
||||
mDisplayScale.mV[VY],
|
||||
gDirUtilp->getAppRODataDir());
|
||||
|
||||
//
|
||||
// We want to set this stuff up BEFORE we initialize the pipeline, so we can turn off
|
||||
|
|
@ -2009,14 +2016,6 @@ LLViewerWindow::LLViewerWindow(const Params& p)
|
|||
LLViewerTextureManager::init() ;
|
||||
gBumpImageList.init();
|
||||
|
||||
// Init font system, but don't actually load the fonts yet
|
||||
// because our window isn't onscreen and they take several
|
||||
// seconds to parse.
|
||||
LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"),
|
||||
mDisplayScale.mV[VX],
|
||||
mDisplayScale.mV[VY],
|
||||
gDirUtilp->getAppRODataDir());
|
||||
|
||||
// Create container for all sub-views
|
||||
LLView::Params rvp;
|
||||
rvp.name("root");
|
||||
|
|
@ -2102,6 +2101,8 @@ void LLViewerWindow::initBase()
|
|||
LL_DEBUGS("AppInit") << "initializing edit menu" << LL_ENDL;
|
||||
initialize_edit_menu();
|
||||
|
||||
LLFontGL::loadCommonFonts();
|
||||
|
||||
// Create the floater view at the start so that other views can add children to it.
|
||||
// (But wait to add it as a child of the root view so that it will be in front of the
|
||||
// other views.)
|
||||
|
|
@ -5499,8 +5500,6 @@ void LLViewerWindow::initFonts(F32 zoom_factor)
|
|||
mDisplayScale.mV[VX] * zoom_factor,
|
||||
mDisplayScale.mV[VY] * zoom_factor,
|
||||
gDirUtilp->getAppRODataDir());
|
||||
// Force font reloads, which can be very slow
|
||||
LLFontGL::loadDefaultFonts();
|
||||
}
|
||||
|
||||
void LLViewerWindow::requestResolutionUpdate()
|
||||
|
|
|
|||
Loading…
Reference in New Issue