From 03b1e918fe55b137f4cc817936511ba8745b2160 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 21 Mar 2024 15:04:31 +0000 Subject: [PATCH] LookAndFeel: Make portable typeface metrics the default --- BREAKING_CHANGES.md | 26 +++++++++++++++++++ .../lookandfeel/juce_LookAndFeel.h | 11 ++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 7a3152a0c2..9c3ea9570a 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -2,6 +2,32 @@ # Version 8.0.0 +## Change + +JUCE widgets now query the LookAndFeel to determine the TypefaceMetricsKind to +use. By default, the LookAndFeel will specify the "portable" metrics kind, +which may change the size of text in JUCE widgets, depending on the font and +platform. + +**Possible Issues** + +Using "portable" metrics may cause text to render at a different scale when +compared to the old "legacy" metrics. + +**Workaround** + +If you want to restore the old metrics, e.g. to maintain the same text scaling +in an existing app, you can override LookAndFeel::getDefaultMetricsKind() on +each LookAndFeel in your application, to return the "legacy" metrics kind. + +**Rationale** + +Using portable font metrics streamlines the development experience when working +on applications that must run on multiple platforms. Using portable metrics by +default means that new projects will benefit from this improved cross-platform +behaviour from the outset. + + ## Change Signatures of several Typeface member functions have been updated to accept a diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h index 9f18174970..9ebcc3eff6 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h @@ -187,12 +187,13 @@ public: /** Widgets can call this to find out the kind of metrics they should use when creating their own fonts. - The default implementation returns the legacy metrics kind, but you can override this if - you want to use the portable metrics kind instead. Using portable metrics may cause text - to render at a different size, so you should check that text in your app still renders at an - appropriate size, and potentially adjust font sizes where necessary after overriding this. + The default implementation returns the portable metrics kind, but you can override this if + you want to use the legacy metrics kind instead, to avoid rendering changes in existing + projects. Switching between metrics kinds may cause text to render at a different size, so you + should check that text in your app still renders at an appropriate size, and potentially adjust + font sizes where necessary after overriding this function. */ - virtual TypefaceMetricsKind getDefaultMetricsKind() const { return TypefaceMetricsKind::legacy; } + virtual TypefaceMetricsKind getDefaultMetricsKind() const { return TypefaceMetricsKind::portable; } /** Returns a copy of the FontOptions with the LookAndFeel's default metrics kind set. */ FontOptions withDefaultMetrics (FontOptions opt) const { return opt.withMetricsKind (getDefaultMetricsKind()); }