libosmscout 1.1.1
Loading...
Searching...
No Matches
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
31
32namespace 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
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 bool initialized = false;
81
82 FT_Library ft=nullptr;
83 FT_Face face=nullptr;
84
85 long defaultFontSize;
86
87 long maxHeight;
88 int sumWidth;
89
90 std::map<std::pair<char32_t, int>, int> characterIndices;
91 std::vector<osmscout::CharacterTextureRef> characters;
92
93 bool LoadFace(const std::string &path, double dpi);
94
95 public:
96
97 TextLoader(const std::string &path, long defaultSize, double dpi);
98
100
101 bool IsInitialized() const
102 {
103 return initialized;
104 }
105
109 size_t GetWidth(int index);
110
114 int GetStartWidth(int index);
115
119 long GetHeight();
120
124 long GetDefaultFontSize() const;
125
129 void SetDefaultFontSize(long defaultFontSize);
130
135
139 std::vector<int> AddCharactersToTextureAtlas(std::string text, double size);
140 };
141}
142
143
144#endif //LIBOSMSCOUT_TEXTLOADER_H
#define OSMSCOUT_MAP_OPENGL_API
Definition MapOpenGLImportExport.h:45
Definition TextLoader.h:34
void SetHeight(long height)
Definition TextLoader.h:70
void SetBaselineY(long baselineY)
Definition TextLoader.h:62
long GetHeight() const
Definition TextLoader.h:66
OpenGLTextureRef GetTexture() const
Definition TextLoader.h:50
char32_t GetCharacter() const
Definition TextLoader.h:42
long GetBaselineY() const
Definition TextLoader.h:58
void SetCharacter(char32_t character)
Definition TextLoader.h:46
void SetTexture(OpenGLTextureRef texture)
Definition TextLoader.h:54
void SetDefaultFontSize(long defaultFontSize)
bool IsInitialized() const
Definition TextLoader.h:101
long GetDefaultFontSize() const
TextLoader(const std::string &path, long defaultSize, double dpi)
OpenGLTextureRef CreateTexture()
int GetStartWidth(int index)
std::vector< int > AddCharactersToTextureAtlas(std::string text, double size)
size_t GetWidth(int index)
Definition Area.h:39
std::shared_ptr< OpenGLTexture > OpenGLTextureRef
Definition OpenGLMapData.h:67
std::shared_ptr< CharacterTexture > CharacterTextureRef
Definition TextLoader.h:76