JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::FontOptions Class Referencefinal

Options that describe a particular font. More...

#include <juce_FontOptions.h>

Collaboration diagram for juce::FontOptions:

Public Member Functions

 FontOptions ()
 Constructs the default set of options.
 
 FontOptions (const String &typefaceName, const String &typefaceStyle, float fontHeight)
 Constructs the default set of options with a given typeface and parameters.
 
 FontOptions (const String &typefaceName, float fontHeight, int styleFlags)
 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 (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.
 
auto getAscentOverride () const
 
auto getDescentOverride () const
 
auto getFallbackEnabled () const
 
auto getFallbacks () const
 
Span< const FontFeatureSettinggetFeatureSettings () const &
 
Span< const FontFeatureSettinggetFeatureSettings () const &&=delete
 
auto getHeight () const
 
auto getHorizontalScale () const
 
auto getKerningFactor () const
 
auto getMetricsKind () const
 
auto getName () const
 
auto getPointHeight () const
 
auto getStyle () const
 
auto getTypeface () const
 
auto getUnderline () const
 
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
 Equality operator.
 
bool operator> (const FontOptions &other) const
 Greater-than operator.
 
bool operator>= (const FontOptions &other) const
 Greater-than-or-equal operator.
 
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 withFallbackEnabled (bool x=true) const
 Returns a copy of these options with font fallback enabled or disabled.
 
FontOptions withFallbacks (std::vector< String > x) const
 Returns a copy of these options with a new set of preferred fallback family names.
 
FontOptions withFeatureDisabled (FontFeatureTag tag) const
 Returns a copy of these options with the specified feature disabled.
 
FontOptions withFeatureEnabled (FontFeatureTag tag) const
 Returns a copy of these options with the specified feature enabled.
 
FontOptions withFeatureRemoved (FontFeatureTag featureTag) const
 Returns a copy of these options with the specified feature removed.
 
FontOptions withFeatureSetting (FontFeatureSetting featureSetting) const
 Returns a copy of these options with the specified font feature setting added or updated.
 
FontOptions withHeight (float x) const
 Returns a copy of these options with the specified height in JUCE units (can be fractional).
 
FontOptions withHorizontalScale (float x) const
 Returns a copy of these options with the specified horizontal scale factor, defaults to 1.0.
 
FontOptions withKerningFactor (float x) const
 Returns a copy of these options with the specified extra kerning factor (also called "tracking").
 
FontOptions withMetricsKind (TypefaceMetricsKind x) const
 Returns a copy of these options with the specified metrics kind.
 
FontOptions withName (String x) const
 Returns a copy of these options with a new typeface name.
 
FontOptions withPointHeight (float x) const
 Returns a copy of these options with the specified height in points (can be fractional).
 
FontOptions withStyle (String 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 withUnderline (bool x=true) const
 Returns a copy of these options with underline enabled or disabled, defaults to disabled.
 

Private Member Functions

auto tie () const
 

Private Attributes

float ascentOverride = -1.0f
 
float descentOverride = -1.0f
 
bool fallbackEnabled = true
 
std::vector< Stringfallbacks
 
std::vector< FontFeatureSettingfeatures
 
float height = -1.0f
 
float horizontalScale = 1.0f
 
TypefaceMetricsKind metricsKind { TypefaceMetricsKind::portable }
 
String name
 
float pointHeight = -1.0f
 
String style
 
float tracking {}
 
Typeface::Ptr typeface
 
bool underlined {}
 

Detailed Description

Options that describe a particular font.

Used to construct Font instances in a fluent style.

See also
Typeface, Font

@tags{Graphics}

Constructor & Destructor Documentation

◆ FontOptions() [1/6]

juce::FontOptions::FontOptions ( )

Constructs the default set of options.

◆ 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 Function Documentation

◆ getAscentOverride()

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

◆ getDescentOverride()

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

◆ getFallbackEnabled()

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

◆ getFallbacks()

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

◆ getFeatureSettings() [1/2]

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

◆ getFeatureSettings() [2/2]

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

◆ getHeight()

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

◆ getHorizontalScale()

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

◆ getKerningFactor()

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

◆ getMetricsKind()

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

◆ getName()

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

◆ getPointHeight()

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

◆ getStyle()

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

◆ getTypeface()

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

◆ getUnderline()

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

◆ operator!=()

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

Inequality operator.

◆ operator<()

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

Less-than operator.

Allows FontOptions to be used as keys in a map.

◆ operator<=()

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

Less-than-or-equal operator.

◆ operator==()

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

Equality operator.

◆ operator>()

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

Greater-than operator.

◆ operator>=()

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

Greater-than-or-equal operator.

◆ tie()

auto juce::FontOptions::tie ( ) const
private

◆ withAscentOverride()

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

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 juce::withMember().

◆ withDescentOverride()

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

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 juce::withMember().

◆ withFallbackEnabled()

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

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

References juce::withMember().

◆ withFallbacks()

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

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

References juce::withMember().

◆ withFeatureDisabled()

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

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

◆ withFeatureEnabled()

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

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

◆ withFeatureRemoved()

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

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.

◆ withFeatureSetting()

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

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

◆ withHeight()

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

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 jassert.

◆ withHorizontalScale()

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

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

References juce::withMember().

◆ withKerningFactor()

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

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

References juce::withMember().

◆ withMetricsKind()

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

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

References juce::withMember().

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

◆ withName()

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

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 jassertfalse, and juce::withMember().

◆ withPointHeight()

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

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 jassert.

◆ withStyle()

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

Returns a copy of these options with a new typeface 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 jassertfalse, and juce::withMember().

◆ withTypeface()

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

Returns a copy of these options with a new typeface.

If the typeface is non-null, it takes precedence over the name and style strings.

References jassert, and juce::withMember().

◆ withUnderline()

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

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

References juce::withMember().

Member Data Documentation

◆ ascentOverride

float juce::FontOptions::ascentOverride = -1.0f
private

◆ descentOverride

float juce::FontOptions::descentOverride = -1.0f
private

◆ fallbackEnabled

bool juce::FontOptions::fallbackEnabled = true
private

◆ fallbacks

std::vector<String> juce::FontOptions::fallbacks
private

◆ features

std::vector<FontFeatureSetting> juce::FontOptions::features
private

◆ height

float juce::FontOptions::height = -1.0f
private

◆ horizontalScale

float juce::FontOptions::horizontalScale = 1.0f
private

◆ metricsKind

TypefaceMetricsKind juce::FontOptions::metricsKind { TypefaceMetricsKind::portable }
private

◆ name

String juce::FontOptions::name
private

◆ pointHeight

float juce::FontOptions::pointHeight = -1.0f
private

◆ style

String juce::FontOptions::style
private

◆ tracking

float juce::FontOptions::tracking {}
private

◆ typeface

Typeface::Ptr juce::FontOptions::typeface
private

◆ underlined

bool juce::FontOptions::underlined {}
private

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