Euphoria
loadedfont.h
Go to the documentation of this file.
1#pragma once
2
3
4
5#include <map>
6
7#include "eu/core/image.h"
8
9
10namespace eu
11{
12 struct MemoryChunk;
13}
14
15namespace eu::core
16{
17 // This represents a loaded glyph not yet placed on a texture image
19 {
20 //
21 // width_
22 // <--------->
23 // +---------+
24 // bearingX | | | |
25 // -------> | | | bearingY |
26 // origin | | | | height
27 // X.........|.........|....... baseline |
28 // | | |
29 // | | |
30 // +---------+
31 //
32 // ------------------------------> advance (x to next glyph)
33 //
34
35 bool valid = false;
36 int code_point = 0;
37 int bearing_x = 0;
38 int bearing_y = 0;
39 int advance = 0;
41 float size = 0.0f;
42 };
43
44
45 using KerningMap = std::map<std::pair<int, int>, float>;
46
47
48 // represent a loaded font (or a part), but it not yet been converted
49 // into a renderable data and texture.
51 {
52 std::map<int, LoadedGlyph> codepoint_to_glyph;
54 std::map<std::string, int> private_use_aliases;
55 int next_private_use = 0xE000;
56 float ascent = 0.0f;
57 float descent = 0.0f;
58 float line_gap = 0.0f;
59
60 int
62
63 bool
65 (
67 int font_size,
68 const std::string& chars
69 );
70 };
71
74 (
75 const std::string& image_file,
76 const std::string& image_alias,
77 float image_scale,
78 float image_bearing_x,
79 float image_bearing_y,
80 float image_advance
81 );
82
85 (
86 const Image& image,
87 const std::string& image_alias,
88 float image_scale,
89 float image_bearing_x,
90 float image_bearing_y,
91 float image_advance
92 );
93}
94
std::map< std::pair< int, int >, float > KerningMap
Definition loadedfont.h:45
LoadedFont get_characters_from_single_image(const std::string &image_file, const std::string &image_alias, float image_scale, float image_bearing_x, float image_bearing_y, float image_advance)
Definition assert.h:118
A (inclusive) range between two values.
Definition range.h:19
A simple sRGB(A) image.
Definition image.h:18
int generate_new_index_from_private_use(const std::string &alias)
std::map< int, LoadedGlyph > codepoint_to_glyph
Definition loadedfont.h:52
bool load_characters_from_font(const MemoryChunk &file_memory, int font_size, const std::string &chars)
std::map< std::string, int > private_use_aliases
Definition loadedfont.h:54