w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Face.h
Go to the documentation of this file.
1 /* GRAPHITE2 LICENSING
2 
3  Copyright 2010, SIL International
4  All rights reserved.
5 
6  This library is free software; you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation; either version 2.1 of 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 GNU
14  Lesser General Public License for more details.
15 
16  You should also have received a copy of the GNU Lesser General Public
17  License along with this library in the file named "LICENSE".
18  If not, write to the Free Software Foundation, 51 Franklin Street,
19  Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
20  internet at http://www.fsf.org/licenses/lgpl.html.
21 
22 Alternatively, the contents of this file may be used under the terms of the
23 Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
24 License, as published by the Free Software Foundation, either version 2
25 of the License or (at your option) any later version.
26 */
27 #pragma once
28 
29 #include <cstdio>
30 
31 #include "graphite2/Font.h"
32 
33 #include "inc/Main.h"
34 #include "inc/FeatureMap.h"
35 #include "inc/TtfUtil.h"
36 #include "inc/Silf.h"
37 #include "inc/Error.h"
38 
39 namespace graphite2 {
40 
41 class Cmap;
42 class FileFace;
43 class GlyphCache;
44 class NameTable;
45 class json;
46 class Font;
47 
48 
49 using TtfUtil::Tag;
50 
51 // These are the actual tags, as distinct from the consecutive IDs in TtfUtil.h
52 
53 class Face
54 {
55  // Prevent any kind of copying
56  Face(const Face&);
57  Face& operator=(const Face&);
58 
59 public:
60  class Table;
61  static float default_glyph_advance(const void* face_ptr, gr_uint16 glyphid);
62 
63  Face(const void* appFaceHandle/*non-NULL*/, const gr_face_ops & ops);
64  virtual ~Face();
65 
66  virtual bool runGraphite(Segment *seg, const Silf *silf) const;
67 
68 public:
69  bool readGlyphs(uint32 faceOptions);
70  bool readGraphite(const Table & silf);
71  bool readFeatures();
72  void takeFileFace(FileFace* pFileFace/*takes ownership*/);
73 
74  const SillMap & theSill() const;
75  const GlyphCache & glyphs() const;
76  Cmap & cmap() const;
77  NameTable * nameTable() const;
79  json * logger() const throw();
80 
83 
84  // Features
88 
89  // Glyph related
92 
93  // Errors
94  unsigned int error() const { return m_error; }
95  bool error(Error e) { m_error = e.error(); return false; }
96  unsigned int error_context() const { return m_error; }
97  void error_context(unsigned int errcntxt) { m_errcntxt = errcntxt; }
98 
100 private:
101  SillMap m_Sill;
103  const void * m_appFaceHandle; // non-NULL
104  FileFace * m_pFileFace; //owned
105  mutable GlyphCache * m_pGlyphFaceCache; // owned - never NULL
106  mutable Cmap * m_cmap; // cmap cache if available
107  mutable NameTable * m_pNames;
108  mutable json * m_logger;
109  unsigned int m_error;
110  unsigned int m_errcntxt;
111 protected:
112  Silf * m_silfs; // silf subtables.
113  uint16 m_numSilf; // num silf subtables in the silf table
114 private:
116  m_descent;
117 #ifdef GRAPHITE2_TELEMETRY
118 public:
119  mutable telemetry tele;
120 #endif
121 };
122 
123 
124 
125 inline
126 const SillMap & Face::theSill() const
127 {
128  return m_Sill;
129 }
130 
131 inline
133 {
134  return m_Sill.theFeatureMap().numFeats();
135 }
136 
137 inline
138 const FeatureRef * Face::featureById(uint32 id) const
139 {
140  return m_Sill.theFeatureMap().findFeatureRef(id);
141 }
142 
143 inline
144 const FeatureRef *Face::feature(uint16 index) const
145 {
146  return m_Sill.theFeatureMap().feature(index);
147 }
148 
149 inline
150 const GlyphCache & Face::glyphs() const
151 {
152  return *m_pGlyphFaceCache;
153 }
154 
155 inline
156 Cmap & Face::cmap() const
157 {
158  return *m_cmap;
159 };
160 
161 inline
162 json * Face::logger() const throw()
163 {
164  return m_logger;
165 }
166 
167 
168 
169 class Face::Table
170 {
171  const Face * _f;
172  mutable const byte * _p;
173  size_t _sz;
174  bool _compressed;
175 
176  Error decompress();
177 
178  void release();
179 
180 public:
181  Table() throw();
182  Table(const Face & face, const Tag n, uint32 version=0xffffffff) throw();
183  ~Table() throw();
184  Table(const Table && rhs) throw();
185 
186  operator const byte * () const throw();
187 
188  size_t size() const throw();
189  Table & operator = (const Table && rhs) throw();
190 };
191 
192 inline
193 Face::Table::Table() throw()
194 : _f(0), _p(0), _sz(0), _compressed(false)
195 {
196 }
197 
198 inline
199 Face::Table::Table(const Table && rhs) throw()
200 : _f(rhs._f), _p(rhs._p), _sz(rhs._sz), _compressed(rhs._compressed)
201 {
202  rhs._p = 0;
203 }
204 
205 inline
206 Face::Table::~Table() throw()
207 {
208  release();
209 }
210 
211 inline
212 Face::Table::operator const byte * () const throw()
213 {
214  return _p;
215 }
216 
217 inline
218 size_t Face::Table::size() const throw()
219 {
220  return _sz;
221 }
222 
223 } // namespace graphite2
224 
225 struct gr_face : public graphite2::Face {};
Definition: error.hpp:20
Definition: Font.hpp:55
const byte * _p
Definition: Face.h:172
const Face * _f
Definition: Face.h:171
size_t size() const
Definition: Face.h:218
void setLogger(FILE *log_file)
uint16 languageForLocale(const char *locale) const
Definition: Face.cpp:267
Cmap & cmap() const
gr_face_ops m_ops
Definition: Face.h:102
void takeFileFace(FileFace *pFileFace)
Cmap & cmap() const
Definition: Face.h:156
int32 getGlyphMetric(uint16 gid, uint8 metric) const
Definition: Face.cpp:235
Cmap * m_cmap
Definition: Face.h:106
FileFace * m_pFileFace
Definition: Face.h:104
uint16 m_ascent
Definition: Face.h:115
bool readGlyphs(uint32 faceOptions)
Face(const void *appFaceHandle, const gr_face_ops &ops)
const SillMap & theSill() const
virtual bool runGraphite(Segment *seg, const Silf *silf) const
Face(const Face &)
SillMap m_Sill
Definition: Face.h:101
CLASS_NEW_DELETE
Definition: Face.h:99
const GlyphCache & glyphs() const
json * m_logger
Definition: Face.h:108
unsigned int m_errcntxt
Definition: Face.h:110
void error_context(unsigned int errcntxt)
Definition: Face.h:97
const SillMap & theSill() const
Definition: Face.h:126
unsigned int error() const
Definition: Face.h:94
unsigned int m_error
Definition: Face.h:109
static float default_glyph_advance(const void *face_ptr, gr_uint16 glyphid)
virtual ~Face()
uint16 numFeatures() const
Definition: Face.h:132
const FeatureRef * featureById(uint32 id) const
Definition: Face.h:138
const Silf * chooseSilf(uint32 script) const
Definition: Face.cpp:220
const void * m_appFaceHandle
Definition: Face.h:103
const GlyphCache & glyphs() const
Definition: Face.h:150
unsigned int error_context() const
Definition: Face.h:96
bool readGraphite(const Table &silf)
uint16 m_numSilf
Definition: Face.h:113
const FeatureRef * feature(uint16 index) const
Definition: Face.h:144
uint16 m_descent
Definition: Face.h:116
NameTable * m_pNames
Definition: Face.h:107
json * logger() const
GlyphCache * m_pGlyphFaceCache
Definition: Face.h:105
Silf * m_silfs
Definition: Face.h:112
bool error(Error e)
Definition: Face.h:95
NameTable * nameTable() const
uint16 findPseudo(uint32 uid) const
Definition: Face.cpp:230
Face & operator=(const Face &)
json * logger() const
Definition: Face.h:162
uint16 numFeats() const
Definition: FeatureMap.h:144
FeatureRef * feature(uint16 index) const
Definition: FeatureMap.h:140
const FeatureRef * findFeatureRef(uint32 name) const
Definition: FeatureMap.cpp:260
const FeatureMap & theFeatureMap() const
Definition: FeatureMap.h:185
#define n
Definition: t4ht.c:1290
xD9 x84 xD8 xAD xD9 x80 xF0 x90 xAC x9A xE0 xA7 xA6 xE0 xA7 xAA xF0 x91 x84 xA4 xF0 x91 x84 x89 xF0 x91 x84 x9B xF0 x90 x8A xAB xF0 x90 x8B x89 xE2 xB2 x9E xE2 xB2 x9F xD0 xBE xD0 x9E xF0 x90 x90 x84 xF0 x90 x90 xAC xE1 x83 x98 xE1 x83 x94 xE1 x83 x90 xE1 xB2 xBF xE2 xB0 x95 xE2 xB1 x85 xCE xBF xCE x9F xE0 xA8 xA0 xE0 xA8 xB0 xE0 xA9 xA6 Kayah xEA xA4 x8D xEA xA4 x80 Khmer xE1 xA7 xA1 xE1 xA7 xAA xE0 xBB x90 Latin Subscript xE2 x82 x92 xE2 x82 x80 xEA x93 xB3 xF0 x96 xB9 xA1 xF0 x96 xB9 x9B xF0 x96 xB9 xAF xE1 x80 x9D xE1 x80 x84 xE1 x80 x82 no script
Definition: afscript.h:271
FT_Face face
Definition: cffdrivr.c:659
#define const
Definition: ftzconf.h:91
#define false
Definition: ftrandom.c:52
#define inline
Definition: config.h:132
unsigned short uint16
Definition: tiff.h:62
unsigned long uint32
Definition: tiff.h:68
hb_tag_t Tag
Definition: luaharfbuzz.h:17
Definition: bits.h:30
gr_uint8 uint8
Definition: Main.h:38
gr_uint16 uint16
Definition: Main.h:40
gr_uint32 uint32
Definition: Main.h:41
gr_int32 int32
Definition: Main.h:44
#define version
Definition: nup.c:10
unsigned short gr_uint16
Definition: Types.h:34
struct Table Table
ShellFileEnvironment e
Definition: sh6.c:388
Definition: gcache.h:9
Definition: Face.h:225
Definition: mendex.h:20
Definition: epdf.c:232
Definition: gd.c:2418
#define FILE
Definition: t1stdio.h:34
static FILE * log_file
Definition: tex4ht.c:1100
static const char * locale
Definition: uresb.c:52