diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index d327b8e4c..1c79ab2e9 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -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& 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& 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 diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 67821376c..fc59ce0fd 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -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& 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& xui_paths, bool create_gl_textures = true); + // Load sans-serif, sans-serif-small, etc. // Slow, requires multiple seconds to load fonts. static bool loadDefaultFonts(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 11e310cb9..7c000984e 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1987,10 +1987,18 @@ bool idle_startup() if (STATE_MULTIMEDIA_INIT == LLStartUp::getStartupState()) { LLStartUp::multimediaInit(); - LLStartUp::setStartupState( STATE_SEED_GRANTED_WAIT ); + LLStartUp::setStartupState( STATE_FONT_INIT ); return FALSE; } + // Loading fonts takes several seconds + if (STATE_FONT_INIT == LLStartUp::getStartupState()) + { + LLStartUp::fontInit(); + LLStartUp::setStartupState( STATE_SEED_GRANTED_WAIT ); + return FALSE; + } + //--------------------------------------------------------------------- // Wait for Seed Cap Grant //--------------------------------------------------------------------- @@ -3757,6 +3765,7 @@ std::string LLStartUp::startupStateToString(EStartupState state) RTNENUM( STATE_LOGIN_DOWNLOADING ); RTNENUM( STATE_LOGIN_PROCESS_RESPONSE ); RTNENUM( STATE_WORLD_INIT ); + RTNENUM( STATE_FONT_INIT ); RTNENUM( STATE_SEED_GRANTED_WAIT ); RTNENUM( STATE_SEED_CAP_GRANTED ); RTNENUM( STATE_WORLD_WAIT ); @@ -3831,6 +3840,15 @@ void LLStartUp::multimediaInit() LLViewerParcelMedia::initClass(); } +void LLStartUp::fontInit() +{ + LL_DEBUGS("AppInit") << "Initializing fonts...." << LL_ENDL; + std::string msg = LLTrans::getString("LoginInitializingFonts"); + set_startup_status(0.45f, msg.c_str(), gAgent.mMOTD.c_str()); + display_startup(); + + LLFontGL::loadDefaultFonts(); +} void LLStartUp::initNameCache() { diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index 40e79b0bb..2574f0907 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -61,6 +61,7 @@ typedef enum { STATE_LOGIN_PROCESS_RESPONSE, // Check authentication reply STATE_WORLD_INIT, // Start building the world STATE_MULTIMEDIA_INIT, // Init the rest of multimedia library + STATE_FONT_INIT, // Load default fonts STATE_SEED_GRANTED_WAIT, // Wait for seed cap grant STATE_SEED_CAP_GRANTED, // Have seed cap grant STATE_WORLD_WAIT, // Waiting for simulator @@ -95,6 +96,8 @@ public: static void multimediaInit(); // Initialize LLViewerMedia multimedia engine. + // Load default fonts not already loaded at start screen + static void fontInit(); static void initNameCache(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2d63e754d..9d984cc09 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1541,14 +1541,19 @@ LLViewerWindow::LLViewerWindow( LLViewerTextureManager::init() ; gBumpImageList.init(); - // Create container for all sub-views - mRootView = new LLRootView("root", mWindowRectScaled, FALSE); - + // Init font system, but don't actually load the fonts yet + // because our window isn't onscreen and they take several + // seconds to parse. if (!gNoRender) { - // Init default fonts - initFonts(); + LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"), + mDisplayScale.mV[VX], + mDisplayScale.mV[VY], + gDirUtilp->getAppRODataDir(), + LLUICtrlFactory::getXUIPaths()); } + // Create container for all sub-views + mRootView = new LLRootView("root", mWindowRectScaled, FALSE); // Make avatar head look forward at start mCurrentMousePoint.mX = getWindowWidthScaled() / 2; @@ -4828,11 +4833,13 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) void LLViewerWindow::initFonts(F32 zoom_factor) { LLFontGL::destroyAllGL(); - LLFontGL::initDefaultFonts( gSavedSettings.getF32("FontScreenDPI"), + // Initialize with possibly different zoom factor + LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"), mDisplayScale.mV[VX] * zoom_factor, mDisplayScale.mV[VY] * zoom_factor, gDirUtilp->getAppRODataDir(), LLUICtrlFactory::getXUIPaths()); + LLFontGL::loadDefaultFonts(); } void LLViewerWindow::toggleFullscreen(BOOL show_progress) { diff --git a/indra/newview/skins/default/xui/en-us/strings.xml b/indra/newview/skins/default/xui/en-us/strings.xml index 070399959..7cae0290f 100644 --- a/indra/newview/skins/default/xui/en-us/strings.xml +++ b/indra/newview/skins/default/xui/en-us/strings.xml @@ -22,6 +22,7 @@ Loading world... Initializing embedded web browser... Initializing multimedia... + Loading fonts... Verifying cache files (can take 60-90 seconds)... Processing Response... Initializing World...