-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglyphRender.cpp
45 lines (31 loc) · 1.04 KB
/
glyphRender.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "stdafx.h"
#include "glyphRender.h"
#include "glyph_foundry/mapbox/glyph_foundry.hpp"
#include "glyph_foundry/mapbox/glyph_foundry_impl.hpp"
GlyphRender::GlyphRender(std::string& textFont)
{
_textFont = textFont;
_freeTypeWrapper = new FreeTypeWrapper();
_ft_face = _freeTypeWrapper->getFace(textFont);
_glyphSize = 24.0;
FT_Set_Char_Size(_ft_face, 0, (FT_F26Dot6)(_glyphSize * (1 << 6)), 0, 0);
}
GlyphRender::~GlyphRender()
{
}
sdf_glyph_foundry::glyph_info* GlyphRender::renderSDFGlyph(uint32_t code_point)
{
// Set character sizes.
//double size = 24.0;
//FT_Set_Char_Size(_ft_face, 0, (FT_F26Dot6)(size * (1 << 6)), 0, 0);
// Get FreeType face from face_ptr.
FT_UInt char_index = FT_Get_Char_Index(_ft_face, code_point);
if (!char_index) {
//fprintf(stderr, "could not find a glyph for this code point\n");
return nullptr;
}
sdf_glyph_foundry::glyph_info* glyph = new sdf_glyph_foundry::glyph_info;
glyph->glyph_index = char_index;
sdf_glyph_foundry::RenderSDF(*glyph, _glyphSize, 3, 0.25, _ft_face);
return glyph;
}