mirror of
https://git.sr.ht/~calebccff/pbsplash
synced 2026-01-12 20:48:40 -09:00
font fixes for iosevka
The font handling was somewhat hardcoded for OpenSans, make some adjustments for iosevka. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
This commit is contained in:
parent
0b0de8faf4
commit
96d181885e
4 changed files with 12 additions and 16 deletions
|
|
@ -103,6 +103,8 @@ typedef struct NSVGimage {
|
|||
float height; // Height of the image.
|
||||
int fontAscent;
|
||||
int fontDescent;
|
||||
int fontUnitsPerEm;
|
||||
int fontHeight;
|
||||
int defaultHorizAdv;
|
||||
NSVGshape *shapes; // Linked list of shapes in the image.
|
||||
} NSVGimage;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ cc = meson.get_compiler('c')
|
|||
|
||||
deps = [
|
||||
cc.find_library('m', required : false),
|
||||
dependency('libdrm', required : true),
|
||||
dependency('libdrm'),
|
||||
dependency('libudev'),
|
||||
]
|
||||
|
||||
inc = [
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include "framebuffer.h"
|
||||
#include "tfblib.h"
|
||||
|
||||
#define DEBUGRENDER 0
|
||||
|
||||
extern inline uint32_t tfb_make_color(uint8_t red, uint8_t green, uint8_t blue);
|
||||
extern inline void tfb_draw_pixel(int x, int y, uint32_t color);
|
||||
extern inline uint32_t tfb_screen_width(void);
|
||||
|
|
@ -137,22 +139,14 @@ void tfb_fill_rect(int x, int y, int w, int h, uint32_t color)
|
|||
if (w < 0 || h < 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
for (uint32_t cy = y; cy < yend; cy++) {
|
||||
//memset(dest, color, w);
|
||||
for (uint32_t cx = x; cx < x + w; cx++)
|
||||
tfb_draw_pixel(cx, cy, color);
|
||||
}
|
||||
*/
|
||||
|
||||
w = MIN(w, MAX(0, (int)__fb_win_end_x - x));
|
||||
yend = MIN(y + h, __fb_win_end_y);
|
||||
|
||||
dest = __fb_buffer + y * __fb_pitch + (x * 4);
|
||||
|
||||
/* drm alignment weirdness */
|
||||
//if (drm)
|
||||
w *= 4;
|
||||
if (drm)
|
||||
w *= 4;
|
||||
|
||||
for (uint32_t cy = y; cy < yend; cy++, dest += __fb_pitch)
|
||||
memset(dest, color, w);
|
||||
|
|
@ -259,8 +253,6 @@ void tfb_fill_circle(int cx, int cy, int r, uint32_t color)
|
|||
tfb_draw_pixel(cx + x, cy + y, color);
|
||||
}
|
||||
|
||||
#define DEBUGRENDER 0
|
||||
|
||||
/* x and y are expected to be relative to the screen rotation, however the buffer
|
||||
* width and height won't be, we need to handle rotating the buffer here.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ static inline float getShapeWidth(const NSVGimage *font, const NSVGshape *shape)
|
|||
if (shape) {
|
||||
return shape->horizAdvX;
|
||||
} else {
|
||||
//printf("WARNING: Shape for '%s' is NULL!\n", shape->unicode ?: "");
|
||||
return font->defaultHorizAdv;
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +121,7 @@ static const char *getTextDimensions(const NSVGimage *font, const char *text, fl
|
|||
int *width, int *height)
|
||||
{
|
||||
int i, j;
|
||||
int fontHeight = (font->fontAscent - font->fontDescent) * scale;
|
||||
int fontHeight = font->fontHeight * scale;
|
||||
int maxWidth = 0;
|
||||
|
||||
if (text == NULL)
|
||||
|
|
@ -129,7 +130,7 @@ static const char *getTextDimensions(const NSVGimage *font, const char *text, fl
|
|||
// Pre-allocate 3x the size to account for any word splitting
|
||||
char *out_text = zalloc(strlen(text) * 3 + 1);
|
||||
|
||||
*width = 2; // font->defaultHorizAdv * scale;
|
||||
*width = font->defaultHorizAdv * scale;
|
||||
// The height is simply the height of the font * the scale factor
|
||||
*height = fontHeight;
|
||||
|
||||
|
|
@ -174,7 +175,7 @@ static const char *getTextDimensions(const NSVGimage *font, const char *text, fl
|
|||
line_has_space = true;
|
||||
}
|
||||
|
||||
*width += round(getShapeWidth(font, shape) * scale);
|
||||
*width += ceil(getShapeWidth(font, shape) * scale);
|
||||
}
|
||||
|
||||
*width = *width > maxWidth ? *width : maxWidth;
|
||||
|
|
|
|||
Loading…
Reference in a new issue