Gnash  0.8.11dev
FreetypeGlyphsProvider.h
Go to the documentation of this file.
1 // FreetypeGlyphsProvider.h: Freetype glyphs manager
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef GNASH_FREETYPE_H
21 #define GNASH_FREETYPE_H
22 
23 #include <string>
24 #include <memory> // for unique_ptr
25 #include <mutex>
26 #include <cstdint>
27 
28 #ifdef USE_FREETYPE
29 # include <ft2build.h>
30 # include FT_FREETYPE_H
31 # include FT_GLYPH_H
32 #endif
33 
34 // Forward declarations
35 namespace gnash {
36  namespace SWF {
37  class ShapeRecord;
38  }
39 }
40 
41 
42 namespace gnash {
43 
45 //
57 {
58 
59 public:
60 
62  //
76  static std::unique_ptr<FreetypeGlyphsProvider> createFace(
77  const std::string& name, bool bold, bool italic);
78 
80  //
84 
85 
89  //
104  std::unique_ptr<SWF::ShapeRecord> getGlyph(std::uint16_t code,
105  float& advance);
106 
108  float ascent() const;
109 
111  float descent() const;
112 
114  //
118  unsigned short unitsPerEM() const;
119 
120 private:
121 
123  //
126  FreetypeGlyphsProvider(const std::string& fontname, bool bold, bool italic);
127 
128 #ifdef USE_FREETYPE
129 
134  float scale;
135 
137  //
155  bool getFontFilename(const std::string& name, bool bold, bool italic,
156  std::string& filename);
157 
159  static void init();
160 
161  static void close();
162 
164  static std::mutex m_lib_mutex;
165 
167  static FT_Library m_lib;
168 
169  FT_Face _face;
170 
171 #endif // USE_FREETYPE
172 
173 };
174 
175 } // namespace gnash
176 
177 
178 #endif // GNASH_FREETYPE_H
name
std::string name
Definition: LocalConnection_as.cpp:149
ShapeRecord.h
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
y
std::int32_t y
Definition: BitmapData_as.cpp:435
_
#define _(String)
Definition: log.h:44
gnash::FreetypeGlyphsProvider
Truetype font rasterizer/converter based on freetype library.
Definition: FreetypeGlyphsProvider.h:57
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::FreetypeGlyphsProvider::unitsPerEM
unsigned short unitsPerEM() const
Return the number of units of glyphs EM.
Definition: FreetypeGlyphsProvider.cpp:401
gnash::FreetypeGlyphsProvider::ascent
float ascent() const
Return the font's ascender in terms of its EM own square.
Definition: FreetypeGlyphsProvider.cpp:415
gnash::FreetypeGlyphsProvider::createFace
static std::unique_ptr< FreetypeGlyphsProvider > createFace(const std::string &name, bool bold, bool italic)
Named constructor for a face-bound rasterizer.
Definition: FreetypeGlyphsProvider.cpp:393
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::FreetypeGlyphsProvider::getGlyph
std::unique_ptr< SWF::ShapeRecord > getGlyph(std::uint16_t code, float &advance)
Return the given DisplayObject glyph as a shape DisplayObject definition in unitsPerEM() coordinates.
Definition: FreetypeGlyphsProvider.cpp:552
FreetypeGlyphsProvider.h
gnash::key::code
code
Definition: GnashKey.h:44
gnash::get
T * get(as_object *o)
Extract the DisplayObject attached to an object.
Definition: as_object.h:842
gnash::FreetypeGlyphsProvider::~FreetypeGlyphsProvider
~FreetypeGlyphsProvider()
Destructor.
Definition: FreetypeGlyphsProvider.cpp:558
gnash::FreetypeGlyphsProvider::descent
float descent() const
Return the font's descender in terms of its own EM square.
Definition: FreetypeGlyphsProvider.cpp:408
gnash::key::j
@ j
Definition: GnashKey.h:156
log.h
DEFAULT_FONTFILE
#define DEFAULT_FONTFILE
Definition: gnashconfig.h:63
gnash::key::f
@ f
Definition: GnashKey.h:152
gnashconfig.h
gnash::getSWFVersion
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
FillStyle.h
gnash::key::SWF
@ SWF
Definition: GnashKey.h:331
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
GnashException.h
x
std::int32_t x
Definition: BitmapData_as.cpp:434