1 module ppc.backend.loaders.font;
2 public import ppc.backend.loaders.font.bitmap;
3 import ppc.backend.ft;
4 import vibe.data.serialization;
5 import ppc.backend;
6 
7 class Font {
8 public:
9     /++
10         Size of atlas.
11     +/
12     PSize atlasSize;
13 
14     /++
15         Returns reference to texture data
16     +/
17     abstract ref ubyte[] getTexture();
18     
19     /++
20         Get GlyphInfo for character
21     +/
22     abstract GlyphInfo* opIndex(dchar c);
23 
24     /++
25         Returns true if the graphics frontend should update the texture
26     +/
27     bool shouldUpdateTexture() {
28         return false;
29     }
30 }
31 
32 struct FontRange {
33     size_t start;
34     size_t end;
35 }
36 
37 struct CharRange {
38     FontRange range;
39 }
40 
41 struct FontDescription {
42     /++
43         The height of a character in pixels
44     +/
45     size_t size;
46 
47     /++
48         The font file
49     +/
50     string font;
51 
52     /++
53         Face Index, useful in some regions
54     +/
55     @optional
56     uint faceIndex = 0;
57 
58     /++
59         Range of characters to pack
60     +/
61     @optional
62     CharRange[] characters = [CharRange(FontRange(32, 128))];
63 }
64 
65 struct GlyphInfo {
66     FTVector origin;
67     FTVector size;
68 
69     FTVector advance;
70     FTVector bearing;
71 }