Loading...
Searching...
No Matches
juce::FontOptions Class Referencefinal

Detailed Description

Options that describe a particular font.

Used to construct Font instances in a fluent style.

See also
Typeface, Font

The documentation for this class was generated from the following file:

Public Member Functions

 FontOptions ()
 Constructs the default set of options.
 FontOptions (float fontHeight)
 Constructs the default set of options with a custom height.
 FontOptions (float fontHeight, int styleFlags)
 Constructs the default set of options with a custom height and style.
 FontOptions (const String &typefaceName, float fontHeight, int styleFlags)
 Constructs the default set of options with a given typeface and parameters.
 FontOptions (const String &typefaceName, const String &typefaceStyle, float fontHeight)
 Constructs the default set of options with a given typeface and parameters.
 FontOptions (const Typeface::Ptr &typeface)
 Constructs the default set of options with a given typeface.
FontOptions withName (String x) const
 Returns a copy of these options with a new typeface name.
FontOptions withStyle (String x) const
 Returns a copy of these options with a new typeface style.
FontOptions withStyleFlags (int x) const
 Returns a copy of these options with a new typeface style.
FontOptions withTypeface (Typeface::Ptr x) const
 Returns a copy of these options with a new typeface.
FontOptions withFallbacks (std::vector< String > x) const
 Returns a copy of these options with a new set of preferred fallback family names.
FontOptions withFallbackEnabled (bool x=true) const
 Returns a copy of these options with font fallback enabled or disabled.
FontOptions withHeight (float x) const
 Returns a copy of these options with the specified height in JUCE units (can be fractional).
FontOptions withPointHeight (float x) const
 Returns a copy of these options with the specified height in points (can be fractional).
FontOptions withKerningFactor (float x) const
 Returns a copy of these options with the specified extra kerning factor (also called "tracking").
FontOptions withHorizontalScale (float x) const
 Returns a copy of these options with the specified horizontal scale factor, defaults to 1.0.
FontOptions withUnderline (bool x=true) const
 Returns a copy of these options with underline enabled or disabled, defaults to disabled.
FontOptions withMetricsKind (TypefaceMetricsKind x) const
 Returns a copy of these options with the specified metrics kind.
FontOptions withAscentOverride (std::optional< float > x) const
 Returns a copy of these options with the specified font metrics value override.
FontOptions withDescentOverride (std::optional< float > x) const
 Returns a copy of these options with the specified font metrics value override.
FontOptions withFeatureSetting (FontFeatureSetting featureSetting) const
 Returns a copy of these options with the specified font feature setting added or updated.
FontOptions withFeatureRemoved (FontFeatureTag featureTag) const
 Returns a copy of these options with the specified feature removed.
FontOptions withFeatureEnabled (FontFeatureTag tag) const
 Returns a copy of these options with the specified feature enabled.
FontOptions withFeatureDisabled (FontFeatureTag tag) const
 Returns a copy of these options with the specified feature disabled.
FontOptions withVariableSetting (FontVariableSetting variableSetting) const
 Returns a copy of these options with the specified variable setting.
FontOptions withVariableSettings (Span< const FontVariableSetting > variableSettings) const
 Returns a copy of these options with the specified variable settings.
FontOptions withVariableRemoved (FontFeatureTag tag) const
 Returns a copy of these options with the specified variable setting removed.
FontOptions withDirect2DHinting (bool state) const
 Returns a copy of these options with Direct2D hinting enabled or disabled as specified.
auto getName () const
auto getStyle () const
auto getTypeface () const
auto getFallbacks () const
auto getHeight () const
auto getPointHeight () const
auto getKerningFactor () const
auto getHorizontalScale () const
auto getFallbackEnabled () const
auto getUnderline () const
auto getMetricsKind () const
auto getAscentOverride () const
auto getDescentOverride () const
Span< const FontFeatureSettinggetFeatureSettings () const &
Span< const FontFeatureSettinggetFeatureSettings () const &&=delete
Span< const FontVariableSettinggetVariableSettings () const &
Span< const FontVariableSettinggetVariableSettings () const &&=delete
bool getDirect2DHinting () const
bool operator== (const FontOptions &other) const
 Equality operator.
bool operator!= (const FontOptions &other) const
 Inequality operator.
bool operator< (const FontOptions &other) const
 Less-than operator.
bool operator<= (const FontOptions &other) const
 Less-than-or-equal operator.
bool operator> (const FontOptions &other) const
 Greater-than operator.
bool operator>= (const FontOptions &other) const
 Greater-than-or-equal operator.

Constructors and Destructors

◆ FontOptions() [1/6]

◆ FontOptions() [2/6]

juce::FontOptions::FontOptions ( float fontHeight)
explicit

Constructs the default set of options with a custom height.

◆ FontOptions() [3/6]

juce::FontOptions::FontOptions ( float fontHeight,
int styleFlags )

Constructs the default set of options with a custom height and style.

Parameters
fontHeightthe height in pixels (can be fractional)
styleFlagsthe style to use - this can be a combination of the Font::bold, Font::italic and Font::underlined, or just Font::plain for the normal style.
See also
Font::FontStyleFlags, Font::getDefaultSansSerifFontName

◆ FontOptions() [4/6]

juce::FontOptions::FontOptions ( const String & typefaceName,
float fontHeight,
int styleFlags )

Constructs the default set of options with a given typeface and parameters.

Parameters
typefaceNamethe font family of the typeface to use
fontHeightthe height in pixels (can be fractional)
styleFlagsthe style to use - this can be a combination of the Font::bold, Font::italic and Font::underlined, or just Font::plain for the normal style.
See also
Font::FontStyleFlags, Font::getDefaultSansSerifFontName

◆ FontOptions() [5/6]

juce::FontOptions::FontOptions ( const String & typefaceName,
const String & typefaceStyle,
float fontHeight )

Constructs the default set of options with a given typeface and parameters.

Parameters
typefaceNamethe font family of the typeface to use
typefaceStylethe font style of the typeface to use
fontHeightthe height in pixels (can be fractional)

◆ FontOptions() [6/6]

juce::FontOptions::FontOptions ( const Typeface::Ptr & typeface)

Constructs the default set of options with a given typeface.

Member Functions

◆ withName()

FontOptions juce::FontOptions::withName ( String x) const
inlinenodiscard

Returns a copy of these options with a new typeface name.

If the options include a non-null Typeface::Ptr, this will be ignored. Otherwise, a suitable typeface will be located based on the typeface name and style strings.

References FontOptions(), jassertfalse, juce::withMember(), and x.

Referenced by withTypeface().

◆ withStyle()

FontOptions juce::FontOptions::withStyle ( String x) const
inlinenodiscard

Returns a copy of these options with a new typeface style.

If the options include a non-null Typeface::Ptr or a custom variable configuration, this will be ignored. Otherwise, a suitable typeface will be located based on the typeface name and style strings.

References FontOptions(), jassertfalse, juce::withMember(), and x.

◆ withStyleFlags()

FontOptions juce::FontOptions::withStyleFlags ( int x) const
nodiscard

Returns a copy of these options with a new typeface style.

The style can be a combination of the Font::bold, Font::italic and Font::underlined, or just Font::plain for the normal style. If the options include a non-null Typeface::Ptr, this will be ignored. Otherwise, a suitable typeface will be located based on the typeface name and style strings.

References FontOptions(), and x.

◆ withTypeface()

FontOptions juce::FontOptions::withTypeface ( Typeface::Ptr x) const
inlinenodiscard

Returns a copy of these options with a new typeface.

If the typeface is non-null, it takes precedence over the name, style strings or any variable settings currently applied.

References FontOptions(), jassert, juce::withMember(), withName(), and x.

◆ withFallbacks()

FontOptions juce::FontOptions::withFallbacks ( std::vector< String > x) const
inlinenodiscard

Returns a copy of these options with a new set of preferred fallback family names.

References FontOptions(), juce::withMember(), and x.

◆ withFallbackEnabled()

FontOptions juce::FontOptions::withFallbackEnabled ( bool x = true) const
inlinenodiscard

Returns a copy of these options with font fallback enabled or disabled.

References FontOptions(), juce::withMember(), and x.

◆ withHeight()

FontOptions juce::FontOptions::withHeight ( float x) const
inlinenodiscard

Returns a copy of these options with the specified height in JUCE units (can be fractional).

FontOptions can hold either a JUCE height, set via withHeight(), or a point height, set via withPointHeight(). After calling withHeight(), the result of getPointHeight() will be -1.0f to indicate that the point height is unset.

For more information about how JUCE font heights work, see Font::setHeight().

References FontOptions(), jassert, and x.

◆ withPointHeight()

FontOptions juce::FontOptions::withPointHeight ( float x) const
inlinenodiscard

Returns a copy of these options with the specified height in points (can be fractional).

After calling withPointHeight(), the result of getHeight() will be -1.0f to indicate that the JUCE height is unset.

For more information about how point heights work, see Font::setPointHeight().

References FontOptions(), jassert, and x.

◆ withKerningFactor()

FontOptions juce::FontOptions::withKerningFactor ( float x) const
inlinenodiscard

Returns a copy of these options with the specified extra kerning factor (also called "tracking").

References FontOptions(), juce::withMember(), and x.

◆ withHorizontalScale()

FontOptions juce::FontOptions::withHorizontalScale ( float x) const
inlinenodiscard

Returns a copy of these options with the specified horizontal scale factor, defaults to 1.0.

References FontOptions(), juce::withMember(), and x.

◆ withUnderline()

FontOptions juce::FontOptions::withUnderline ( bool x = true) const
inlinenodiscard

Returns a copy of these options with underline enabled or disabled, defaults to disabled.

References FontOptions(), juce::withMember(), and x.

◆ withMetricsKind()

FontOptions juce::FontOptions::withMetricsKind ( TypefaceMetricsKind x) const
inlinenodiscard

Returns a copy of these options with the specified metrics kind.

References FontOptions(), juce::withMember(), and x.

Referenced by juce::LookAndFeel::withDefaultMetrics().

◆ withAscentOverride()

FontOptions juce::FontOptions::withAscentOverride ( std::optional< float > x) const
inlinenodiscard

Returns a copy of these options with the specified font metrics value override.

std::nullopt indicates that the font should use the built-in typeface metric; otherwise, the ascent value will be found by multiplying the provided value by the font size in points.

References FontOptions(), juce::withMember(), and x.

◆ withDescentOverride()

FontOptions juce::FontOptions::withDescentOverride ( std::optional< float > x) const
inlinenodiscard

Returns a copy of these options with the specified font metrics value override.

std::nullopt indicates that the font should use the built-in typeface metric; otherwise, the descent value will be found by multiplying the provided value by the font size in points.

References FontOptions(), juce::withMember(), and x.

◆ withFeatureSetting()

FontOptions juce::FontOptions::withFeatureSetting ( FontFeatureSetting featureSetting) const
nodiscard

Returns a copy of these options with the specified font feature setting added or updated.

References FontOptions().

Referenced by withFeatureDisabled(), and withFeatureEnabled().

◆ withFeatureRemoved()

FontOptions juce::FontOptions::withFeatureRemoved ( FontFeatureTag featureTag) const
nodiscard

Returns a copy of these options with the specified feature removed.

If the featureTag corresponds to a recognised default-enabled font feature (e.g., "calt", "ccmp", "liga", "locl", "mark", "mkmk", "rlig"), it's setting will be reset to its default state.

References FontOptions().

◆ withFeatureEnabled()

FontOptions juce::FontOptions::withFeatureEnabled ( FontFeatureTag tag) const
inlinenodiscard

Returns a copy of these options with the specified feature enabled.

References juce::FontFeatureSetting::featureEnabled, FontOptions(), and withFeatureSetting().

◆ withFeatureDisabled()

FontOptions juce::FontOptions::withFeatureDisabled ( FontFeatureTag tag) const
inlinenodiscard

Returns a copy of these options with the specified feature disabled.

References juce::FontFeatureSetting::featureDisabled, FontOptions(), and withFeatureSetting().

◆ withVariableSetting()

FontOptions juce::FontOptions::withVariableSetting ( FontVariableSetting variableSetting) const
nodiscard

Returns a copy of these options with the specified variable setting.

See also
Font:setVariableSettings, Typeface::getSupportedVariables, Typeface::getConfiguredVariables

References FontOptions().

◆ withVariableSettings()

FontOptions juce::FontOptions::withVariableSettings ( Span< const FontVariableSetting > variableSettings) const
nodiscard

Returns a copy of these options with the specified variable settings.

This will replace any current variable settings configured.

See also
Font:setVariableSettings, Typeface::getSupportedVariables, Typeface::getConfiguredVariables

References FontOptions().

◆ withVariableRemoved()

FontOptions juce::FontOptions::withVariableRemoved ( FontFeatureTag tag) const
nodiscard

Returns a copy of these options with the specified variable setting removed.

This removes any configured value for the given variable axis, causing the font to use the axis's default value instead.

Parameters
tagThe variable axis tag to remove (e.g., 'wght', 'wdth', 'slnt')
See also
withVariableSetting, Typeface::getSupportedVariables

References FontOptions().

◆ withDirect2DHinting()

FontOptions juce::FontOptions::withDirect2DHinting ( bool state) const
inlinenodiscard

Returns a copy of these options with Direct2D hinting enabled or disabled as specified.

The default state is enabled.

This option currently only has an effect when using the Direct2D renderer on Windows.

Some fonts can look substantially different under the Direct2D renderer when compared to the software or OpenGL renderers. Fonts such as MS PGothic have hinted bitmaps for specific font sizes, and these bitmaps may appear much thinner than the font outlines that are also provided in the font. The software renderer always rasterises the font outlines, but Direct2D will default to using the built-in bitmaps if present, which will more closely match the intentions of the font designer. Disabling this option will cause the Direct2D to rasterise the font outlines in a similar way to the software renderer, which will produce a result that's closer to that of the software renderer (and therefore the legacy JUCE behaviour).

See also
getDirect2DHinting()

References FontOptions(), and juce::withMember().

◆ getName()

auto juce::FontOptions::getName ( ) const
inlinenodiscard
See also
withName()

◆ getStyle()

auto juce::FontOptions::getStyle ( ) const
inlinenodiscard
See also
withStyle()

◆ getTypeface()

auto juce::FontOptions::getTypeface ( ) const
inlinenodiscard
See also
withTypeface()

◆ getFallbacks()

auto juce::FontOptions::getFallbacks ( ) const
inlinenodiscard
See also
withFallbacks()

◆ getHeight()

auto juce::FontOptions::getHeight ( ) const
inlinenodiscard
See also
withHeight()

◆ getPointHeight()

auto juce::FontOptions::getPointHeight ( ) const
inlinenodiscard

◆ getKerningFactor()

auto juce::FontOptions::getKerningFactor ( ) const
inlinenodiscard

◆ getHorizontalScale()

auto juce::FontOptions::getHorizontalScale ( ) const
inlinenodiscard

◆ getFallbackEnabled()

auto juce::FontOptions::getFallbackEnabled ( ) const
inlinenodiscard

◆ getUnderline()

auto juce::FontOptions::getUnderline ( ) const
inlinenodiscard
See also
withUnderline()

◆ getMetricsKind()

auto juce::FontOptions::getMetricsKind ( ) const
inlinenodiscard

◆ getAscentOverride()

auto juce::FontOptions::getAscentOverride ( ) const
inlinenodiscard

◆ getDescentOverride()

auto juce::FontOptions::getDescentOverride ( ) const
inlinenodiscard

◆ getFeatureSettings() [1/2]

Span< const FontFeatureSetting > juce::FontOptions::getFeatureSettings ( ) const &
inlinenodiscard

◆ getFeatureSettings() [2/2]

Span< const FontFeatureSetting > juce::FontOptions::getFeatureSettings ( ) const &&
nodiscarddelete

◆ getVariableSettings() [1/2]

Span< const FontVariableSetting > juce::FontOptions::getVariableSettings ( ) const &
inlinenodiscard

◆ getVariableSettings() [2/2]

Span< const FontVariableSetting > juce::FontOptions::getVariableSettings ( ) const &&
nodiscarddelete

◆ getDirect2DHinting()

bool juce::FontOptions::getDirect2DHinting ( ) const
inlinenodiscard

◆ operator==()

bool juce::FontOptions::operator== ( const FontOptions & other) const
nodiscard

Equality operator.

References FontOptions().

◆ operator!=()

bool juce::FontOptions::operator!= ( const FontOptions & other) const
nodiscard

Inequality operator.

References FontOptions().

◆ operator<()

bool juce::FontOptions::operator< ( const FontOptions & other) const
nodiscard

Less-than operator.

Allows FontOptions to be used as keys in a map.

References FontOptions().

◆ operator<=()

bool juce::FontOptions::operator<= ( const FontOptions & other) const
nodiscard

Less-than-or-equal operator.

References FontOptions().

◆ operator>()

bool juce::FontOptions::operator> ( const FontOptions & other) const
nodiscard

Greater-than operator.

References FontOptions().

◆ operator>=()

bool juce::FontOptions::operator>= ( const FontOptions & other) const
nodiscard

Greater-than-or-equal operator.

References FontOptions(), and juce::portable.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram