Specialize font paths for preinstalled font selection instead

This commit is contained in:
elasota
2021-04-15 20:56:31 -04:00
parent 22ae442f87
commit 141f840888
17 changed files with 49 additions and 54 deletions

View File

@@ -15,16 +15,20 @@
namespace PortabilityLayer
{
FontFamily::FontSpec::FontSpec()
: m_fontPath(nullptr)
: m_fontVDir(VirtualDirectories::kUnspecified)
, m_fontPath(nullptr)
, m_font(nullptr)
, m_hacks(FontHacks_None)
, m_typeFaceIndex(0)
, m_isRegistered(false)
{
}
void FontFamily::AddFont(int flags, const char *path, FontHacks fontHacks)
void FontFamily::AddFont(int flags, VirtualDirectory_t vDir, const char *path, int typeFaceIndex, FontHacks fontHacks)
{
m_fontSpecs[flags].m_fontVDir = vDir;
m_fontSpecs[flags].m_fontPath = path;
m_fontSpecs[flags].m_typeFaceIndex = typeFaceIndex;
m_fontSpecs[flags].m_hacks = fontHacks;
m_fontSpecs[flags].m_isRegistered = true;
@@ -55,7 +59,7 @@ namespace PortabilityLayer
if (spec.m_font)
return spec.m_font;
GpIOStream *sysFontStream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFonts, spec.m_fontPath, false, GpFileCreationDispositions::kOpenExisting);
GpIOStream *sysFontStream = PLDrivers::GetFileSystem()->OpenFile(spec.m_fontVDir, spec.m_fontPath, false, GpFileCreationDispositions::kOpenExisting);
if (!sysFontStream)
return nullptr;
@@ -93,7 +97,7 @@ namespace PortabilityLayer
IGpFontHandler *fontHandler = PLDrivers::GetFontHandler();
IGpFont *font = fontHandler->LoadFont(sysFontStream);
IGpFont *font = fontHandler->LoadFont(sysFontStream, spec.m_typeFaceIndex);
if (!fontHandler->KeepStreamOpen())
sysFontStream->Close();
@@ -121,13 +125,16 @@ namespace PortabilityLayer
return m_fontSpecs[variation].m_hacks;
}
bool FontFamily::GetFontSpec(int variation, FontHacks &outHacks, const char *&outPath)
bool FontFamily::GetFontSpec(int variation, FontHacks &outHacks, VirtualDirectory_t &outVDir, const char *&outPath, int &outTypeFaceIndex)
{
if (!m_fontSpecs[variation].m_isRegistered)
const FontSpec &spec = m_fontSpecs[variation];
if (!spec.m_isRegistered)
return false;
outHacks = m_fontSpecs[variation].m_hacks;
outPath = m_fontSpecs[variation].m_fontPath;
outHacks = spec.m_hacks;
outVDir = spec.m_fontVDir;
outPath = spec.m_fontPath;
outTypeFaceIndex = spec.m_typeFaceIndex;
return true;
}