From b6211f01c871a0317ab98dd9e6f10caa04535530 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 3 Jul 2012 14:39:00 +0100 Subject: [PATCH] Added method: Font::withTypefaceStyle(). --- modules/juce_graphics/fonts/juce_Font.cpp | 7 +++++++ modules/juce_graphics/fonts/juce_Font.h | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 77da2854a6..2a651554f2 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -384,6 +384,13 @@ void Font::setTypefaceStyle (const String& typefaceStyle) } } +Font Font::withTypefaceStyle (const String& newStyle) const +{ + Font f (*this); + f.setTypefaceStyle (newStyle); + return f; +} + StringArray Font::getAvailableStyles() const { return findAllTypefaceStyles (getTypeface()->getName()); diff --git a/modules/juce_graphics/fonts/juce_Font.h b/modules/juce_graphics/fonts/juce_Font.h index 9a82e98e18..03825095b3 100644 --- a/modules/juce_graphics/fonts/juce_Font.h +++ b/modules/juce_graphics/fonts/juce_Font.h @@ -149,20 +149,21 @@ public: const String& getTypefaceName() const noexcept; //============================================================================== - /** Changes the font style of the typeface - - e.g. "Regular", "Italic", etc. - - */ - void setTypefaceStyle (const String& typefaceStyle); - /** Returns the font style of the typeface that this font uses. - - e.g. "Regular", "Italic", etc. - + @see withTypefaceStyle, getAvailableStyles() */ const String& getTypefaceStyle() const noexcept; + /** Changes the font style of the typeface. + @see getAvailableStyles() + */ + void setTypefaceStyle (const String& newStyle); + + /** Returns a copy of this font with a new typeface style. + @see getAvailableStyles() + */ + Font withTypefaceStyle (const String& newStyle) const; + /** Returns a list of the styles that this font can use. */ StringArray getAvailableStyles() const;