libosmscout  1.1.1
TextLoader.h
Go to the documentation of this file.
1 #ifndef LIBOSMSCOUT_TEXTLOADER_H
2 #define LIBOSMSCOUT_TEXTLOADER_H
3 
4 /*
5  This source is part of the libosmscout-map library
6  Copyright (C) 2017 Fanny Monori
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <string>
24 
25 #include <ft2build.h>
26 #include FT_FREETYPE_H
27 #include FT_GLYPH_H
28 
29 #include <osmscout/OpenGLMapData.h>
31 
32 namespace osmscout {
33 
35  char32_t character;
36  OpenGLTextureRef texture;
37  long baselineY;
38  long height;
39 
40  public:
41 
42  char32_t GetCharacter() const {
43  return character;
44  }
45 
46  void SetCharacter(char32_t character) {
47  this->character = character;
48  }
49 
51  return texture;
52  }
53 
54  void SetTexture(OpenGLTextureRef texture) {
55  this->texture = texture;
56  }
57 
58  long GetBaselineY() const {
59  return baselineY;
60  }
61 
62  void SetBaselineY(long baselineY) {
63  this->baselineY = baselineY;
64  }
65 
66  long GetHeight() const {
67  return height;
68  }
69 
70  void SetHeight(long height) {
71  this->height = height;
72  }
73 
74  };
75 
76  typedef std::shared_ptr<CharacterTexture> CharacterTextureRef;
77 
79  private:
80  FT_Library ft;
81  FT_Face face;
82 
83  long defaultFontSize;
84 
85  long maxHeight;
86  int sumWidth;
87 
88  std::map<std::pair<char32_t, int>, int> characterIndices;
89  std::vector<osmscout::CharacterTextureRef> characters;
90 
91  void LoadFace();
92 
93  void LoadFace(std::string);
94 
95  public:
96 
97  ~TextLoader();
98 
99  TextLoader(std::string path, long defaultSize);
100 
104  size_t GetWidth(int index);
105 
109  int GetStartWidth(int index);
110 
114  long GetHeight();
115 
119  long GetDefaultFontSize() const;
120 
124  void SetDefaultFontSize(long defaultFontSize);
125 
129  OpenGLTextureRef CreateTexture();
130 
134  std::vector<int> AddCharactersToTextureAtlas(std::string text, double size);
135  };
136 }
137 
138 
139 #endif //LIBOSMSCOUT_TEXTLOADER_H
Definition: TextLoader.h:78
void SetTexture(OpenGLTextureRef texture)
Definition: TextLoader.h:54
OpenGLTextureRef GetTexture() const
Definition: TextLoader.h:50
#define OSMSCOUT_MAP_OPENGL_API
Definition: MapOpenGLImportExport.h:45
Definition: TextLoader.h:34
void SetHeight(long height)
Definition: TextLoader.h:70
char32_t GetCharacter() const
Definition: TextLoader.h:42
Definition: Area.h:38
void SetBaselineY(long baselineY)
Definition: TextLoader.h:62
long GetBaselineY() const
Definition: TextLoader.h:58
std::shared_ptr< CharacterTexture > CharacterTextureRef
Definition: TextLoader.h:76
long GetHeight() const
Definition: TextLoader.h:66
void SetCharacter(char32_t character)
Definition: TextLoader.h:46
std::shared_ptr< OpenGLTexture > OpenGLTextureRef
Definition: OpenGLMapData.h:51