MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / InitializeFonts

Function InitializeFonts

LibLemon/src/gfx/font.cpp:29–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 __attribute__((constructor))
30 void InitializeFonts(){
31 fontState = -1;
32
33 if(FT_Init_FreeType(&library)){
34 printf("Error initializing freetype");
35 return;
36 }
37
38 mainFont = new Font;
39
40 if(int err = FT_New_Face(library, "/initrd/montserrat.ttf", 0, &mainFont->face)){
41 printf("Freetype Error (%d) loading font from memory /initrd/montserrat.ttf\n",err);
42 return;
43 }
44
45 mainFont->height = 12;
46
47 if(int err = FT_Set_Pixel_Sizes(mainFont->face, 0, mainFont->height)){
48 printf("Freetype Error (%d) Setting Font Size\n", err);
49 return;
50 }
51
52 mainFont->lineHeight = 16;
53 mainFont->id = new char[strlen("default") + 1];
54 mainFont->width = 8;
55 mainFont->tabWidth = 4;
56 strcpy(mainFont->id, "default");
57
58 fonts["default"] = mainFont;
59
60 fontState = 1;
61 }
62
63 Font* LoadFont(const char* path, const char* id, int sz){
64 Font* font = new Font;

Callers 4

DrawCharFunction · 0.85
DrawStringFunction · 0.85
GetCharWidthFunction · 0.85
GetTextLengthFunction · 0.85

Calls 2

strlenFunction · 0.85
strcpyFunction · 0.85

Tested by

no test coverage detected