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

Function GetCharWidth

LibLemon/src/gfx/text.cpp:183–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181 }
182
183 int GetCharWidth(char c, Font* font){
184 if((fontState != 1 && fontState != -1) || !font->face) InitializeFonts();
185 if(fontState == -1){
186 return 8;
187 }
188
189 if(c == '\n'){
190 return 0;
191 } else if (c == ' ') {
192 return font->width;
193 } else if (c == '\t') {
194 return font->tabWidth * font->width;
195 } else if (!isprint(c)) {
196 return 0;
197 }
198
199 if(int err = FT_Load_Char(font->face, c, FT_LOAD_ADVANCE_ONLY)) {
200 printf("Freetype Error (%d)\n", err);
201 throw new FontException(FontException::FontRenderError, err);
202 fontState = 0;
203 return 0;
204 }
205
206 return font->face->glyph->advance.x >> 6;
207 }
208
209 int GetCharWidth(char c){
210 return GetCharWidth(c, mainFont);

Callers 1

OnMouseDownMethod · 0.85

Calls 1

InitializeFontsFunction · 0.85

Tested by

no test coverage detected