(Android) Fonts and locales are now copied earlier than the other assets as HarfBuzz and libintl need them earlier in the startup process

This commit is contained in:
Leon Styhre 2024-08-20 23:09:11 +02:00
parent c630ad091c
commit 5a2e6ec537

View file

@ -1014,7 +1014,20 @@ int main(int argc, char* argv[])
} }
#if defined(__ANDROID__) #if defined(__ANDROID__)
Utils::Platform::Android::setupLocalizationFiles(); // We need to copy the font and locale files before starting the renderer as HarfBuzz
// and libintl need them before that point.
std::string buildIdentifier {PROGRAM_VERSION_STRING};
buildIdentifier.append(" (r")
.append(std::to_string(PROGRAM_RELEASE_NUMBER))
.append("), built ")
.append(PROGRAM_BUILT_STRING);
const bool needResourceCopy {Utils::Platform::Android::checkNeedResourceCopy(buildIdentifier)};
if (needResourceCopy) {
LOG(LogInfo) << "Application has been updated or it's a new installation, copying "
"bundled fonts and locales to internal storage...";
Utils::Platform::Android::setupFontFiles();
Utils::Platform::Android::setupLocalizationFiles();
}
#endif #endif
Utils::Localization::setLocale(); Utils::Localization::setLocale();
@ -1052,21 +1065,14 @@ int main(int argc, char* argv[])
LOG(LogDebug) << "Android internal directory: " << AndroidVariables::sInternalDataDirectory; LOG(LogDebug) << "Android internal directory: " << AndroidVariables::sInternalDataDirectory;
LOG(LogDebug) << "Android external directory: " << AndroidVariables::sExternalDataDirectory; LOG(LogDebug) << "Android external directory: " << AndroidVariables::sExternalDataDirectory;
{ if (needResourceCopy) {
std::string buildIdentifier {PROGRAM_VERSION_STRING}; LOG(LogInfo) << "Application has been updated or it's a new installation, copying "
buildIdentifier.append(" (r") "bundled resources and theme to internal storage...";
.append(std::to_string(PROGRAM_RELEASE_NUMBER)) if (Settings::getInstance()->getBool("SplashScreen"))
.append("), built ") window->renderSplashScreen(Window::SplashScreenState::RESOURCE_COPY, 0.0f);
.append(PROGRAM_BUILT_STRING); if (Utils::Platform::Android::setupResources(buildIdentifier)) {
if (Utils::Platform::Android::checkNeedResourceCopy(buildIdentifier)) { LOG(LogError) << "Copying of resources and themes failed";
LOG(LogInfo) << "Application has been updated or it's a new installation, copying " return -1;
"bundled resources and theme to internal storage...";
if (Settings::getInstance()->getBool("SplashScreen"))
window->renderSplashScreen(Window::SplashScreenState::RESOURCE_COPY, 0.0f);
if (Utils::Platform::Android::setupResources(buildIdentifier)) {
LOG(LogError) << "Copying of resources and themes failed";
return -1;
}
} }
} }