mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a method LookAndFeel::setDefaultSansSerifTypeface()
This commit is contained in:
parent
381f97492a
commit
5d9eabb084
2 changed files with 37 additions and 11 deletions
|
|
@ -118,25 +118,41 @@ void LookAndFeel::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) noe
|
|||
//==============================================================================
|
||||
Typeface::Ptr LookAndFeel::getTypefaceForFont (const Font& font)
|
||||
{
|
||||
if (defaultSans.isNotEmpty() && font.getTypefaceName() == Font::getDefaultSansSerifFontName())
|
||||
{
|
||||
Font f (font);
|
||||
f.setTypefaceName (defaultSans);
|
||||
return Typeface::createSystemTypefaceFor (f);
|
||||
if (font.getTypefaceName() == Font::getDefaultSansSerifFontName())
|
||||
{
|
||||
if (defaultTypeface != nullptr)
|
||||
return defaultTypeface;
|
||||
|
||||
if (defaultSans.isNotEmpty())
|
||||
{
|
||||
Font f (font);
|
||||
f.setTypefaceName (defaultSans);
|
||||
return Typeface::createSystemTypefaceFor (f);
|
||||
}
|
||||
}
|
||||
|
||||
return Font::getDefaultTypefaceForFont (font);
|
||||
}
|
||||
|
||||
void LookAndFeel::setDefaultSansSerifTypeface (Typeface::Ptr newDefaultTypeface)
|
||||
{
|
||||
if (defaultTypeface != newDefaultTypeface)
|
||||
{
|
||||
defaultTypeface = newDefaultTypeface;
|
||||
Typeface::clearTypefaceCache();
|
||||
}
|
||||
}
|
||||
|
||||
void LookAndFeel::setDefaultSansSerifTypefaceName (const String& newName)
|
||||
{
|
||||
if (defaultSans != newName)
|
||||
{
|
||||
{
|
||||
defaultTypeface = {};
|
||||
Typeface::clearTypefaceCache();
|
||||
defaultSans = newName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
MouseCursor LookAndFeel::getMouseCursorFor (Component& component)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -163,15 +163,24 @@ public:
|
|||
//==============================================================================
|
||||
/** Returns the typeface that should be used for a given font.
|
||||
The default implementation just does what you'd expect it to, but you can override
|
||||
this if you want to intercept fonts and use your own custom typeface object.
|
||||
this if you want to intercept fonts and use your own custom typeface object.
|
||||
@see setDefaultTypeface
|
||||
*/
|
||||
virtual Typeface::Ptr getTypefaceForFont (const Font&);
|
||||
|
||||
/** Allows you to supply a default typeface that will be returned as the default
|
||||
sans-serif font.
|
||||
Instead of a typeface object, you can specify a typeface by name using the
|
||||
setDefaultSansSerifTypefaceName() method.
|
||||
You can perform more complex typeface substitutions by overloading
|
||||
getTypefaceForFont() but this lets you easily set a global typeface.
|
||||
*/
|
||||
void setDefaultSansSerifTypeface (Typeface::Ptr newDefaultTypeface);
|
||||
|
||||
/** Allows you to change the default sans-serif font.
|
||||
|
||||
If you need to supply your own Typeface object for any of the default fonts, rather
|
||||
than just supplying the name (e.g. if you want to use an embedded font), then
|
||||
you should instead override getTypefaceForFont() to create and return the typeface.
|
||||
you can instead call setDefaultSansSerifTypeface() with an object to use.
|
||||
*/
|
||||
void setDefaultSansSerifTypefaceName (const String& newName);
|
||||
|
||||
|
|
@ -223,7 +232,8 @@ private:
|
|||
};
|
||||
|
||||
SortedSet<ColourSetting> colours;
|
||||
String defaultSans, defaultSerif, defaultFixed;
|
||||
String defaultSans, defaultSerif, defaultFixed;
|
||||
Typeface::Ptr defaultTypeface;
|
||||
bool useNativeAlertWindows = false;
|
||||
|
||||
JUCE_DECLARE_WEAK_REFERENCEABLE (LookAndFeel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue