Add Inter font, map Chicago system symbol reservations using it, use Command symbol on macOS

This commit is contained in:
elasota
2021-08-01 22:24:41 -04:00
parent f9109850a6
commit c04aeeb962
26 changed files with 389 additions and 101 deletions

View File

@@ -4,7 +4,7 @@
{ {
"name" : "Okay", "name" : "Okay",
"itemType" : "Button", "itemType" : "Button",
"pos" : [ 438, 292 ], "pos" : [ 438, 316 ],
"size" : [ 58, 20 ], "size" : [ 58, 20 ],
"id" : 1, "id" : 1,
"enabled" : true "enabled" : true
@@ -12,7 +12,7 @@
{ {
"name" : "Export Source Code to ZIP Archive...", "name" : "Export Source Code to ZIP Archive...",
"itemType" : "Button", "itemType" : "Button",
"pos" : [ 205, 292 ], "pos" : [ 205, 316 ],
"size" : [ 226, 20 ], "size" : [ 226, 20 ],
"id" : 1, "id" : 1,
"enabled" : false "enabled" : false
@@ -98,7 +98,7 @@
"enabled" : true "enabled" : true
}, },
{ {
"name" : "LIBICONV ©1999-2001, 2016 Free Software Foundation, Inc.", "name" : "Inter font ©2016-2019 Rasmus Andersson + Inter Project Authors",
"itemType" : "Label", "itemType" : "Label",
"pos" : [ 16, 149 ], "pos" : [ 16, 149 ],
"size" : [ 406, 20 ], "size" : [ 406, 20 ],
@@ -114,7 +114,7 @@
"enabled" : true "enabled" : true
}, },
{ {
"name" : "RapidJSON ©2015 THL A29 Limited, a Tencent company, and Milo Yip", "name" : "LIBICONV ©1999-2001, 2016 Free Software Foundation, Inc.",
"itemType" : "Label", "itemType" : "Label",
"pos" : [ 16, 172 ], "pos" : [ 16, 172 ],
"size" : [ 406, 28 ], "size" : [ 406, 28 ],
@@ -130,7 +130,7 @@
"enabled" : true "enabled" : true
}, },
{ {
"name" : "zlib ©1995-2017 Jean-loup Gailly and Mark Adler", "name" : "RapidJSON ©2015 THL A29 Limited, a Tencent company, and Milo Yip",
"itemType" : "Label", "itemType" : "Label",
"pos" : [ 16, 205 ], "pos" : [ 16, 205 ],
"size" : [ 406, 20 ], "size" : [ 406, 20 ],
@@ -146,7 +146,7 @@
"enabled" : true "enabled" : true
}, },
{ {
"name" : "FreeType ©2020 The FreeType Project", "name" : "zlib ©1995-2017 Jean-loup Gailly and Mark Adler",
"itemType" : "Label", "itemType" : "Label",
"pos" : [ 16, 229 ], "pos" : [ 16, 229 ],
"size" : [ 406, 20 ], "size" : [ 406, 20 ],
@@ -162,7 +162,7 @@
"enabled" : true "enabled" : true
}, },
{ {
"name" : "Simple DirectMedia Layer ©1997-2020 Sam Lantinga", "name" : "FreeType ©2020 The FreeType Project",
"itemType" : "Label", "itemType" : "Label",
"pos" : [ 16, 253 ], "pos" : [ 16, 253 ],
"size" : [ 406, 20 ], "size" : [ 406, 20 ],
@@ -176,6 +176,22 @@
"size" : [ 66, 20 ], "size" : [ 66, 20 ],
"id" : 1, "id" : 1,
"enabled" : true "enabled" : true
},
{
"name" : "Simple DirectMedia Layer ©1997-2020 Sam Lantinga",
"itemType" : "Label",
"pos" : [ 16, 277 ],
"size" : [ 406, 20 ],
"id" : 1,
"enabled" : true
},
{
"name" : "License...",
"itemType" : "Button",
"pos" : [ 430, 272 ],
"size" : [ 66, 20 ],
"id" : 1,
"enabled" : true
} }
] ]
} }

View File

@@ -233,11 +233,12 @@ void DoAboutOpenSource(void)
static const int kOpenSansLicenseButton = 8; static const int kOpenSansLicenseButton = 8;
static const int kRobotoMonoLicenseButton = 10; static const int kRobotoMonoLicenseButton = 10;
static const int kGochiHandLicenseButton = 12; static const int kGochiHandLicenseButton = 12;
static const int kLibIConvLicenseButton = 14; static const int kInterLicenseButton = 14;
static const int kRapidJSONLicenseButton = 16; static const int kLibIConvLicenseButton = 16;
static const int kZLibLicenseButton = 18; static const int kRapidJSONLicenseButton = 18;
static const int kFreeTypeLicenseButton = 20; static const int kZLibLicenseButton = 20;
static const int kSDLLicenseButton = 22; static const int kFreeTypeLicenseButton = 22;
static const int kSDLLicenseButton = 24;
static const int kLicenseResourceApache = 1000; static const int kLicenseResourceApache = 1000;
static const int kLicenseResourceGPLv2 = 1001; static const int kLicenseResourceGPLv2 = 1001;
@@ -249,7 +250,7 @@ void DoAboutOpenSource(void)
static const int kAboutOpenSourceDialogTemplateID = 2005; static const int kAboutOpenSourceDialogTemplateID = 2005;
const Rect windowRect = Rect::Create(0, 0, 324, 512); const Rect windowRect = Rect::Create(0, 0, 348, 512);
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR("")); PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
@@ -281,6 +282,7 @@ void DoAboutOpenSource(void)
DoLicenseReader(kLicenseResourceApache); DoLicenseReader(kLicenseResourceApache);
break; break;
case kGochiHandLicenseButton: case kGochiHandLicenseButton:
case kInterLicenseButton:
DoLicenseReader(kLicenseResourceOFL); DoLicenseReader(kLicenseResourceOFL);
break; break;
case kLibIConvLicenseButton: case kLibIConvLicenseButton:

View File

@@ -537,9 +537,6 @@ int AppStartup()
ToolBoxInit(); ToolBoxInit();
CheckOurEnvirons(); CheckOurEnvirons();
if (thisMac.isTouchscreen)
PortabilityLayer::MenuManager::GetInstance()->SetMenuTouchScreenStyle(true);
if (!thisMac.hasColor) if (!thisMac.hasColor)
RedAlert(kErrNeedColorQD); RedAlert(kErrNeedColorQD);
if (!thisMac.hasSystem7) if (!thisMac.hasSystem7)
@@ -686,4 +683,4 @@ int gpAppMain()
HandleEvent(); HandleEvent();
return AppShutdown(); return AppShutdown();
} }

View File

@@ -0,0 +1,64 @@
#include "CompositeRenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "GpRenderedGlyphMetrics.h"
#include <assert.h>
PortabilityLayer::CompositeRenderedFont::CompositeRenderedFont(RenderedFont *rfont, RenderedFont *fallbackFont)
: m_font(rfont)
, m_fallbackFont(fallbackFont)
, m_metrics(rfont->GetMetrics())
{
assert(rfont->IsAntiAliased() == fallbackFont->IsAntiAliased());
const GpRenderedFontMetrics fallbackMetrics = fallbackFont->GetMetrics();
if (fallbackMetrics.m_ascent > m_metrics.m_ascent)
m_metrics.m_ascent = fallbackMetrics.m_ascent;
if (fallbackMetrics.m_descent < m_metrics.m_descent)
m_metrics.m_descent = fallbackMetrics.m_descent;
if (fallbackMetrics.m_linegap > m_metrics.m_linegap)
m_metrics.m_linegap = fallbackMetrics.m_linegap;
}
bool PortabilityLayer::CompositeRenderedFont::GetGlyph(unsigned int character, const GpRenderedGlyphMetrics *&outMetricsPtr, const void *&outData) const
{
if (m_font->GetGlyph(character, outMetricsPtr, outData))
return true;
return m_fallbackFont->GetGlyph(character, outMetricsPtr, outData);
}
const GpRenderedFontMetrics &PortabilityLayer::CompositeRenderedFont::GetMetrics() const
{
return m_metrics;
}
size_t PortabilityLayer::CompositeRenderedFont::MeasureString(const uint8_t *chars, size_t len) const
{
int32_t measure = 0;
for (size_t i = 0; i < len; i++)
{
const uint8_t character = chars[i];
const GpRenderedGlyphMetrics *metrics = nullptr;
const void *data = nullptr;
if (m_font->GetGlyph(chars[i], metrics, data))
measure += metrics->m_advanceX;
else if (m_fallbackFont->GetGlyph(chars[i], metrics, data))
measure += metrics->m_advanceX;
}
return static_cast<size_t>(measure);
}
bool PortabilityLayer::CompositeRenderedFont::IsAntiAliased() const
{
return m_font->IsAntiAliased();
}
void PortabilityLayer::CompositeRenderedFont::Destroy()
{
assert(false);
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
namespace PortabilityLayer
{
class CompositeRenderedFont : public RenderedFont
{
public:
CompositeRenderedFont(RenderedFont *rfont, RenderedFont *fallbackFont);
bool GetGlyph(unsigned int character, const GpRenderedGlyphMetrics *&outMetricsPtr, const void *&outData) const override;
const GpRenderedFontMetrics &GetMetrics() const override;
size_t MeasureString(const uint8_t *chars, size_t len) const override;
bool IsAntiAliased() const override;
void Destroy() override;
size_t MeasureCharStr(const char *str, size_t len) const;
size_t MeasurePStr(const PLPasStr &pstr) const;
private:
GpRenderedFontMetrics m_metrics;
RenderedFont *m_font;
RenderedFont *m_fallbackFont;
};
}

View File

@@ -6,6 +6,7 @@ namespace PortabilityLayer
{ {
enum FontFamilyID enum FontFamilyID
{ {
kSystemSymbols,
kSystem, kSystem,
kApplication, kApplication,
kMonospace, kMonospace,

View File

@@ -7,5 +7,6 @@ namespace PortabilityLayer
FontHacks_None, FontHacks_None,
FontHacks_Roboto, FontHacks_Roboto,
FontHacks_SyntheticBold_OpenSans, FontHacks_SyntheticBold_OpenSans,
FontHacks_SystemSymbols,
}; };
} }

View File

@@ -91,6 +91,9 @@ namespace PortabilityLayer
for (int i = 0; i < FontFamilyIDs::kCount; i++) for (int i = 0; i < FontFamilyIDs::kCount; i++)
m_fontFamilies[static_cast<FontFamilyID_t>(i)] = FontFamily::Create(static_cast<FontFamilyID_t>(i)); m_fontFamilies[static_cast<FontFamilyID_t>(i)] = FontFamily::Create(static_cast<FontFamilyID_t>(i));
if (m_fontFamilies[FontFamilyIDs::kSystemSymbols])
m_fontFamilies[FontFamilyIDs::kSystemSymbols]->AddFont(FontFamilyFlag_None, VirtualDirectories::kFonts, "Fonts/Inter/Inter-SemiBold.ttf", 0, FontHacks_SystemSymbols);
if (m_fontFamilies[FontFamilyIDs::kSystem]) if (m_fontFamilies[FontFamilyIDs::kSystem])
m_fontFamilies[FontFamilyIDs::kSystem]->AddFont(FontFamilyFlag_None, VirtualDirectories::kFonts, "Fonts/OpenSans/OpenSans-ExtraBold.ttf", 0, FontHacks_None); m_fontFamilies[FontFamilyIDs::kSystem]->AddFont(FontFamilyFlag_None, VirtualDirectories::kFonts, "Fonts/OpenSans/OpenSans-ExtraBold.ttf", 0, FontHacks_None);
@@ -409,6 +412,8 @@ namespace PortabilityLayer
FontManagerImpl::FontPreset FontManagerImpl::ms_fontPresets[FontPresets::kCount] = FontManagerImpl::FontPreset FontManagerImpl::ms_fontPresets[FontPresets::kCount] =
{ {
{ FontFamilyIDs::kSystemSymbols, 12, FontFamilyFlag_None, true },
{ FontFamilyIDs::kSystem, 12, FontFamilyFlag_None, true }, { FontFamilyIDs::kSystem, 12, FontFamilyFlag_None, true },
{ FontFamilyIDs::kSystem, 12, FontFamilyFlag_Bold, true }, { FontFamilyIDs::kSystem, 12, FontFamilyFlag_Bold, true },

View File

@@ -6,6 +6,8 @@ namespace PortabilityLayer
{ {
enum FontPreset enum FontPreset
{ {
kSystemSymbols12,
kSystem12, kSystem12,
kSystem12Bold, kSystem12Bold,

View File

@@ -105,6 +105,7 @@ namespace PortabilityLayer
private: private:
static void SynthesizeBoldAA(IGpFontRenderedGlyph *&glyph, unsigned int xScale, unsigned int yScale, bool aa, uint8_t character, int size, FontHacks fontHacks); static void SynthesizeBoldAA(IGpFontRenderedGlyph *&glyph, unsigned int xScale, unsigned int yScale, bool aa, uint8_t character, int size, FontHacks fontHacks);
static uint16_t ResolveSystemSymbol(uint8_t character);
static FontRendererImpl ms_instance; static FontRendererImpl ms_instance;
}; };
@@ -396,6 +397,10 @@ namespace PortabilityLayer
for (unsigned int i = 0; i < numCharacters; i++) for (unsigned int i = 0; i < numCharacters; i++)
{ {
uint16_t unicodeCodePoint = MacRoman::ToUnicode(i); uint16_t unicodeCodePoint = MacRoman::ToUnicode(i);
if (fontHacks == FontHacks_SystemSymbols)
unicodeCodePoint = ResolveSystemSymbol(i);
if (unicodeCodePoint == 0xffff) if (unicodeCodePoint == 0xffff)
continue; continue;
@@ -668,6 +673,35 @@ namespace PortabilityLayer
glyph = newGlyph; glyph = newGlyph;
} }
uint16_t FontRendererImpl::ResolveSystemSymbol(uint8_t character)
{
// This emulates Chicago system symbol mappings
switch (character)
{
case 0x02: return 0x21e5;
case 0x03: return 0x21e4;
case 0x05: return 0x21e7;
case 0x06: return 0x2303;
case 0x07: return 0x2325;
case 0x0a: return 0x2326;
case 0x0b: return 0x21a9;
case 0x0c: return 0x21aa;
case 0x10: return 0x2193;
case 0x11: return 0x2318;
case 0x12: return 0x27a3;
case 0x13: return 0x25c6;
case 0x14: return 0x2764; // Supposed to be Apple logo but, uh yeah
case 0x17: return 0x232b;
case 0x18: return 0x2190;
case 0x19: return 0x2191;
case 0x1a: return 0x2192;
case 0x1b: return 0x238b;
case 0x1c: return 0x2327;
default:
return 0xffff;
}
}
FontRendererImpl *FontRendererImpl::GetInstance() FontRendererImpl *FontRendererImpl::GetInstance()
{ {
return &ms_instance; return &ms_instance;

View File

@@ -1,9 +1,11 @@
#include "MenuManager.h" #include "MenuManager.h"
#include "CompositeRenderedFont.h"
#include "DisplayDeviceManager.h" #include "DisplayDeviceManager.h"
#include "FontFamily.h" #include "FontFamily.h"
#include "FontManager.h" #include "FontManager.h"
#include "IGpFont.h" #include "IGpFont.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "SimpleGraphic.h" #include "SimpleGraphic.h"
@@ -119,6 +121,8 @@ struct Menu
namespace PortabilityLayer namespace PortabilityLayer
{ {
class CompositeRenderedFont;
class MenuManagerImpl final : public MenuManager class MenuManagerImpl final : public MenuManager
{ {
public: public:
@@ -163,9 +167,6 @@ namespace PortabilityLayer
void RenderFrame(IGpDisplayDriver *displayDriver) override; void RenderFrame(IGpDisplayDriver *displayDriver) override;
void SetMenuTouchScreenStyle(bool isTouchScreen) override;
bool IsMenuTouchScreenStyle() const override;
static MenuManagerImpl *GetInstance(); static MenuManagerImpl *GetInstance();
private: private:
@@ -213,9 +214,7 @@ namespace PortabilityLayer
static const unsigned int kIconResID = 128; static const unsigned int kIconResID = 128;
static const unsigned int kMenuBarIconYOffset = 2; static const unsigned int kMenuBarIconYOffset = 2;
static const unsigned int kMenuBarTextYOffset = 14; static const unsigned int kMenuBarTextYOffset = 14;
static const unsigned int kTouchScreenMenuBarTextYOffset = 40;
static const unsigned int kMenuBarHeight = 20; static const unsigned int kMenuBarHeight = 20;
static const unsigned int kTouchscreenMenuBarHeight = 54;
static const unsigned int kMenuBarItemPadding = 6; static const unsigned int kMenuBarItemPadding = 6;
static const unsigned int kMenuBarInitialPadding = 16; static const unsigned int kMenuBarInitialPadding = 16;
@@ -233,10 +232,9 @@ namespace PortabilityLayer
static const unsigned int kMenuItemLeftPadding = 16 + 2 + 2; // 2 for left border, 16 for icon, 2 for spacing static const unsigned int kMenuItemLeftPadding = 16 + 2 + 2; // 2 for left border, 16 for icon, 2 for spacing
static const int kMenuFontFlags = PortabilityLayer::FontFamilyFlag_Bold; static const int kMenuFontFlags = PortabilityLayer::FontFamilyFlag_Bold;
static const int kTouchScreenMenuFontFlags = PortabilityLayer::FontFamilyFlag_None;
static const FontPreset_t kMenuFontSymbolsPreset = FontPresets::kSystemSymbols12;
static const FontPreset_t kMenuFontPreset = FontPresets::kSystem12Bold; static const FontPreset_t kMenuFontPreset = FontPresets::kSystem12Bold;
static const FontPreset_t kTouchScreenMenuFontPreset = FontPresets::kApplication40;
DrawSurface *m_menuBarGraf; DrawSurface *m_menuBarGraf;
@@ -245,7 +243,6 @@ namespace PortabilityLayer
bool m_haveMenuBarLayout; bool m_haveMenuBarLayout;
bool m_haveIcon; bool m_haveIcon;
bool m_menuBarVisible; bool m_menuBarVisible;
bool m_isTouchScreen;
uint8_t m_iconColors[16 * 16]; uint8_t m_iconColors[16 * 16];
uint8_t m_iconMask[32]; uint8_t m_iconMask[32];
@@ -257,6 +254,7 @@ namespace PortabilityLayer
static const int kHintTextCapacity = 6; static const int kHintTextCapacity = 6;
static size_t FormatHintText(uint8_t *buffer, uint8_t key); static size_t FormatHintText(uint8_t *buffer, uint8_t key);
static CompositeRenderedFont GetMenuTextCompositeFont();
static MenuManagerImpl ms_instance; static MenuManagerImpl ms_instance;
}; };
@@ -267,7 +265,6 @@ namespace PortabilityLayer
, m_haveIcon(false) , m_haveIcon(false)
, m_iconGraphic(nullptr) , m_iconGraphic(nullptr)
, m_menuBarVisible(false) , m_menuBarVisible(false)
, m_isTouchScreen(false)
{ {
} }
@@ -945,7 +942,7 @@ namespace PortabilityLayer
PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance(); PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance();
const int16_t menuHeight = m_isTouchScreen ? kTouchscreenMenuBarHeight : kMenuBarHeight; const int16_t menuHeight = kMenuBarHeight;
const Rect menuRect = Rect::Create(0, 0, menuHeight, width); const Rect menuRect = Rect::Create(0, 0, menuHeight, width);
@@ -1048,18 +1045,9 @@ namespace PortabilityLayer
// Text items // Text items
ResolveCachingColor barNormalTextColor = gs_barNormalTextColor; ResolveCachingColor barNormalTextColor = gs_barNormalTextColor;
PortabilityLayer::RenderedFont *sysFont = nullptr; PortabilityLayer::CompositeRenderedFont sysFont = GetMenuTextCompositeFont();
unsigned int textYOffset = 0;
if (m_isTouchScreen) const unsigned int textYOffset = kMenuBarTextYOffset;
{
sysFont = GetFont(kTouchScreenMenuFontPreset);
textYOffset = kTouchScreenMenuBarTextYOffset;
}
else
{
sysFont = GetFont(kMenuFontPreset);
textYOffset = kMenuBarTextYOffset;
}
{ {
Menu **menuHdl = m_firstMenu; Menu **menuHdl = m_firstMenu;
@@ -1081,7 +1069,7 @@ namespace PortabilityLayer
if (menuHdl != selectedMenuHdl) if (menuHdl != selectedMenuHdl)
{ {
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), textYOffset); const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), textYOffset);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), barNormalTextColor, sysFont); graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), barNormalTextColor, &sysFont);
} }
} }
} }
@@ -1101,7 +1089,7 @@ namespace PortabilityLayer
size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding; size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding;
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), textYOffset); const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), textYOffset);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), barHighlightTextColor, sysFont); graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), barHighlightTextColor, &sysFont);
} }
} }
@@ -1130,15 +1118,8 @@ namespace PortabilityLayer
const PixMap *pixMap = *m_menuBarGraf->m_port.GetPixMap(); const PixMap *pixMap = *m_menuBarGraf->m_port.GetPixMap();
const size_t width = pixMap->m_rect.right - pixMap->m_rect.left; const size_t width = pixMap->m_rect.right - pixMap->m_rect.left;
const size_t height = pixMap->m_rect.bottom - pixMap->m_rect.top; const size_t height = pixMap->m_rect.bottom - pixMap->m_rect.top;
int32_t y = 0;
if (m_isTouchScreen) displayDriver->DrawSurface(m_menuBarGraf->m_ddSurface, 0, 0, width, height, nullptr);
{
unsigned int displayHeight = WindowManager::GetInstance()->GetDisplayResolution().m_y;
y = static_cast<int32_t>(displayHeight) - kTouchscreenMenuBarHeight;
}
displayDriver->DrawSurface(m_menuBarGraf->m_ddSurface, 0, y, width, height, nullptr);
} }
} }
@@ -1167,16 +1148,6 @@ namespace PortabilityLayer
} }
} }
void MenuManagerImpl::SetMenuTouchScreenStyle(bool isTouchScreenStyle)
{
m_isTouchScreen = isTouchScreenStyle;
}
bool MenuManagerImpl::IsMenuTouchScreenStyle() const
{
return m_isTouchScreen;
}
void MenuManagerImpl::RefreshMenuBarLayout() void MenuManagerImpl::RefreshMenuBarLayout()
{ {
if (m_haveMenuBarLayout) if (m_haveMenuBarLayout)
@@ -1184,19 +1155,7 @@ namespace PortabilityLayer
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance(); PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::RenderedFont *rfont = nullptr; PortabilityLayer::CompositeRenderedFont sysFont = GetMenuTextCompositeFont();
PortabilityLayer::FontFamily *fontFamily = nullptr;
unsigned int fontSize = 0;
unsigned int fontFlags = 0;
if (m_isTouchScreen)
rfont = GetFont(kTouchScreenMenuFontPreset);
else
rfont = GetFont(kMenuFontPreset);
if (!rfont)
return;
unsigned int index = 0; unsigned int index = 0;
size_t measuredWidth = 0; size_t measuredWidth = 0;
@@ -1217,7 +1176,7 @@ namespace PortabilityLayer
menu->isIcon = true; menu->isIcon = true;
} }
else else
menu->unpaddedTitleWidth = rfont->MeasureString(pascalStr.UChars(), pascalStr.Length()); menu->unpaddedTitleWidth = sysFont.MeasureString(pascalStr.UChars(), pascalStr.Length());
measuredWidth += menu->unpaddedTitleWidth; measuredWidth += menu->unpaddedTitleWidth;
@@ -1234,9 +1193,7 @@ namespace PortabilityLayer
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance(); PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::RenderedFont *rfont = GetFont(kMenuFontPreset); PortabilityLayer::CompositeRenderedFont rfont = GetMenuTextCompositeFont();
if (!rfont)
return;
const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents); const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents);
@@ -1258,7 +1215,7 @@ namespace PortabilityLayer
const uint8_t *itemName = strBlob + item.nameOffsetInStringBlob; const uint8_t *itemName = strBlob + item.nameOffsetInStringBlob;
const PLPasStr itemNamePStr = PLPasStr(itemName); const PLPasStr itemNamePStr = PLPasStr(itemName);
const size_t nameWidth = rfont->MeasureString(itemNamePStr.UChars(), itemNamePStr.Length()); const size_t nameWidth = rfont.MeasureString(itemNamePStr.UChars(), itemNamePStr.Length());
const size_t paddedWidth = nameWidth + kMenuItemLeftPadding + kMenuItemRightPadding; const size_t paddedWidth = nameWidth + kMenuItemLeftPadding + kMenuItemRightPadding;
@@ -1270,7 +1227,7 @@ namespace PortabilityLayer
{ {
uint8_t hintText[kHintTextCapacity]; uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key); const size_t hintLength = FormatHintText(hintText, item.key);
hintWidth = std::max<size_t>(rfont->MeasureString(hintText, hintLength) + kMenuItemRightPadding, hintWidth); hintWidth = std::max<size_t>(rfont.MeasureString(hintText, hintLength) + kMenuItemRightPadding, hintWidth);
} }
} }
@@ -1386,13 +1343,7 @@ namespace PortabilityLayer
bool MenuManagerImpl::IsYInMenuBarRange(int32_t y) const bool MenuManagerImpl::IsYInMenuBarRange(int32_t y) const
{ {
if (m_isTouchScreen) return y >= 0 && y < static_cast<int32_t>(kMenuBarHeight);
{
unsigned int displayHeight = WindowManager::GetInstance()->GetDisplayResolution().m_y;
return y >= (static_cast<int32_t>(displayHeight - kTouchscreenMenuBarHeight)) && y < static_cast<int32_t>(displayHeight);
}
else
return y >= 0 && y < static_cast<int32_t>(kMenuBarHeight);
} }
bool MenuManagerImpl::ItemIsSeparator(const Menu &menu, const MenuItem &item) bool MenuManagerImpl::ItemIsSeparator(const Menu &menu, const MenuItem &item)
@@ -1405,14 +1356,31 @@ namespace PortabilityLayer
size_t MenuManagerImpl::FormatHintText(uint8_t *buffer, uint8_t key) size_t MenuManagerImpl::FormatHintText(uint8_t *buffer, uint8_t key)
{ {
buffer[0] = 'C'; if (PLDrivers::GetSystemServices()->GetOperatingSystem() == GpOperatingSystems::kMacOS)
buffer[1] = 't'; {
buffer[2] = 'r'; buffer[0] = 0x11; // Command symbol
buffer[3] = 'l'; buffer[1] = key;
buffer[4] = '+'; return 2;
buffer[5] = key; }
else
{
buffer[0] = 'C';
buffer[1] = 't';
buffer[2] = 'r';
buffer[3] = 'l';
buffer[4] = '+';
buffer[5] = key;
return 6;
}
}
return 6;
CompositeRenderedFont MenuManagerImpl::GetMenuTextCompositeFont()
{
PortabilityLayer::RenderedFont *sysFont = GetFont(kMenuFontPreset);
PortabilityLayer::RenderedFont *symbolsFont = GetFont(kMenuFontSymbolsPreset);
return CompositeRenderedFont(symbolsFont, sysFont);
} }
MenuManagerImpl *MenuManagerImpl::GetInstance() MenuManagerImpl *MenuManagerImpl::GetInstance()
@@ -1580,7 +1548,7 @@ namespace PortabilityLayer
surface->FillRect(Rect::Create(static_cast<int16_t>(menu->layoutFinalHeight - 1), 1, static_cast<int16_t>(menu->layoutFinalHeight), static_cast<int16_t>(menu->layoutWidth - 1)), darkGrayColor); surface->FillRect(Rect::Create(static_cast<int16_t>(menu->layoutFinalHeight - 1), 1, static_cast<int16_t>(menu->layoutFinalHeight), static_cast<int16_t>(menu->layoutWidth - 1)), darkGrayColor);
} }
PortabilityLayer::RenderedFont *sysFont = GetFont(kMenuFontPreset); PortabilityLayer::CompositeRenderedFont compositeFont = GetMenuTextCompositeFont();
const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents); const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents);
@@ -1611,7 +1579,7 @@ namespace PortabilityLayer
else else
itemTextAndCheckColor = gs_barDisabledTextColor; itemTextAndCheckColor = gs_barDisabledTextColor;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), itemTextAndCheckColor, sysFont); surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), itemTextAndCheckColor, &compositeFont);
if (item.key) if (item.key)
{ {
@@ -1619,7 +1587,7 @@ namespace PortabilityLayer
uint8_t hintText[kHintTextCapacity]; uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key); const size_t hintLength = FormatHintText(hintText, item.key);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), itemTextAndCheckColor, sysFont); surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), itemTextAndCheckColor, &compositeFont);
} }
if (item.checked) if (item.checked)
@@ -1651,7 +1619,7 @@ namespace PortabilityLayer
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset; itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), barHighlightTextColor, sysFont); surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), barHighlightTextColor, &compositeFont);
if (item.key) if (item.key)
{ {
@@ -1659,7 +1627,7 @@ namespace PortabilityLayer
uint8_t hintText[kHintTextCapacity]; uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key); const size_t hintLength = FormatHintText(hintText, item.key);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), barHighlightTextColor, sysFont); surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), barHighlightTextColor, &compositeFont);
if (item.checked) if (item.checked)
surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset), barHighlightTextColor); surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset), barHighlightTextColor);

View File

@@ -58,9 +58,6 @@ namespace PortabilityLayer
virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0; virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0;
virtual void SetMenuTouchScreenStyle(bool isTouchScreenStyle) = 0;
virtual bool IsMenuTouchScreenStyle() const = 0;
static MenuManager *GetInstance(); static MenuManager *GetInstance();
}; };
} }

View File

@@ -93,6 +93,7 @@
<ClInclude Include="ByteUnpack.h" /> <ClInclude Include="ByteUnpack.h" />
<ClInclude Include="CFileStream.h" /> <ClInclude Include="CFileStream.h" />
<ClInclude Include="CombinedTimestamp.h" /> <ClInclude Include="CombinedTimestamp.h" />
<ClInclude Include="CompositeRenderedFont.h" />
<ClInclude Include="DataTypes.h" /> <ClInclude Include="DataTypes.h" />
<ClInclude Include="DeflateCodec.h" /> <ClInclude Include="DeflateCodec.h" />
<ClInclude Include="DialogManager.h" /> <ClInclude Include="DialogManager.h" />
@@ -226,6 +227,7 @@
<ClCompile Include="BitmapImage.cpp" /> <ClCompile Include="BitmapImage.cpp" />
<ClCompile Include="ByteSwap.cpp" /> <ClCompile Include="ByteSwap.cpp" />
<ClCompile Include="CFileStream.cpp" /> <ClCompile Include="CFileStream.cpp" />
<ClCompile Include="CompositeRenderedFont.cpp" />
<ClCompile Include="DeflateCodec.cpp" /> <ClCompile Include="DeflateCodec.cpp" />
<ClCompile Include="DialogManager.cpp" /> <ClCompile Include="DialogManager.cpp" />
<ClCompile Include="DisplayDeviceManager.cpp" /> <ClCompile Include="DisplayDeviceManager.cpp" />

View File

@@ -426,6 +426,9 @@
<ClInclude Include="FontPresets.h"> <ClInclude Include="FontPresets.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CompositeRenderedFont.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CFileStream.cpp"> <ClCompile Include="CFileStream.cpp">
@@ -683,5 +686,8 @@
<ClCompile Include="InflateStream.cpp"> <ClCompile Include="InflateStream.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CompositeRenderedFont.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1476,7 +1476,7 @@ namespace PortabilityLayer
logger->Printf(IGpLogDriver::Category_Information, "WindowManagerImpl: Resizing from %ix%i to %ix%i", static_cast<int>(prevWidth), static_cast<int>(prevHeight), static_cast<int>(newWidth), static_cast<int>(newHeight)); logger->Printf(IGpLogDriver::Category_Information, "WindowManagerImpl: Resizing from %ix%i to %ix%i", static_cast<int>(prevWidth), static_cast<int>(prevHeight), static_cast<int>(newWidth), static_cast<int>(newHeight));
const uint32_t menuBarHeight = PortabilityLayer::MenuManager::GetInstance()->GetMenuBarHeight(); const uint32_t menuBarHeight = PortabilityLayer::MenuManager::GetInstance()->GetMenuBarHeight();
const bool menuIsTouchScreen = PortabilityLayer::MenuManager::GetInstance()->IsMenuTouchScreenStyle(); const bool menuIsTouchScreen = false; //PortabilityLayer::MenuManager::GetInstance()->IsMenuTouchScreenStyle();
for (PortabilityLayer::WindowImpl *window = m_windowStackTop; window != nullptr; window = window->GetWindowBelow()) for (PortabilityLayer::WindowImpl *window = m_windowStackTop; window != nullptr; window = window->GetWindowBelow())
{ {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,93 @@
Copyright (c) 2016-2019 The Inter Project Authors (me@rsms.me)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -0,0 +1,72 @@
Inter Variable Font
===================
This download contains Inter as both a variable font and static fonts.
Inter is a variable font with these axes:
slnt
wght
This means all the styles are contained in a single file:
Inter-VariableFont_slnt,wght.ttf
If your app fully supports variable fonts, you can now pick intermediate styles
that arent available as static fonts. Not all apps support variable fonts, and
in those cases you can use the static font files for Inter:
static/Inter-Thin.ttf
static/Inter-ExtraLight.ttf
static/Inter-Light.ttf
static/Inter-Regular.ttf
static/Inter-Medium.ttf
static/Inter-SemiBold.ttf
static/Inter-Bold.ttf
static/Inter-ExtraBold.ttf
static/Inter-Black.ttf
Get started
-----------
1. Install the font files you want to use
2. Use your app's font picker to view the font family and all the
available styles
Learn more about variable fonts
-------------------------------
https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
https://variablefonts.typenetwork.com
https://medium.com/variable-fonts
In desktop apps
https://theblog.adobe.com/can-variable-fonts-illustrator-cc
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts
Online
https://developers.google.com/fonts/docs/getting_started
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts
Installing fonts
MacOS: https://support.apple.com/en-us/HT201749
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows
Android Apps
https://developers.google.com/fonts/docs/android
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
License
-------
Please read the full license text (OFL.txt) to understand the permissions,
restrictions and requirements for usage, redistribution, and modification.
You can use them freely in your products & projects - print or digital,
commercial or otherwise. However, you can't sell the fonts on their own.
This isn't legal advice, please consider consulting a lawyer and see the full
license for all details.