increase logo size slightly, fix text getting cut off

This commit is contained in:
Caleb Connolly 2023-02-06 17:17:19 +00:00
parent 83ab7e731d
commit 22f07eb624
No known key found for this signature in database
GPG key ID: 0583312B195F64B6

View file

@ -21,7 +21,7 @@
#define MSG_MAX_LEN 4096 #define MSG_MAX_LEN 4096
#define DEFAULT_FONT_PATH "/usr/share/pbsplash/OpenSans-Regular.svg" #define DEFAULT_FONT_PATH "/usr/share/pbsplash/OpenSans-Regular.svg"
#define LOGO_SIZE_MAX_MM 25 #define LOGO_SIZE_MAX_MM 40
#define FONT_SIZE_PT 9 #define FONT_SIZE_PT 9
#define FONT_SIZE_B_PT 5 #define FONT_SIZE_B_PT 5
#define PT_TO_MM 0.38f #define PT_TO_MM 0.38f
@ -170,7 +170,7 @@ static char* getTextDimensions(NSVGimage *font, char *text, float scale,
if (text == NULL) if (text == NULL)
return text; return text;
*width = 0; *width = font->defaultHorizAdv * scale;
// The height is simply the height of the font * the scale factor // The height is simply the height of the font * the scale factor
*height = fontHeight; *height = fontHeight;
@ -193,7 +193,7 @@ static char* getTextDimensions(NSVGimage *font, char *text, float scale,
} }
if (shape) { if (shape) {
*width += (float)shapes[i]->horizAdvX * scale + 0.5; *width += (float)shapes[i]->horizAdvX * scale + 2;
} else { } else {
*width += font->defaultHorizAdv * scale; *width += font->defaultHorizAdv * scale;
} }
@ -400,7 +400,7 @@ int main(int argc, char **argv)
&textWidth, &bottomTextHeight); &textWidth, &bottomTextHeight);
tx = screenWidth / 2.f - textWidth / 2.f; tx = screenWidth / 2.f - textWidth / 2.f;
ty = screenHeight - bottomTextHeight - MM_TO_PX(dpi, 2); ty = screenHeight - bottomTextHeight - MM_TO_PX(dpi, 2);
draw_text(font, message_bottom, tx, ty, textWidth, draw_text(font, message_bottom, tx, ty, screenWidth,
bottomTextHeight, fontsz, tfb_gray); bottomTextHeight, fontsz, tfb_gray);
} }
@ -427,6 +427,10 @@ int main(int argc, char **argv)
int frame = 0; int frame = 0;
int tty = open(active_tty, O_RDWR); int tty = open(active_tty, O_RDWR);
if (!tty) {
fprintf(stderr, "Failed to open tty %s (%d)\n", active_tty, errno);
goto out;
}
while (!terminate) { while (!terminate) {
if (!animation) { if (!animation) {
sleep(1); sleep(1);