Skip to content

Commit

Permalink
On windows, use OS Lato if available (#5012)
Browse files Browse the repository at this point in the history
JUCE uses GDI for memory fonts and D2D for OS fonts
so install Lato and detect if it is there and use that
rather than memory font on Win to improve font rendering
of Lato labels on Win. Noop on mac/lin.

Closes #4856
  • Loading branch information
baconpaul authored Sep 7, 2021
1 parent 8081620 commit 69f92c4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/installer_win/surge-x86.iss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Name: Data; Description: Data Files; Types: full compact custom; Flags: fixed

[Files]
Source: {#SURGE_SRC}\resources\data\*; DestDir: {commonappdata}\Surge XT\; Components: Data; Flags: recursesubdirs; Excludes: "*.git,windows.wt,configuration.xml,paramdocumentation.xml";

Source: {#SURGE_SRC}\resources\fonts\Lato-Regular.ttf; DestDir: "{fonts}"; Components: Data; FontInstall: "Lato"; Flags: onlyifdoesntexist uninsneveruninstall
;; these lines are used by Azure pipelines - if you want to build the installer locally, comment them out!
Source: {#SURGE_BIN}\surge_xt_products\Surge XT (32-bit).vst3\*; DestDir: {commoncf32}\VST3\Surge Synth Team\; Components: VST3; Flags: ignoreversion recursesubdirs
Source: {#SURGE_BIN}\surge_xt_products\Surge XT Effects (32-bit).vst3\*; DestDir: {commoncf32}\VST3\Surge Synth Team\; Components: EffectsVST3; Flags: ignoreversion skipifsourcedoesntexist recursesubdirs
Expand Down
1 change: 1 addition & 0 deletions scripts/installer_win/surge.iss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Name: Data; Description: Data Files; Types: full compact custom; Flags: fixed

[Files]
Source: {#SURGE_SRC}\resources\data\*; DestDir: {commonappdata}\Surge XT\; Components: Data; Flags: recursesubdirs; Excludes: "*.git,windows.wt,configuration.xml,paramdocumentation.xml";
Source: {#SURGE_SRC}\resources\fonts\Lato-Regular.ttf; DestDir: "{fonts}"; Components: Data; FontInstall: "Lato"; Flags: onlyifdoesntexist uninsneveruninstall
Source: {#SURGE_BIN}\surge_xt_products\Surge XT.vst3\*; DestDir: {commoncf64}\VST3\Surge Synth Team\; Components: VST3; Flags: ignoreversion recursesubdirs
Source: {#SURGE_BIN}\surge_xt_products\Surge XT Effects.vst3\*; DestDir: {commoncf64}\VST3\Surge Synth Team\; Components: EffectsVST3; Flags: ignoreversion skipifsourcedoesntexist recursesubdirs
Source: {#SURGE_BIN}\surge_xt_products\Surge XT.exe; DestDir: {commonpf64}\Surge Synth Team\; Components: SA; Flags: ignoreversion
Expand Down
20 changes: 19 additions & 1 deletion src/gui/RuntimeFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ namespace GUI

DefaultFonts::DefaultFonts()
{
#if WINDOWS
/* On windows in memory fonts use GDI and OS fonts use D2D so if we have
* LATO in the OS use that
*/
auto ft = juce::Font::findAllTypefaceNames();
for (const auto &q : ft)
if (q == "Lato")
useOSLato = true;

#endif

#define TEST_WITH_INDIE_FLOWER 0
#if TEST_WITH_INDIE_FLOWER
latoRegularTypeface = juce::Typeface::createSystemTypefaceFor(
Expand All @@ -46,7 +57,14 @@ DefaultFonts::~DefaultFonts(){};

juce::Font DefaultFonts::getLatoAtSize(float size, juce::Font::FontStyleFlags style) const
{
return juce::Font(latoRegularTypeface).withPointHeight(size).withStyle(style);
if (useOSLato)
{
return juce::Font("Lato", 10, 0).withPointHeight(size).withStyle(style);
}
else
{
return juce::Font(latoRegularTypeface).withPointHeight(size).withStyle(style);
}
}

juce::Font DefaultFonts::getFiraMonoAtSize(float size) const
Expand Down
2 changes: 2 additions & 0 deletions src/gui/RuntimeFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct DefaultFonts : public juce::DeletedAtShutdown
juce::Font::FontStyleFlags style = juce::Font::FontStyleFlags::plain) const;
juce::Font getFiraMonoAtSize(float size) const;

bool useOSLato{false};

juce::Font displayFont;
juce::Font patchNameFont;
juce::Font lfoTypeFont;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/ModulatableSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void ModulatableSlider::updateLocationState()
// This calculation is a little dicey but is correct
labelRect = juce::Rectangle<int>()
.withX(handleX0)
.withY(trayh / 2)
.withY(trayh / 2 + 1)
.withHeight(trayh)
.withWidth(range)
.withTrimmedRight(1)
Expand Down

0 comments on commit 69f92c4

Please sign in to comment.