annotate OrthancStone/Sources/Fonts/FontRenderer.cpp @ 1652:fa9e6bf84958

integrating pdf.js into Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Nov 2020 20:47:53 +0100
parents 8563ea5d8ae4
children 9ac2a65d4172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "FontRenderer.h"
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../Toolbox/DynamicBitmap.h"
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
27 #include <OrthancException.h>
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <ft2build.h>
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include FT_FREETYPE_H
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include FT_GLYPH_H
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 // https://stackoverflow.com/questions/31161284/how-can-i-get-the-corresponding-error-string-from-an-ft-error-code
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 static std::string GetErrorMessage(FT_Error err)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #undef __FTERRORS_H__
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #define FT_ERRORDEF( e, v, s ) case e: return s;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #define FT_ERROR_START_LIST switch (err) {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #define FT_ERROR_END_LIST }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include FT_ERRORS_H
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 return "(Unknown error)";
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 static void CheckError(FT_Error err)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (err != 0)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 "Error in FreeType: " + GetErrorMessage(err));
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 namespace OrthancStone
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 class FontRenderer::PImpl : public boost::noncopyable
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 private:
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 std::string fontContent_;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 FT_Library library_;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 FT_Face face_;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 void Clear()
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 if (face_ != NULL)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 FT_Done_Face(face_);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 face_ = NULL;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 fontContent_.clear();
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 public:
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 PImpl() :
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 library_(NULL),
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 face_(NULL)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 CheckError(FT_Init_FreeType(&library_));
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 ~PImpl()
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 Clear();
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 FT_Done_FreeType(library_);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 void LoadFont(const std::string& fontContent,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 unsigned int fontSize)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 Clear();
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 // It is necessary to make a private copy of the font, as
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 // Freetype makes the assumption that the buffer containing the
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 // font is never deleted
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 fontContent_.assign(fontContent);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 const FT_Byte* data = reinterpret_cast<const FT_Byte*>(fontContent_.c_str());
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
693
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 576
diff changeset
105 CheckError(FT_New_Memory_Face(
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 576
diff changeset
106 library_, data, static_cast<FT_Long>(fontContent_.size()), 0, &face_));
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 576
diff changeset
107
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 CheckError(FT_Set_Char_Size(face_, // handle to face object
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 0, // char_width in 1/64th of points
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 fontSize * 64, // char_height in 1/64th of points
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 72, // horizontal device resolution
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 72)); // vertical device resolution
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 CheckError(FT_Select_Charmap(face_, FT_ENCODING_UNICODE));
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 Glyph* Render(uint32_t unicode)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 if (face_ == NULL)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 "First call LoadFont()");
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 else if (FT_Load_Char(face_, unicode, FT_LOAD_RENDER) != 0)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 // This character is not available
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 return NULL;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 else
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 if (face_->glyph->format != FT_GLYPH_FORMAT_BITMAP)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 //CheckError(FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1));
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 Orthanc::ImageAccessor bitmap;
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 bitmap.AssignReadOnly(Orthanc::PixelFormat_Grayscale8,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 face_->glyph->bitmap.width,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 face_->glyph->bitmap.rows,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 face_->glyph->bitmap.pitch,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 face_->glyph->bitmap.buffer);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
145 std::unique_ptr<Glyph> glyph(
576
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 new Glyph(bitmap.GetWidth(),
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 bitmap.GetHeight(),
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 face_->glyph->bitmap_left,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 -face_->glyph->bitmap_top, // Positive for an upwards vertical distance
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 face_->glyph->advance.x >> 6,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 face_->glyph->metrics.vertAdvance >> 6));
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 glyph->SetPayload(new DynamicBitmap(bitmap));
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 return glyph.release();
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 };
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 FontRenderer::FontRenderer() :
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 pimpl_(new PImpl)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 void FontRenderer::LoadFont(const std::string& fontContent,
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 unsigned int fontSize)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 pimpl_->LoadFont(fontContent, fontSize);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 Glyph* FontRenderer::Render(uint32_t unicode)
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 return pimpl_->Render(unicode);
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
529c9617654b FontRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }