Fix monospace font collision, cache more fonts

This commit is contained in:
elasota
2020-11-01 18:03:40 -05:00
parent 2f32c4f434
commit 47be9d73e3
2 changed files with 76 additions and 20 deletions

View File

@@ -41,7 +41,7 @@ int main(int argc, const char **argv);
short isVolume, wasVolume; short isVolume, wasVolume;
short isDepthPref, dataResFile, numSMWarnings; short isDepthPref, dataResFile, numSMWarnings;
Boolean quitting, doZooms, quickerTransitions, isUseICCProfile; Boolean quitting, doZooms, quickerTransitions, isUseICCProfile, isPrefsLoaded;
Boolean isAutoScale = true; Boolean isAutoScale = true;
@@ -155,6 +155,8 @@ void ReadInPrefs (void)
globalModulePrefs.Dispose(); globalModulePrefs.Dispose();
globalModulePrefs = modulePrefs; globalModulePrefs = modulePrefs;
modulePrefs = nullptr; modulePrefs = nullptr;
isPrefsLoaded = true;
} }
else else
{ {
@@ -237,6 +239,8 @@ void ReadInPrefs (void)
displayDriver->RequestToggleFullScreen(0); displayDriver->RequestToggleFullScreen(0);
modulePrefs.Dispose(); modulePrefs.Dispose();
isPrefsLoaded = false;
} }
if ((numNeighbors > 1) && (thisMac.constrainedScreen.right <= 512)) if ((numNeighbors > 1) && (thisMac.constrainedScreen.right <= 512))
@@ -346,7 +350,7 @@ void StepLoadScreen(int steps)
if (loadScreenWindow) if (loadScreenWindow)
{ {
int oldProgress = loadScreenProgress; int oldProgress = loadScreenProgress;
int loadScreenMax = 19; int loadScreenMax = 25;
loadScreenProgress = loadScreenProgress + steps; loadScreenProgress = loadScreenProgress + steps;
if (loadScreenProgress > loadScreenMax) if (loadScreenProgress > loadScreenMax)
loadScreenProgress = loadScreenMax; loadScreenProgress = loadScreenMax;
@@ -370,7 +374,15 @@ void InitLoadingWindow()
return; return;
static const int kLoadScreenHeight = 32; static const int kLoadScreenHeight = 32;
static const int kLoadScreenWidth = 256;
int kLoadScreenWidth = 256;
PLPasStr loadingText = PSTR("Loading...");
if (!isPrefsLoaded)
{
loadingText = PSTR("Performing First-Time Setup...");
kLoadScreenWidth = 420;
}
ForceSyncFrame(); ForceSyncFrame();
PLSysCalls::Sleep(1); PLSysCalls::Sleep(1);
@@ -395,7 +407,6 @@ void InitLoadingWindow()
PortabilityLayer::WindowManager::GetInstance()->FlickerWindowIn(loadScreenWindow, 32); PortabilityLayer::WindowManager::GetInstance()->FlickerWindowIn(loadScreenWindow, 32);
const PLPasStr loadingText = PSTR("Loading...");
PortabilityLayer::RenderedFont *font = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true); PortabilityLayer::RenderedFont *font = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
int32_t textY = (kLoadScreenHeight + font->GetMetrics().m_ascent) / 2; int32_t textY = (kLoadScreenHeight + font->GetMetrics().m_ascent) / 2;
surface->DrawString(Point::Create(4+16, textY), loadingText, blackColor, font); surface->DrawString(Point::Create(4+16, textY), loadingText, blackColor, font);
@@ -412,20 +423,65 @@ void InitLoadingWindow()
void PreloadFonts() void PreloadFonts()
{ {
GetApplicationFont(8, PortabilityLayer::FontFamilyFlag_None, true); enum FontCategory
StepLoadScreen(1); {
GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true); FontCategory_System,
StepLoadScreen(1); FontCategory_Application,
GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true); FontCategory_Handwriting,
StepLoadScreen(1); FontCategory_Monospace,
GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold, true); };
StepLoadScreen(1);
GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true); struct FontSpec
StepLoadScreen(1); {
GetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true); FontCategory m_category;
StepLoadScreen(1); int m_size;
GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true); int m_flags;
StepLoadScreen(1); bool m_aa;
};
FontSpec specs[] =
{
{ FontCategory_System, 9, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_System, 10, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_Application, 8, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Application, 9, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Application, 12, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_Application, 14, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_Application, 18, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Application, 40, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Handwriting, 24, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Handwriting, 48, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Monospace, 10, PortabilityLayer::FontFamilyFlag_None, true },
};
const int numFontSpecs = sizeof(specs) / sizeof(specs[0]);
for (int i = 0; i < numFontSpecs; i++)
{
const FontSpec &spec = specs[i];
switch (spec.m_category)
{
case FontCategory_Application:
GetApplicationFont(spec.m_size, spec.m_flags, spec.m_aa);
break;
case FontCategory_System:
GetSystemFont(spec.m_size, spec.m_flags, spec.m_aa);
break;
case FontCategory_Handwriting:
GetHandwritingFont(spec.m_size, spec.m_flags, spec.m_aa);
break;
case FontCategory_Monospace:
GetMonospaceFont(spec.m_size, spec.m_flags, spec.m_aa);
break;
default:
break;
}
StepLoadScreen(1);
}
} }
void gpAppInit() void gpAppInit()
@@ -480,7 +536,7 @@ int gpAppMain()
if (!copyGood) if (!copyGood)
encryptedNumber = 0L; encryptedNumber = 0L;
else if (didValidation) else if (didValidation)
WriteOutPrefs(); StepLoadScreen(3); WriteOutPrefs(); SpinCursor(3);
#endif #endif
// if ((thisMac.numScreens > 1) && (isUseSecondScreen)) // if ((thisMac.numScreens > 1) && (isUseSecondScreen))

View File

@@ -41,7 +41,7 @@ namespace PortabilityLayer
static const int kSystemFontCacheID = 1; static const int kSystemFontCacheID = 1;
static const int kApplicationFontCacheID = 2; static const int kApplicationFontCacheID = 2;
static const int kHandwritingFontCacheID = 3; static const int kHandwritingFontCacheID = 3;
static const int kMonospaceFontCacheID = 3; static const int kMonospaceFontCacheID = 4;
static const int kFontCacheVersion = 1; static const int kFontCacheVersion = 1;
static const int kFontCacheNameSize = 64; static const int kFontCacheNameSize = 64;