openshot-audio  0.1.7
juce_Font.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_FONT_H_INCLUDED
26 #define JUCE_FONT_H_INCLUDED
27 
28 
29 //==============================================================================
40 {
41 public:
42  //==============================================================================
47  {
48  plain = 0,
49  bold = 1,
50  italic = 2,
51  underlined = 4
52  };
53 
54  //==============================================================================
63  Font (float fontHeight, int styleFlags = plain);
64 
74  Font (const String& typefaceName, float fontHeight, int styleFlags);
75 
82  Font (const String& typefaceName, const String& typefaceStyle, float fontHeight);
83 
85  Font (const Font& other) noexcept;
86 
88  Font (const Typeface::Ptr& typeface);
89 
96  Font();
97 
98  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
99  Font (Font&& other) noexcept;
100  Font& operator= (Font&& other) noexcept;
101  #endif
102 
104  Font& operator= (const Font& other) noexcept;
105 
106  bool operator== (const Font& other) const noexcept;
107  bool operator!= (const Font& other) const noexcept;
108 
110  ~Font() noexcept;
111 
112  //==============================================================================
125  void setTypefaceName (const String& faceName);
126 
138  const String& getTypefaceName() const noexcept;
139 
140  //==============================================================================
144  const String& getTypefaceStyle() const noexcept;
145 
149  void setTypefaceStyle (const String& newStyle);
150 
154  Font withTypefaceStyle (const String& newStyle) const;
155 
157  StringArray getAvailableStyles() const;
158 
159  //==============================================================================
170  static const String& getDefaultSansSerifFontName();
171 
179  static const String& getDefaultSerifFontName();
180 
188  static const String& getDefaultMonospacedFontName();
189 
197  static const String& getDefaultStyle();
198 
200  static Typeface::Ptr getDefaultTypefaceForFont (const Font& font);
201 
202  //==============================================================================
204  Font withHeight (float height) const;
205 
207  Font withPointHeight (float heightInPoints) const;
208 
212  void setHeight (float newHeight);
213 
217  void setHeightWithoutChangingWidth (float newHeight);
218 
225  float getHeight() const noexcept;
226 
233  float getHeightInPoints() const;
234 
239  float getAscent() const;
240 
245  float getAscentInPoints() const;
246 
251  float getDescent() const;
252 
257  float getDescentInPoints() const;
258 
259  //==============================================================================
265  int getStyleFlags() const noexcept;
266 
271  Font withStyle (int styleFlags) const;
272 
277  void setStyleFlags (int newFlags);
278 
279  //==============================================================================
281  void setBold (bool shouldBeBold);
282 
286  Font boldened() const;
287 
289  bool isBold() const noexcept;
290 
292  void setItalic (bool shouldBeItalic);
294  Font italicised() const;
296  bool isItalic() const noexcept;
297 
299  void setUnderline (bool shouldBeUnderlined);
301  bool isUnderlined() const noexcept;
302 
303 
304  //==============================================================================
311  float getHorizontalScale() const noexcept;
312 
318  Font withHorizontalScale (float scaleFactor) const;
319 
324  void setHorizontalScale (float scaleFactor);
325 
330  static float getDefaultMinimumHorizontalScaleFactor() noexcept;
331 
336  static void setDefaultMinimumHorizontalScaleFactor (float newMinimumScaleFactor) noexcept;
337 
346  float getExtraKerningFactor() const noexcept;
347 
354  Font withExtraKerningFactor (float extraKerning) const;
355 
362  void setExtraKerningFactor (float extraKerning);
363 
364  //==============================================================================
366  void setSizeAndStyle (float newHeight,
367  int newStyleFlags,
368  float newHorizontalScale,
369  float newKerningAmount);
370 
372  void setSizeAndStyle (float newHeight,
373  const String& newStyle,
374  float newHorizontalScale,
375  float newKerningAmount);
376 
377  //==============================================================================
381  int getStringWidth (const String& text) const;
382 
386  float getStringWidthFloat (const String& text) const;
387 
393  void getGlyphPositions (const String& text, Array <int>& glyphs, Array <float>& xOffsets) const;
394 
395  //==============================================================================
401  Typeface* getTypeface() const;
402 
410  static void findFonts (Array<Font>& results);
411 
419  static StringArray findAllTypefaceNames();
420 
428  static StringArray findAllTypefaceStyles (const String& family);
429 
430  //==============================================================================
434  static const String& getFallbackFontName();
435 
439  static void setFallbackFontName (const String& name);
440 
444  static const String& getFallbackFontStyle();
445 
449  static void setFallbackFontStyle (const String& style);
450 
451  //==============================================================================
456  String toString() const;
457 
462  static Font fromString (const String& fontDescription);
463 
464 
465 private:
466  //==============================================================================
467  class SharedFontInternal;
468  ReferenceCountedObjectPtr<SharedFontInternal> font;
469  void dupeInternalIfShared();
470  void checkTypefaceSuitability();
471  float getHeightToPointsFactor() const;
472 
474 };
475 
476 #endif // JUCE_FONT_H_INCLUDED
Definition: juce_Font.h:39
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Font.cpp:178
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_Typeface.h:44
Definition: juce_StringArray.h:39
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
Definition: juce_Array.h:60
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
FontStyleFlags
Definition: juce_Font.h:46