-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmain.cpp
More file actions
105 lines (80 loc) · 2.3 KB
/
Copy pathmain.cpp
File metadata and controls
105 lines (80 loc) · 2.3 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <iostream>
#include <ctime>
#include "hbshaper.h"
#include "freetypelib.h"
using namespace std;
vector<gl::Mesh*> meshes;
int main(int argc, char** argv) {
srand(time(NULL));
// the font rasterizing library
FreeTypeLib lib;
clock_t begin, end;
HBShaper latinShaper("DejaVuSerif.ttf", &lib);
HBShaper arabicShaper("amiri-regular.ttf", &lib);
HBShaper russianShaper("DejaVuSerif.ttf", &lib);
HBShaper hanShaper("fireflysung.ttf", &lib);
HBShaper hindiShaper("Sanskrit2003.ttf", &lib);
latinShaper.init();
arabicShaper.init();
russianShaper.init();
hanShaper.init();
hindiShaper.init();
HBText hbt1 = {
"ficellé fffffi. VAV.",
"fr",
HB_SCRIPT_LATIN,
HB_DIRECTION_LTR
};
HBText hbt2 = {
"تسجّل يتكلّم",
"ar",
HB_SCRIPT_ARABIC,
HB_DIRECTION_RTL
};
HBText hbt3 = {
"Дуо вёжи дёжжэнтиюнт ут",
"ru",
HB_SCRIPT_CYRILLIC,
HB_DIRECTION_LTR
};
HBText hbt4 = {
"緳 踥踕",
"ch",
HB_SCRIPT_HAN,
HB_DIRECTION_TTB
};
HBText hbt5 = {
"हालाँकि प्रचलित रूप पूजा",
"hi",
HB_SCRIPT_DEVANAGARI,
HB_DIRECTION_LTR
};
latinShaper.addFeature(HBFeature::KerningOn);
gl::initGL(argc, argv);
begin = clock();
// ask for some meshes, this is not optimal since every glyph has its
// own texture, should use an atlas than contains glyph inside
// ->>>>>>> e.g. DON'T DO THIS <<<<<<<<<-
for(auto mesh: latinShaper.drawText(hbt1, 20, 320)) {
meshes.push_back(mesh);
}
for(auto mesh: arabicShaper.drawText(hbt2, 20, 220)) {
meshes.push_back(mesh);
}
for(auto mesh: russianShaper.drawText(hbt3, 20, 120)) {
meshes.push_back(mesh);
}
for(auto mesh: hanShaper.drawText(hbt4, 700, 380)) {
meshes.push_back(mesh);
}
for(auto mesh: hindiShaper.drawText(hbt5, 20, 20)) {
meshes.push_back(mesh);
}
end = clock();
std::cout << ((float) (end - begin) / CLOCKS_PER_SEC) * 1000 << " ms." << std::endl;
gl::uploadMeshes(meshes);
gl::loop(meshes);
gl::finish();
gl::deleteMeshes(meshes);
return 0;
}