|
JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins
« « « Anklang Documentation |
Represents a particular font, including its size, style, etc. More...
#include "juce_Font.h"
Classes | |
| class | SharedFontInternal |
Public Types | |
| enum | FontStyleFlags { plain , bold , italic , underlined } |
| A combination of these values is used by the constructor to specify the style of font to use. More... | |
Public Member Functions | |
| Font (float fontHeight, int styleFlags=plain) | |
| Creates a sans-serif font in a given size. | |
| Font (const String &typefaceName, float fontHeight, int styleFlags) | |
| Creates a font with a given typeface and parameters. | |
| Font (const String &typefaceName, const String &typefaceStyle, float fontHeight) | |
| Creates a font with a given typeface and parameters. | |
| Font (const Font &other) noexcept | |
| Creates a copy of another Font object. | |
| Font (const Typeface::Ptr &typeface) | |
| Creates a font for a typeface. | |
| Font () | |
| Creates a basic sans-serif font at a default height. | |
| Font (Font &&other) noexcept | |
| Move constructor. | |
| Font & | operator= (Font &&other) noexcept |
| Move assignment operator. | |
| Font & | operator= (const Font &other) noexcept |
| Copies this font from another one. | |
| bool | operator== (const Font &other) const noexcept |
| bool | operator!= (const Font &other) const noexcept |
| ~Font () noexcept | |
| Destructor. | |
| void | setTypefaceName (const String &faceName) |
| Changes the font family of the typeface. | |
| String | getTypefaceName () const noexcept |
| Returns the font family of the typeface that this font uses. | |
| String | getTypefaceStyle () const noexcept |
| Returns the font style of the typeface that this font uses. | |
| void | setTypefaceStyle (const String &newStyle) |
| Changes the font style of the typeface. | |
| Font | withTypefaceStyle (const String &newStyle) const |
| Returns a copy of this font with a new typeface style. | |
| StringArray | getAvailableStyles () const |
| Returns a list of the styles that this font can use. | |
| Font | withHeight (float height) const |
| Returns a copy of this font with a new height. | |
| Font | withPointHeight (float heightInPoints) const |
| Returns a copy of this font with a new height, specified in points. | |
| void | setHeight (float newHeight) |
| Changes the font's height. | |
| void | setHeightWithoutChangingWidth (float newHeight) |
| Changes the font's height without changing its width. | |
| float | getHeight () const noexcept |
| Returns the total height of this font, in pixels. | |
| float | getHeightInPoints () const |
| Returns the total height of this font, in points. | |
| float | getAscent () const |
| Returns the height of the font above its baseline, in pixels. | |
| float | getAscentInPoints () const |
| Returns the height of the font above its baseline, in points. | |
| float | getDescent () const |
| Returns the amount that the font descends below its baseline, in pixels. | |
| float | getDescentInPoints () const |
| Returns the amount that the font descends below its baseline, in points. | |
| int | getStyleFlags () const noexcept |
| Returns the font's style flags. | |
| Font | withStyle (int styleFlags) const |
| Returns a copy of this font with the given set of style flags. | |
| void | setStyleFlags (int newFlags) |
| Changes the font's style. | |
| void | setBold (bool shouldBeBold) |
| Makes the font bold or non-bold. | |
| Font | boldened () const |
| Returns a copy of this font with the bold attribute set. | |
| bool | isBold () const noexcept |
| Returns true if the font is bold. | |
| void | setItalic (bool shouldBeItalic) |
| Makes the font italic or non-italic. | |
| Font | italicised () const |
| Returns a copy of this font with the italic attribute set. | |
| bool | isItalic () const noexcept |
| Returns true if the font is italic. | |
| void | setUnderline (bool shouldBeUnderlined) |
| Makes the font underlined or non-underlined. | |
| bool | isUnderlined () const noexcept |
| Returns true if the font is underlined. | |
| float | getHorizontalScale () const noexcept |
| Returns the font's horizontal scale. | |
| Font | withHorizontalScale (float scaleFactor) const |
| Returns a copy of this font with a new horizontal scale. | |
| void | setHorizontalScale (float scaleFactor) |
| Changes the font's horizontal scale factor. | |
| float | getExtraKerningFactor () const noexcept |
| Returns the font's kerning. | |
| Font | withExtraKerningFactor (float extraKerning) const |
| Returns a copy of this font with a new kerning factor. | |
| void | setExtraKerningFactor (float extraKerning) |
| Changes the font's kerning. | |
| void | setSizeAndStyle (float newHeight, int newStyleFlags, float newHorizontalScale, float newKerningAmount) |
| Changes all the font's characteristics with one call. | |
| void | setSizeAndStyle (float newHeight, const String &newStyle, float newHorizontalScale, float newKerningAmount) |
| Changes all the font's characteristics with one call. | |
| int | getStringWidth (const String &text) const |
| Returns the total width of a string as it would be drawn using this font. | |
| float | getStringWidthFloat (const String &text) const |
| Returns the total width of a string as it would be drawn using this font. | |
| void | getGlyphPositions (const String &text, Array< int > &glyphs, Array< float > &xOffsets) const |
| Returns the series of glyph numbers and their x offsets needed to represent a string. | |
| Typeface::Ptr | getTypefacePtr () const |
| Returns the typeface used by this font. | |
| String | toString () const |
| Creates a string to describe this font. | |
Static Public Member Functions | |
| static const String & | getDefaultSansSerifFontName () |
| Returns a typeface font family that represents the default sans-serif font. | |
| static const String & | getDefaultSerifFontName () |
| Returns a typeface font family that represents the default serif font. | |
| static const String & | getDefaultMonospacedFontName () |
| Returns a typeface font family that represents the default monospaced font. | |
| static const String & | getDefaultStyle () |
| Returns a font style name that represents the default style. | |
| static Typeface::Ptr | getDefaultTypefaceForFont (const Font &font) |
| Returns the default system typeface for the given font. | |
| static float | getDefaultMinimumHorizontalScaleFactor () noexcept |
| Returns the minimum horizontal scale to which fonts may be squashed when trying to create a layout. | |
| static void | setDefaultMinimumHorizontalScaleFactor (float newMinimumScaleFactor) noexcept |
| Sets the minimum horizontal scale to which fonts may be squashed when trying to create a text layout. | |
| static void | findFonts (Array< Font > &results) |
| Creates an array of Font objects to represent all the fonts on the system. | |
| static StringArray | findAllTypefaceNames () |
| Returns a list of all the available typeface font families. | |
| static StringArray | findAllTypefaceStyles (const String &family) |
| Returns a list of all the available typeface font styles. | |
| static const String & | getFallbackFontName () |
| Returns the font family of the typeface to be used for rendering glyphs that aren't found in the requested typeface. | |
| static void | setFallbackFontName (const String &name) |
| Sets the (platform-specific) font family of the typeface to use to find glyphs that aren't available in whatever font you're trying to use. | |
| static const String & | getFallbackFontStyle () |
| Returns the font style of the typeface to be used for rendering glyphs that aren't found in the requested typeface. | |
| static void | setFallbackFontStyle (const String &style) |
| Sets the (platform-specific) font style of the typeface to use to find glyphs that aren't available in whatever font you're trying to use. | |
| static Font | fromString (const String &fontDescription) |
| Recreates a font from its stringified encoding. | |
Friends | |
| struct | GraphicsFontHelpers |
Represents a particular font, including its size, style, etc.
Apart from the typeface to be used, a Font object also dictates whether the font is bold, italic, underlined, how big it is, and its kerning and horizontal scale factor.
@tags{Graphics}
Definition at line 41 of file juce_Font.h.
A combination of these values is used by the constructor to specify the style of font to use.
| Enumerator | |
|---|---|
| plain | indicates a plain, non-bold, non-italic version of the font.
|
| bold | boldens the font.
|
| italic | finds an italic version of the font.
|
| underlined | underlines the font.
|
Definition at line 48 of file juce_Font.h.
Creates a sans-serif font in a given size.
| fontHeight | the height in pixels (can be fractional) |
| styleFlags | the 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. |
Definition at line 380 of file juce_Font.cpp.
Creates a font with a given typeface and parameters.
| typefaceName | the font family of the typeface to use |
| fontHeight | the height in pixels (can be fractional) |
| styleFlags | the 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. |
Definition at line 385 of file juce_Font.cpp.
Creates a font with a given typeface and parameters.
| typefaceName | the font family of the typeface to use |
| typefaceStyle | the font style of the typeface to use |
| fontHeight | the height in pixels (can be fractional) |
Definition at line 390 of file juce_Font.cpp.
Creates a copy of another Font object.
Definition at line 378 of file juce_Font.cpp.
| juce::Font::Font | ( | const Typeface::Ptr & | typeface | ) |
Creates a font for a typeface.
Definition at line 377 of file juce_Font.cpp.
| juce::Font::Font | ( | ) |
Creates a basic sans-serif font at a default height.
You should use one of the other constructors for creating a font that you're planning on drawing with - this constructor is here to help initialise objects before changing the font's settings later.
Definition at line 376 of file juce_Font.cpp.
|
noexcept |
Move constructor.
Definition at line 401 of file juce_Font.cpp.
| Font juce::Font::boldened | ( | ) | const |
Returns a copy of this font with the bold attribute set.
If the font does not have a bold version, this will return the default font.
Definition at line 701 of file juce_Font.cpp.
|
static |
Returns a list of all the available typeface font families.
The names returned can be passed into setTypefaceName().
You can use this instead of findFonts() if you only need their font family names, and not font objects.
Definition at line 98 of file juce_Fonts_linux.cpp.
|
static |
Returns a list of all the available typeface font styles.
The names returned can be passed into setTypefaceStyle().
You can use this instead of findFonts() if you only need their styles, and not font objects.
Definition at line 103 of file juce_Fonts_linux.cpp.
Creates an array of Font objects to represent all the fonts on the system.
If you just need the font family names of the typefaces, you can also use findAllTypefaceNames() instead.
| results | the array to which new Font objects will be added. |
Definition at line 778 of file juce_Font.cpp.
Recreates a font from its stringified encoding.
This method takes a string that was created by toString(), and recreates the original font.
Definition at line 809 of file juce_Font.cpp.
| float juce::Font::getAscent | ( | ) | const |
Returns the height of the font above its baseline, in pixels.
This is the maximum height from the baseline to the top.
Definition at line 729 of file juce_Font.cpp.
| float juce::Font::getAscentInPoints | ( | ) | const |
Returns the height of the font above its baseline, in points.
This is the maximum height from the baseline to the top.
Definition at line 738 of file juce_Font.cpp.
| StringArray juce::Font::getAvailableStyles | ( | ) | const |
Returns a list of the styles that this font can use.
Definition at line 503 of file juce_Font.cpp.
|
staticnoexcept |
Returns the minimum horizontal scale to which fonts may be squashed when trying to create a layout.
Definition at line 45 of file juce_Font.cpp.
Returns a typeface font family that represents the default monospaced font.
Note that this method just returns a generic placeholder string that means "the default monospaced font" - it's not the actual font family of this font.
Definition at line 466 of file juce_Font.cpp.
Returns a typeface font family that represents the default sans-serif font.
This is also the typeface that will be used when a font is created without specifying any typeface details.
Note that this method just returns a generic placeholder string that means "the default sans-serif font" - it's not the actual font family of this font.
Definition at line 464 of file juce_Font.cpp.
Returns a typeface font family that represents the default serif font.
Note that this method just returns a generic placeholder string that means "the default serif font" - it's not the actual font family of this font.
Definition at line 465 of file juce_Font.cpp.
Returns a font style name that represents the default style.
Note that this method just returns a generic placeholder string that means "the default font style" - it's not the actual name of the font style of any particular font.
Definition at line 467 of file juce_Font.cpp.
|
static |
Returns the default system typeface for the given font.
Definition at line 201 of file juce_Fonts_linux.cpp.
| float juce::Font::getDescent | ( | ) | const |
Returns the amount that the font descends below its baseline, in pixels.
This is calculated as (getHeight() - getAscent()).
Definition at line 735 of file juce_Font.cpp.
| float juce::Font::getDescentInPoints | ( | ) | const |
Returns the amount that the font descends below its baseline, in points.
This is calculated as (getHeight() - getAscent()).
Definition at line 739 of file juce_Font.cpp.
|
noexcept |
Returns the font's kerning.
This is the extra space added between adjacent characters, as a proportion of the font's height.
A value of zero is normal spacing, positive values will spread the letters out more, and negative values make them closer together.
Definition at line 682 of file juce_Font.cpp.
Returns the font family of the typeface to be used for rendering glyphs that aren't found in the requested typeface.
Definition at line 519 of file juce_Font.cpp.
Returns the font style of the typeface to be used for rendering glyphs that aren't found in the requested typeface.
Definition at line 533 of file juce_Font.cpp.
| void juce::Font::getGlyphPositions | ( | const String & | text, |
| Array< int > & | glyphs, | ||
| Array< float > & | xOffsets | ||
| ) | const |
Returns the series of glyph numbers and their x offsets needed to represent a string.
An extra x offset is added at the end of the run, to indicate where the right hand edge of the last character is.
Definition at line 756 of file juce_Font.cpp.
|
noexcept |
Returns the total height of this font, in pixels.
This is the maximum height, from the top of the ascent to the bottom of the descenders.
Definition at line 734 of file juce_Font.cpp.
| float juce::Font::getHeightInPoints | ( | ) | const |
Returns the total height of this font, in points.
This is the maximum height, from the top of the ascent to the bottom of the descenders.
Definition at line 737 of file juce_Font.cpp.
|
noexcept |
Returns the font's horizontal scale.
A value of 1.0 is the normal scale, less than this will be narrower, greater than 1.0 will be stretched out.
Definition at line 677 of file juce_Font.cpp.
Returns the total width of a string as it would be drawn using this font.
For a more accurate floating-point result, use getStringWidthFloat().
Definition at line 741 of file juce_Font.cpp.
Returns the total width of a string as it would be drawn using this font.
Definition at line 746 of file juce_Font.cpp.
|
noexcept |
Returns the font's style flags.
This will return a bitwise-or'ed combination of values from the FontStyleFlags enum, to describe whether the font is bold, italic, etc.
Definition at line 592 of file juce_Font.cpp.
|
noexcept |
Returns the font family of the typeface that this font uses.
e.g. "Arial", "Courier", etc.
This may also be set to Font::getDefaultSansSerifFontName(), Font::getDefaultSerifFontName(), or Font::getDefaultMonospacedFontName(), which are not actual platform-specific font family names, but are generic font family names that are used to represent the various default fonts.
If you need to know the exact typeface font family being used, you can call Font::getTypefacePtr()->getName(), which will give you the platform-specific font family.
Definition at line 469 of file juce_Font.cpp.
| Typeface::Ptr juce::Font::getTypefacePtr | ( | ) | const |
Returns the typeface used by this font.
Definition at line 508 of file juce_Font.cpp.
|
noexcept |
Returns the font style of the typeface that this font uses.
Definition at line 470 of file juce_Font.cpp.
|
noexcept |
Returns true if the font is bold.
Definition at line 704 of file juce_Font.cpp.
|
noexcept |
Returns true if the font is italic.
Definition at line 705 of file juce_Font.cpp.
|
noexcept |
Returns true if the font is underlined.
Definition at line 706 of file juce_Font.cpp.
| Font juce::Font::italicised | ( | ) | const |
Returns a copy of this font with the italic attribute set.
Definition at line 702 of file juce_Font.cpp.
Definition at line 420 of file juce_Font.cpp.
Copies this font from another one.
Definition at line 395 of file juce_Font.cpp.
Move assignment operator.
Definition at line 406 of file juce_Font.cpp.
Definition at line 414 of file juce_Font.cpp.
Makes the font bold or non-bold.
Definition at line 708 of file juce_Font.cpp.
|
staticnoexcept |
Sets the minimum horizontal scale to which fonts may be squashed when trying to create a text layout.
Definition at line 46 of file juce_Font.cpp.
Changes the font's kerning.
| extraKerning | a multiple of the font's height that will be added to space between the characters. So a value of zero is normal spacing, positive values spread the letters out, negative values make them closer together. |
Definition at line 694 of file juce_Font.cpp.
Sets the (platform-specific) font family of the typeface to use to find glyphs that aren't available in whatever font you're trying to use.
Definition at line 524 of file juce_Font.cpp.
Sets the (platform-specific) font style of the typeface to use to find glyphs that aren't available in whatever font you're trying to use.
Definition at line 538 of file juce_Font.cpp.
Changes the font's height.
Definition at line 567 of file juce_Font.cpp.
Changes the font's height without changing its width.
This alters the horizontal scale to compensate for the change in height.
Definition at line 579 of file juce_Font.cpp.
Changes the font's horizontal scale factor.
| scaleFactor | a value of 1.0 is the normal scale, less than this will be narrower, greater than 1.0 will be stretched out. |
Definition at line 670 of file juce_Font.cpp.
Makes the font italic or non-italic.
Definition at line 715 of file juce_Font.cpp.
| void juce::Font::setSizeAndStyle | ( | float | newHeight, |
| const String & | newStyle, | ||
| float | newHorizontalScale, | ||
| float | newKerningAmount | ||
| ) |
Changes all the font's characteristics with one call.
Definition at line 642 of file juce_Font.cpp.
| void juce::Font::setSizeAndStyle | ( | float | newHeight, |
| int | newStyleFlags, | ||
| float | newHorizontalScale, | ||
| float | newKerningAmount | ||
| ) |
Changes all the font's characteristics with one call.
Definition at line 621 of file juce_Font.cpp.
Changes the font's style.
| newFlags | a bitwise-or'ed combination of values from the FontStyleFlags enum. |
Definition at line 609 of file juce_Font.cpp.
Changes the font family of the typeface.
e.g. "Arial", "Courier", etc.
This may also be set to Font::getDefaultSansSerifFontName(), Font::getDefaultSerifFontName(), or Font::getDefaultMonospacedFontName(), which are not actual platform-specific font family names, but are generic font family names that are used to represent the various default fonts. If you need to know the exact typeface font family being used, you can call Font::getTypefacePtr()->getName(), which will give you the platform-specific font family.
If a suitable font isn't found on the machine, it'll just use a default instead.
Definition at line 472 of file juce_Font.cpp.
Changes the font style of the typeface.
Definition at line 485 of file juce_Font.cpp.
Makes the font underlined or non-underlined.
Definition at line 722 of file juce_Font.cpp.
| String juce::Font::toString | ( | ) | const |
Creates a string to describe this font.
The string will contain information to describe the font's typeface, size, and style. To recreate the font from this string, use fromString().
Definition at line 794 of file juce_Font.cpp.
Returns a copy of this font with a new kerning factor.
| extraKerning | a multiple of the font's height that will be added to space between the characters. So a value of zero is normal spacing, positive values spread the letters out, negative values make them closer together. |
Definition at line 687 of file juce_Font.cpp.
Returns a copy of this font with a new height.
Definition at line 548 of file juce_Font.cpp.
Returns a copy of this font with a new horizontal scale.
| scaleFactor | a value of 1.0 is the normal scale, less than this will be narrower, greater than 1.0 will be stretched out. |
Definition at line 663 of file juce_Font.cpp.
Returns a copy of this font with a new height, specified in points.
Definition at line 560 of file juce_Font.cpp.
Returns a copy of this font with the given set of style flags.
| styleFlags | a bitwise-or'ed combination of values from the FontStyleFlags enum. |
Definition at line 602 of file juce_Font.cpp.
Returns a copy of this font with a new typeface style.
Definition at line 496 of file juce_Font.cpp.
|
friend |
Definition at line 480 of file juce_Font.h.