1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added method Font::getDefaultMinimumHorizontalScaleFactor() to make it possible to change the global minimum font squashing amount.

This commit is contained in:
jules 2015-03-17 11:41:14 +00:00
parent 251a059644
commit 844d9e8d86
7 changed files with 31 additions and 8 deletions

View file

@ -203,7 +203,7 @@ public:
The minimumHorizontalScale parameter specifies how much the text can be squashed horizontally
to try to squeeze it into the space. If you don't want any horizontal scaling to occur, you
can set this value to 1.0f.
can set this value to 1.0f. Pass 0 if you want it to use a default value.
@see GlyphArrangement::addFittedText
*/
@ -211,7 +211,7 @@ public:
int x, int y, int width, int height,
Justification justificationFlags,
int maximumNumberOfLines,
float minimumHorizontalScale = 0.7f) const;
float minimumHorizontalScale = 0.0f) const;
/** Tries to draw a text string inside a given space.
@ -228,7 +228,7 @@ public:
The minimumHorizontalScale parameter specifies how much the text can be squashed horizontally
to try to squeeze it into the space. If you don't want any horizontal scaling to occur, you
can set this value to 1.0f.
can set this value to 1.0f. Pass 0 if you want it to use a default value.
@see GlyphArrangement::addFittedText
*/
@ -236,7 +236,7 @@ public:
const Rectangle<int>& area,
Justification justificationFlags,
int maximumNumberOfLines,
float minimumHorizontalScale = 0.7f) const;
float minimumHorizontalScale = 0.0f) const;
//==============================================================================
/** Fills the context's entire clip region with the current colour or brush.

View file

@ -30,6 +30,7 @@ namespace FontValues
}
const float defaultFontHeight = 14.0f;
float minimumHorizontalScale = 1.0f;
String fallbackFont;
String fallbackFontStyle;
}
@ -37,6 +38,9 @@ namespace FontValues
typedef Typeface::Ptr (*GetTypefaceForFont) (const Font&);
GetTypefaceForFont juce_getTypefaceForFont = nullptr;
float Font::getDefaultMinimumHorizontalScaleFactor() noexcept { return FontValues::minimumHorizontalScale; }
void Font::setDefaultMinimumHorizontalScaleFactor (float newValue) noexcept { FontValues::minimumHorizontalScale = newValue; }
//==============================================================================
class TypefaceCache : private DeletedAtShutdown
{

View file

@ -319,6 +319,18 @@ public:
*/
void setHorizontalScale (float scaleFactor);
/** Returns the minimum horizontal scale to which fonts may be squashed when trying to
create a layout.
@see setDefaultMinimumHorizontalScaleFactor
*/
static float getDefaultMinimumHorizontalScaleFactor() noexcept;
/** Sets the minimum horizontal scale to which fonts may be squashed when trying to
create a text layout.
@see getDefaultMinimumHorizontalScaleFactor
*/
static void setDefaultMinimumHorizontalScaleFactor (float newMinimumScaleFactor) noexcept;
/** Returns the font's kerning.
This is the extra space added between adjacent characters, as a proportion

View file

@ -366,8 +366,11 @@ void GlyphArrangement::addFittedText (const Font& f,
const float width, const float height,
Justification layout,
int maximumLines,
const float minimumHorizontalScale)
float minimumHorizontalScale)
{
if (minimumHorizontalScale == 0.0f)
minimumHorizontalScale = Font::getDefaultMinimumHorizontalScaleFactor();
// doesn't make much sense if this is outside a sensible range of 0.5 to 1.0
jassert (minimumHorizontalScale > 0 && minimumHorizontalScale <= 1.0f);

View file

@ -208,6 +208,10 @@ public:
A Justification parameter lets you specify how the text is laid out within the rectangle,
both horizontally and vertically.
The minimumHorizontalScale parameter specifies how much the text can be squashed horizontally
to try to squeeze it into the space. If you don't want any horizontal scaling to occur, you
can set this value to 1.0f. Pass 0 if you want it to use the default value.
@see Graphics::drawFittedText
*/
void addFittedText (const Font& font,
@ -215,7 +219,7 @@ public:
float x, float y, float width, float height,
Justification layout,
int maximumLinesToUse,
float minimumHorizontalScale = 0.7f);
float minimumHorizontalScale = 0.0f);
/** Appends another glyph arrangement to this one. */
void addGlyphArrangement (const GlyphArrangement&);

View file

@ -29,7 +29,7 @@ Label::Label (const String& name, const String& labelText)
font (15.0f),
justification (Justification::centredLeft),
border (1, 5, 1, 5),
minimumHorizontalScale (0.7f),
minimumHorizontalScale (0.0f),
keyboardType (TextEditor::textKeyboard),
editSingleClick (false),
editDoubleClick (false),

View file

@ -154,7 +154,7 @@ public:
bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; }
/** Specifies the minimum amount that the font can be squashed horizontally before it starts
using ellipsis.
using ellipsis. Use a value of 0 for a default value.
@see Graphics::drawFittedText
*/