diff --git a/ApplicationResourcePatches/DITL/2005.json b/ApplicationResourcePatches/DITL/2005.json index 70c769f..dcb1d44 100644 --- a/ApplicationResourcePatches/DITL/2005.json +++ b/ApplicationResourcePatches/DITL/2005.json @@ -4,7 +4,7 @@ { "name" : "Okay", "itemType" : "Button", - "pos" : [ 438, 292 ], + "pos" : [ 438, 316 ], "size" : [ 58, 20 ], "id" : 1, "enabled" : true @@ -12,7 +12,7 @@ { "name" : "Export Source Code to ZIP Archive...", "itemType" : "Button", - "pos" : [ 205, 292 ], + "pos" : [ 205, 316 ], "size" : [ 226, 20 ], "id" : 1, "enabled" : false @@ -98,7 +98,7 @@ "enabled" : true }, { - "name" : "LIBICONV ©1999-2001, 2016 Free Software Foundation, Inc.", + "name" : "Inter font ©2016-2019 Rasmus Andersson + Inter Project Authors", "itemType" : "Label", "pos" : [ 16, 149 ], "size" : [ 406, 20 ], @@ -114,7 +114,7 @@ "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", "pos" : [ 16, 172 ], "size" : [ 406, 28 ], @@ -130,7 +130,7 @@ "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", "pos" : [ 16, 205 ], "size" : [ 406, 20 ], @@ -146,7 +146,7 @@ "enabled" : true }, { - "name" : "FreeType ©2020 The FreeType Project", + "name" : "zlib ©1995-2017 Jean-loup Gailly and Mark Adler", "itemType" : "Label", "pos" : [ 16, 229 ], "size" : [ 406, 20 ], @@ -162,7 +162,7 @@ "enabled" : true }, { - "name" : "Simple DirectMedia Layer ©1997-2020 Sam Lantinga", + "name" : "FreeType ©2020 The FreeType Project", "itemType" : "Label", "pos" : [ 16, 253 ], "size" : [ 406, 20 ], @@ -176,6 +176,22 @@ "size" : [ 66, 20 ], "id" : 1, "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 } ] } \ No newline at end of file diff --git a/GpApp/About.cpp b/GpApp/About.cpp index f42826c..12a3d0f 100644 --- a/GpApp/About.cpp +++ b/GpApp/About.cpp @@ -233,11 +233,12 @@ void DoAboutOpenSource(void) static const int kOpenSansLicenseButton = 8; static const int kRobotoMonoLicenseButton = 10; static const int kGochiHandLicenseButton = 12; - static const int kLibIConvLicenseButton = 14; - static const int kRapidJSONLicenseButton = 16; - static const int kZLibLicenseButton = 18; - static const int kFreeTypeLicenseButton = 20; - static const int kSDLLicenseButton = 22; + static const int kInterLicenseButton = 14; + static const int kLibIConvLicenseButton = 16; + static const int kRapidJSONLicenseButton = 18; + static const int kZLibLicenseButton = 20; + static const int kFreeTypeLicenseButton = 22; + static const int kSDLLicenseButton = 24; static const int kLicenseResourceApache = 1000; static const int kLicenseResourceGPLv2 = 1001; @@ -249,7 +250,7 @@ void DoAboutOpenSource(void) 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("")); @@ -281,6 +282,7 @@ void DoAboutOpenSource(void) DoLicenseReader(kLicenseResourceApache); break; case kGochiHandLicenseButton: + case kInterLicenseButton: DoLicenseReader(kLicenseResourceOFL); break; case kLibIConvLicenseButton: diff --git a/GpApp/Main.cpp b/GpApp/Main.cpp index 9d3caf2..093cfd3 100644 --- a/GpApp/Main.cpp +++ b/GpApp/Main.cpp @@ -537,9 +537,6 @@ int AppStartup() ToolBoxInit(); CheckOurEnvirons(); - if (thisMac.isTouchscreen) - PortabilityLayer::MenuManager::GetInstance()->SetMenuTouchScreenStyle(true); - if (!thisMac.hasColor) RedAlert(kErrNeedColorQD); if (!thisMac.hasSystem7) @@ -686,4 +683,4 @@ int gpAppMain() HandleEvent(); return AppShutdown(); -} \ No newline at end of file +} diff --git a/PortabilityLayer/CompositeRenderedFont.cpp b/PortabilityLayer/CompositeRenderedFont.cpp new file mode 100644 index 0000000..dbad88b --- /dev/null +++ b/PortabilityLayer/CompositeRenderedFont.cpp @@ -0,0 +1,64 @@ +#include "CompositeRenderedFont.h" +#include "GpRenderedFontMetrics.h" +#include "GpRenderedGlyphMetrics.h" + +#include + +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(measure); +} + +bool PortabilityLayer::CompositeRenderedFont::IsAntiAliased() const +{ + return m_font->IsAntiAliased(); +} + +void PortabilityLayer::CompositeRenderedFont::Destroy() +{ + assert(false); +} diff --git a/PortabilityLayer/CompositeRenderedFont.h b/PortabilityLayer/CompositeRenderedFont.h new file mode 100644 index 0000000..477c70b --- /dev/null +++ b/PortabilityLayer/CompositeRenderedFont.h @@ -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; + }; +} diff --git a/PortabilityLayer/FontFamilyID.h b/PortabilityLayer/FontFamilyID.h index 4f5dd16..c79822a 100644 --- a/PortabilityLayer/FontFamilyID.h +++ b/PortabilityLayer/FontFamilyID.h @@ -6,6 +6,7 @@ namespace PortabilityLayer { enum FontFamilyID { + kSystemSymbols, kSystem, kApplication, kMonospace, diff --git a/PortabilityLayer/FontHacks.h b/PortabilityLayer/FontHacks.h index c9a06b0..94534ec 100644 --- a/PortabilityLayer/FontHacks.h +++ b/PortabilityLayer/FontHacks.h @@ -7,5 +7,6 @@ namespace PortabilityLayer FontHacks_None, FontHacks_Roboto, FontHacks_SyntheticBold_OpenSans, + FontHacks_SystemSymbols, }; } diff --git a/PortabilityLayer/FontManager.cpp b/PortabilityLayer/FontManager.cpp index 0483878..3043870 100644 --- a/PortabilityLayer/FontManager.cpp +++ b/PortabilityLayer/FontManager.cpp @@ -91,6 +91,9 @@ namespace PortabilityLayer for (int i = 0; i < FontFamilyIDs::kCount; i++) m_fontFamilies[static_cast(i)] = FontFamily::Create(static_cast(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]) 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] = { + { FontFamilyIDs::kSystemSymbols, 12, FontFamilyFlag_None, true }, + { FontFamilyIDs::kSystem, 12, FontFamilyFlag_None, true }, { FontFamilyIDs::kSystem, 12, FontFamilyFlag_Bold, true }, diff --git a/PortabilityLayer/FontPresets.h b/PortabilityLayer/FontPresets.h index 33257a0..67cc9a9 100644 --- a/PortabilityLayer/FontPresets.h +++ b/PortabilityLayer/FontPresets.h @@ -6,6 +6,8 @@ namespace PortabilityLayer { enum FontPreset { + kSystemSymbols12, + kSystem12, kSystem12Bold, diff --git a/PortabilityLayer/FontRenderer.cpp b/PortabilityLayer/FontRenderer.cpp index 82c6c90..25425ca 100644 --- a/PortabilityLayer/FontRenderer.cpp +++ b/PortabilityLayer/FontRenderer.cpp @@ -105,6 +105,7 @@ namespace PortabilityLayer private: 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; }; @@ -396,6 +397,10 @@ namespace PortabilityLayer for (unsigned int i = 0; i < numCharacters; i++) { uint16_t unicodeCodePoint = MacRoman::ToUnicode(i); + + if (fontHacks == FontHacks_SystemSymbols) + unicodeCodePoint = ResolveSystemSymbol(i); + if (unicodeCodePoint == 0xffff) continue; @@ -668,6 +673,35 @@ namespace PortabilityLayer 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() { return &ms_instance; diff --git a/PortabilityLayer/MenuManager.cpp b/PortabilityLayer/MenuManager.cpp index e55e6f7..701798e 100644 --- a/PortabilityLayer/MenuManager.cpp +++ b/PortabilityLayer/MenuManager.cpp @@ -1,9 +1,11 @@ #include "MenuManager.h" +#include "CompositeRenderedFont.h" #include "DisplayDeviceManager.h" #include "FontFamily.h" #include "FontManager.h" #include "IGpFont.h" #include "IGpDisplayDriver.h" +#include "IGpSystemServices.h" #include "MemoryManager.h" #include "ResourceManager.h" #include "SimpleGraphic.h" @@ -119,6 +121,8 @@ struct Menu namespace PortabilityLayer { + class CompositeRenderedFont; + class MenuManagerImpl final : public MenuManager { public: @@ -163,9 +167,6 @@ namespace PortabilityLayer void RenderFrame(IGpDisplayDriver *displayDriver) override; - void SetMenuTouchScreenStyle(bool isTouchScreen) override; - bool IsMenuTouchScreenStyle() const override; - static MenuManagerImpl *GetInstance(); private: @@ -213,9 +214,7 @@ namespace PortabilityLayer static const unsigned int kIconResID = 128; static const unsigned int kMenuBarIconYOffset = 2; static const unsigned int kMenuBarTextYOffset = 14; - static const unsigned int kTouchScreenMenuBarTextYOffset = 40; static const unsigned int kMenuBarHeight = 20; - static const unsigned int kTouchscreenMenuBarHeight = 54; static const unsigned int kMenuBarItemPadding = 6; 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 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 kTouchScreenMenuFontPreset = FontPresets::kApplication40; DrawSurface *m_menuBarGraf; @@ -245,7 +243,6 @@ namespace PortabilityLayer bool m_haveMenuBarLayout; bool m_haveIcon; bool m_menuBarVisible; - bool m_isTouchScreen; uint8_t m_iconColors[16 * 16]; uint8_t m_iconMask[32]; @@ -257,6 +254,7 @@ namespace PortabilityLayer static const int kHintTextCapacity = 6; static size_t FormatHintText(uint8_t *buffer, uint8_t key); + static CompositeRenderedFont GetMenuTextCompositeFont(); static MenuManagerImpl ms_instance; }; @@ -267,7 +265,6 @@ namespace PortabilityLayer , m_haveIcon(false) , m_iconGraphic(nullptr) , m_menuBarVisible(false) - , m_isTouchScreen(false) { } @@ -945,7 +942,7 @@ namespace PortabilityLayer 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); @@ -1048,18 +1045,9 @@ namespace PortabilityLayer // Text items ResolveCachingColor barNormalTextColor = gs_barNormalTextColor; - PortabilityLayer::RenderedFont *sysFont = nullptr; - unsigned int textYOffset = 0; - if (m_isTouchScreen) - { - sysFont = GetFont(kTouchScreenMenuFontPreset); - textYOffset = kTouchScreenMenuBarTextYOffset; - } - else - { - sysFont = GetFont(kMenuFontPreset); - textYOffset = kMenuBarTextYOffset; - } + PortabilityLayer::CompositeRenderedFont sysFont = GetMenuTextCompositeFont(); + + const unsigned int textYOffset = kMenuBarTextYOffset; { Menu **menuHdl = m_firstMenu; @@ -1081,7 +1069,7 @@ namespace PortabilityLayer if (menuHdl != selectedMenuHdl) { const Point itemPos = Point::Create(static_cast(xCoordinate), textYOffset); - graf->DrawString(itemPos, PLPasStr(static_cast(menu->stringBlobHandle->m_contents)), barNormalTextColor, sysFont); + graf->DrawString(itemPos, PLPasStr(static_cast(menu->stringBlobHandle->m_contents)), barNormalTextColor, &sysFont); } } } @@ -1101,7 +1089,7 @@ namespace PortabilityLayer size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding; const Point itemPos = Point::Create(static_cast(xCoordinate), textYOffset); - graf->DrawString(itemPos, PLPasStr(static_cast(menu->stringBlobHandle->m_contents)), barHighlightTextColor, sysFont); + graf->DrawString(itemPos, PLPasStr(static_cast(menu->stringBlobHandle->m_contents)), barHighlightTextColor, &sysFont); } } @@ -1130,15 +1118,8 @@ namespace PortabilityLayer const PixMap *pixMap = *m_menuBarGraf->m_port.GetPixMap(); const size_t width = pixMap->m_rect.right - pixMap->m_rect.left; const size_t height = pixMap->m_rect.bottom - pixMap->m_rect.top; - int32_t y = 0; - if (m_isTouchScreen) - { - unsigned int displayHeight = WindowManager::GetInstance()->GetDisplayResolution().m_y; - y = static_cast(displayHeight) - kTouchscreenMenuBarHeight; - } - - displayDriver->DrawSurface(m_menuBarGraf->m_ddSurface, 0, y, width, height, nullptr); + displayDriver->DrawSurface(m_menuBarGraf->m_ddSurface, 0, 0, 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() { if (m_haveMenuBarLayout) @@ -1184,19 +1155,7 @@ namespace PortabilityLayer PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance(); - PortabilityLayer::RenderedFont *rfont = nullptr; - 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; + PortabilityLayer::CompositeRenderedFont sysFont = GetMenuTextCompositeFont(); unsigned int index = 0; size_t measuredWidth = 0; @@ -1217,7 +1176,7 @@ namespace PortabilityLayer menu->isIcon = true; } else - menu->unpaddedTitleWidth = rfont->MeasureString(pascalStr.UChars(), pascalStr.Length()); + menu->unpaddedTitleWidth = sysFont.MeasureString(pascalStr.UChars(), pascalStr.Length()); measuredWidth += menu->unpaddedTitleWidth; @@ -1234,9 +1193,7 @@ namespace PortabilityLayer PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance(); - PortabilityLayer::RenderedFont *rfont = GetFont(kMenuFontPreset); - if (!rfont) - return; + PortabilityLayer::CompositeRenderedFont rfont = GetMenuTextCompositeFont(); const uint8_t *strBlob = static_cast(menu->stringBlobHandle->m_contents); @@ -1258,7 +1215,7 @@ namespace PortabilityLayer const uint8_t *itemName = strBlob + item.nameOffsetInStringBlob; 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; @@ -1270,7 +1227,7 @@ namespace PortabilityLayer { uint8_t hintText[kHintTextCapacity]; const size_t hintLength = FormatHintText(hintText, item.key); - hintWidth = std::max(rfont->MeasureString(hintText, hintLength) + kMenuItemRightPadding, hintWidth); + hintWidth = std::max(rfont.MeasureString(hintText, hintLength) + kMenuItemRightPadding, hintWidth); } } @@ -1386,13 +1343,7 @@ namespace PortabilityLayer bool MenuManagerImpl::IsYInMenuBarRange(int32_t y) const { - if (m_isTouchScreen) - { - unsigned int displayHeight = WindowManager::GetInstance()->GetDisplayResolution().m_y; - return y >= (static_cast(displayHeight - kTouchscreenMenuBarHeight)) && y < static_cast(displayHeight); - } - else - return y >= 0 && y < static_cast(kMenuBarHeight); + return y >= 0 && y < static_cast(kMenuBarHeight); } 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) { - buffer[0] = 'C'; - buffer[1] = 't'; - buffer[2] = 'r'; - buffer[3] = 'l'; - buffer[4] = '+'; - buffer[5] = key; + if (PLDrivers::GetSystemServices()->GetOperatingSystem() == GpOperatingSystems::kMacOS) + { + buffer[0] = 0x11; // Command symbol + buffer[1] = key; + return 2; + } + 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() @@ -1580,7 +1548,7 @@ namespace PortabilityLayer surface->FillRect(Rect::Create(static_cast(menu->layoutFinalHeight - 1), 1, static_cast(menu->layoutFinalHeight), static_cast(menu->layoutWidth - 1)), darkGrayColor); } - PortabilityLayer::RenderedFont *sysFont = GetFont(kMenuFontPreset); + PortabilityLayer::CompositeRenderedFont compositeFont = GetMenuTextCompositeFont(); const uint8_t *strBlob = static_cast(menu->stringBlobHandle->m_contents); @@ -1611,7 +1579,7 @@ namespace PortabilityLayer else itemTextAndCheckColor = gs_barDisabledTextColor; - surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), itemTextAndCheckColor, sysFont); + surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), itemTextAndCheckColor, &compositeFont); if (item.key) { @@ -1619,7 +1587,7 @@ namespace PortabilityLayer uint8_t hintText[kHintTextCapacity]; const size_t hintLength = FormatHintText(hintText, item.key); - surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast(hintText)), itemTextAndCheckColor, sysFont); + surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast(hintText)), itemTextAndCheckColor, &compositeFont); } if (item.checked) @@ -1651,7 +1619,7 @@ namespace PortabilityLayer 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) { @@ -1659,7 +1627,7 @@ namespace PortabilityLayer uint8_t hintText[kHintTextCapacity]; const size_t hintLength = FormatHintText(hintText, item.key); - surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast(hintText)), barHighlightTextColor, sysFont); + surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast(hintText)), barHighlightTextColor, &compositeFont); if (item.checked) surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset), barHighlightTextColor); diff --git a/PortabilityLayer/MenuManager.h b/PortabilityLayer/MenuManager.h index f3d93e5..38098cd 100644 --- a/PortabilityLayer/MenuManager.h +++ b/PortabilityLayer/MenuManager.h @@ -58,9 +58,6 @@ namespace PortabilityLayer virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0; - virtual void SetMenuTouchScreenStyle(bool isTouchScreenStyle) = 0; - virtual bool IsMenuTouchScreenStyle() const = 0; - static MenuManager *GetInstance(); }; } diff --git a/PortabilityLayer/PortabilityLayer.vcxproj b/PortabilityLayer/PortabilityLayer.vcxproj index ab2bac6..8e1479c 100644 --- a/PortabilityLayer/PortabilityLayer.vcxproj +++ b/PortabilityLayer/PortabilityLayer.vcxproj @@ -93,6 +93,7 @@ + @@ -226,6 +227,7 @@ + diff --git a/PortabilityLayer/PortabilityLayer.vcxproj.filters b/PortabilityLayer/PortabilityLayer.vcxproj.filters index ecf6b7c..ea5733e 100644 --- a/PortabilityLayer/PortabilityLayer.vcxproj.filters +++ b/PortabilityLayer/PortabilityLayer.vcxproj.filters @@ -426,6 +426,9 @@ Header Files + + Header Files + @@ -683,5 +686,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/PortabilityLayer/WindowManager.cpp b/PortabilityLayer/WindowManager.cpp index 2b7f512..31d26a5 100644 --- a/PortabilityLayer/WindowManager.cpp +++ b/PortabilityLayer/WindowManager.cpp @@ -1476,7 +1476,7 @@ namespace PortabilityLayer logger->Printf(IGpLogDriver::Category_Information, "WindowManagerImpl: Resizing from %ix%i to %ix%i", static_cast(prevWidth), static_cast(prevHeight), static_cast(newWidth), static_cast(newHeight)); 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()) { diff --git a/Resources/Fonts/Inter/Inter-Black.ttf b/Resources/Fonts/Inter/Inter-Black.ttf new file mode 100644 index 0000000..5653757 Binary files /dev/null and b/Resources/Fonts/Inter/Inter-Black.ttf differ diff --git a/Resources/Fonts/Inter/Inter-Bold.ttf b/Resources/Fonts/Inter/Inter-Bold.ttf new file mode 100644 index 0000000..e98b84c Binary files /dev/null and b/Resources/Fonts/Inter/Inter-Bold.ttf differ diff --git a/Resources/Fonts/Inter/Inter-ExtraBold.ttf b/Resources/Fonts/Inter/Inter-ExtraBold.ttf new file mode 100644 index 0000000..7f16a0f Binary files /dev/null and b/Resources/Fonts/Inter/Inter-ExtraBold.ttf differ diff --git a/Resources/Fonts/Inter/Inter-ExtraLight.ttf b/Resources/Fonts/Inter/Inter-ExtraLight.ttf new file mode 100644 index 0000000..69426a3 Binary files /dev/null and b/Resources/Fonts/Inter/Inter-ExtraLight.ttf differ diff --git a/Resources/Fonts/Inter/Inter-Light.ttf b/Resources/Fonts/Inter/Inter-Light.ttf new file mode 100644 index 0000000..a5f0736 Binary files /dev/null and b/Resources/Fonts/Inter/Inter-Light.ttf differ diff --git a/Resources/Fonts/Inter/Inter-Medium.ttf b/Resources/Fonts/Inter/Inter-Medium.ttf new file mode 100644 index 0000000..721147d Binary files /dev/null and b/Resources/Fonts/Inter/Inter-Medium.ttf differ diff --git a/Resources/Fonts/Inter/Inter-Regular.ttf b/Resources/Fonts/Inter/Inter-Regular.ttf new file mode 100644 index 0000000..96fd6a1 Binary files /dev/null and b/Resources/Fonts/Inter/Inter-Regular.ttf differ diff --git a/Resources/Fonts/Inter/Inter-SemiBold.ttf b/Resources/Fonts/Inter/Inter-SemiBold.ttf new file mode 100644 index 0000000..ddb2792 Binary files /dev/null and b/Resources/Fonts/Inter/Inter-SemiBold.ttf differ diff --git a/Resources/Fonts/Inter/Inter-Thin.ttf b/Resources/Fonts/Inter/Inter-Thin.ttf new file mode 100644 index 0000000..76be625 Binary files /dev/null and b/Resources/Fonts/Inter/Inter-Thin.ttf differ diff --git a/Resources/Fonts/Inter/OFL.txt b/Resources/Fonts/Inter/OFL.txt new file mode 100644 index 0000000..ce049ad --- /dev/null +++ b/Resources/Fonts/Inter/OFL.txt @@ -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. diff --git a/Resources/Fonts/Inter/README.txt b/Resources/Fonts/Inter/README.txt new file mode 100644 index 0000000..b621edf --- /dev/null +++ b/Resources/Fonts/Inter/README.txt @@ -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 aren’t 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.