ScummVM API documentation
te_font2.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_FONT2_H
23 #define TETRAEDGE_TE_TE_FONT2_H
24 
25 #include "common/str.h"
26 #include "common/file.h"
27 #include "common/hashmap.h"
28 #include "graphics/font.h"
29 
30 #include "tetraedge/te/te_resource.h"
31 #include "tetraedge/te/te_vector2s32.h"
32 #include "tetraedge/te/te_vector3f32.h"
33 #include "tetraedge/te/te_3d_texture.h"
34 #include "tetraedge/te/te_intrusive_ptr.h"
35 #include "tetraedge/te/te_i_font.h"
36 
37 namespace Tetraedge {
38  struct KernChars {
39  uint32 _c1;
40  uint32 _c2;
41  };
42  bool operator==(const KernChars &l, const KernChars &r);
43 }
44 
45 namespace Common {
46  template<> struct Hash<Tetraedge::KernChars> : public UnaryFunction<Tetraedge::KernChars, uint> {
47  uint operator()(Tetraedge::KernChars val) const { return val._c1 * 7333 + val._c2; }
48  };
49 }
50 
51 namespace Tetraedge {
52 
57 class TeFont2 : public TeIFont, public Graphics::Font {
58 public:
59 
60  struct GlyphData2 {
61  float _xSz;
62  float _ySz;
63  float _xOff; // from nominal location
64  float _yOff; // top location, from baseline
65  float _xAdvance;
66  float _floats[3];
67  TeVector3f32 _vec; // location in texture - offset from bottom left
68  };
69 
70  TeFont2();
71  virtual ~TeFont2();
72 
73  bool load(const Common::Path &path);
74  bool load(const Common::FSNode &node);
75  void unload();
76 
77  Graphics::Font *getAtSize(uint size) override;
78 
79  virtual int getFontHeight() const override;
80  virtual int getMaxCharWidth() const override;
81  virtual int getCharWidth(uint32 chr) const override;
82  virtual void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
83  virtual int getKerningOffset(uint32 left, uint32 right) const override;
84  virtual Common::Rect getBBox(const Common::String &str, int fontSize) override;
85  virtual Common::Rect getBoundingBox(uint32 chr) const override;
86  virtual TeVector3f32 kerning(uint pxSize, uint isocode1, uint isocode2) override;
87 
88  virtual float height(uint pxSize) override;
89 
90 private:
91  Common::Path _loadedPath;
92 
93  uint32 _numChars;
94  TeVector2s32 _somePt;
95  TeVector3f32 _someVec;
96  bool _hasKernData;
97  float _maxHeight;
98  // Records a map of character pairs to kerning offsets
100  Common::Array<uint32> _uintArray;
102  TeImage _texture;
103 };
104 
105 } // end namespace Tetraedge
106 
107 #endif // TETRAEDGE_TE_TE_FONT2_H
Definition: te_image.h:39
Definition: str.h:59
Definition: font.h:82
Definition: detection.h:27
Definition: surface.h:66
Definition: rect.h:144
Definition: path.h:52
Definition: func.h:527
Definition: te_font2.h:60
Definition: te_i_font.h:37
Definition: te_font2.h:38
Definition: hashmap.h:85
Definition: algorithm.h:29
Definition: fs.h:69
Definition: te_vector2s32.h:31
Definition: te_font2.h:57
Definition: te_vector3f32.h:33
Definition: func.h:43