libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout-map-opengl
include
osmscoutmapopengl
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 <
osmscoutmapopengl/OpenGLMapData.h
>
30
#include <
osmscoutmapopengl/MapOpenGLImportExport.h
>
31
32
namespace
osmscout
{
33
34
class
OSMSCOUT_MAP_OPENGL_API
CharacterTexture
{
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
50
OpenGLTextureRef
GetTexture
()
const
{
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
78
class
OSMSCOUT_MAP_OPENGL_API
TextLoader
{
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
99
~TextLoader
();
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
134
OpenGLTextureRef
CreateTexture
();
135
139
std::vector<int>
AddCharactersToTextureAtlas
(std::string text,
double
size);
140
};
141
}
142
143
144
#endif
//LIBOSMSCOUT_TEXTLOADER_H
MapOpenGLImportExport.h
OSMSCOUT_MAP_OPENGL_API
#define OSMSCOUT_MAP_OPENGL_API
Definition
MapOpenGLImportExport.h:45
OpenGLMapData.h
osmscout::CharacterTexture
Definition
TextLoader.h:34
osmscout::CharacterTexture::SetHeight
void SetHeight(long height)
Definition
TextLoader.h:70
osmscout::CharacterTexture::SetBaselineY
void SetBaselineY(long baselineY)
Definition
TextLoader.h:62
osmscout::CharacterTexture::GetHeight
long GetHeight() const
Definition
TextLoader.h:66
osmscout::CharacterTexture::GetTexture
OpenGLTextureRef GetTexture() const
Definition
TextLoader.h:50
osmscout::CharacterTexture::GetCharacter
char32_t GetCharacter() const
Definition
TextLoader.h:42
osmscout::CharacterTexture::GetBaselineY
long GetBaselineY() const
Definition
TextLoader.h:58
osmscout::CharacterTexture::SetCharacter
void SetCharacter(char32_t character)
Definition
TextLoader.h:46
osmscout::CharacterTexture::SetTexture
void SetTexture(OpenGLTextureRef texture)
Definition
TextLoader.h:54
osmscout::TextLoader::SetDefaultFontSize
void SetDefaultFontSize(long defaultFontSize)
osmscout::TextLoader::IsInitialized
bool IsInitialized() const
Definition
TextLoader.h:101
osmscout::TextLoader::GetDefaultFontSize
long GetDefaultFontSize() const
osmscout::TextLoader::~TextLoader
~TextLoader()
osmscout::TextLoader::GetHeight
long GetHeight()
osmscout::TextLoader::TextLoader
TextLoader(const std::string &path, long defaultSize, double dpi)
osmscout::TextLoader::CreateTexture
OpenGLTextureRef CreateTexture()
osmscout::TextLoader::GetStartWidth
int GetStartWidth(int index)
osmscout::TextLoader::AddCharactersToTextureAtlas
std::vector< int > AddCharactersToTextureAtlas(std::string text, double size)
osmscout::TextLoader::GetWidth
size_t GetWidth(int index)
osmscout
Definition
Area.h:39
osmscout::OpenGLTextureRef
std::shared_ptr< OpenGLTexture > OpenGLTextureRef
Definition
OpenGLMapData.h:67
osmscout::CharacterTextureRef
std::shared_ptr< CharacterTexture > CharacterTextureRef
Definition
TextLoader.h:76
Generated by
1.17.0