openshot-audio  0.1.4
juce_CustomTypeface.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_CUSTOMTYPEFACE_H_INCLUDED
26 #define JUCE_CUSTOMTYPEFACE_H_INCLUDED
27 
28 
29 //==============================================================================
47 {
48 public:
49  //==============================================================================
52 
62  explicit CustomTypeface (InputStream& serialisedTypefaceStream);
63 
65  ~CustomTypeface();
66 
67  //==============================================================================
69  void clear();
70 
81  void setCharacteristics (const String& fontFamily, float ascent,
82  bool isBold, bool isItalic,
83  juce_wchar defaultCharacter) noexcept;
84 
94  void setCharacteristics (const String& fontFamily, const String& fontStyle,
95  float ascent, juce_wchar defaultCharacter) noexcept;
96 
105  void addGlyph (juce_wchar character, const Path& path, float width) noexcept;
106 
110  void addKerningPair (juce_wchar char1, juce_wchar char2, float extraAmount) noexcept;
111 
116  void addGlyphsFromOtherTypeface (Typeface& typefaceToCopy, juce_wchar characterStartIndex, int numCharacters) noexcept;
117 
126  bool writeToStream (OutputStream& outputStream);
127 
128  //==============================================================================
129  // The following methods implement the basic Typeface behaviour.
130  float getAscent() const override;
131  float getDescent() const override;
132  float getHeightToPointsFactor() const override;
133  float getStringWidth (const String&) override;
134  void getGlyphPositions (const String&, Array <int>& glyphs, Array<float>& xOffsets) override;
135  bool getOutlineForGlyph (int glyphNumber, Path&) override;
136  EdgeTable* getEdgeTableForGlyph (int glyphNumber, const AffineTransform&, float fontHeight) override;
137 
138 protected:
139  //==============================================================================
141  float ascent;
142 
143  //==============================================================================
150  virtual bool loadGlyphIfPossible (juce_wchar characterNeeded);
151 
152 private:
153  //==============================================================================
154  class GlyphInfo;
155  friend struct ContainerDeletePolicy<GlyphInfo>;
156  OwnedArray<GlyphInfo> glyphs;
157  short lookupTable [128];
158 
159  GlyphInfo* findGlyph (const juce_wchar character, bool loadIfNeeded) noexcept;
160 
162 };
163 
164 #endif // JUCE_CUSTOMTYPEFACE_H_INCLUDED
Definition: juce_EdgeTable.h:35
virtual float getAscent() const =0
#define noexcept
Definition: juce_CompilerSupport.h:141
virtual float getStringWidth(const String &text)=0
Definition: juce_InputStream.h:41
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
virtual float getDescent() const =0
Definition: juce_Typeface.h:44
Definition: juce_Path.h:62
virtual EdgeTable * getEdgeTableForGlyph(int glyphNumber, const AffineTransform &transform, float fontHeight)
Definition: juce_Typeface.cpp:119
virtual void getGlyphPositions(const String &text, Array< int > &glyphs, Array< float > &xOffsets)=0
Definition: juce_OutputStream.h:42
Definition: juce_CustomTypeface.cpp:25
virtual float getHeightToPointsFactor() const =0
Definition: juce_ContainerDeletePolicy.h:44
juce_wchar defaultCharacter
Definition: juce_CustomTypeface.h:140
Definition: juce_OwnedArray.h:55
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_AffineTransform.h:40
virtual bool getOutlineForGlyph(int glyphNumber, Path &path)=0
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49
float ascent
Definition: juce_CustomTypeface.h:141
Definition: juce_CustomTypeface.h:46