Fix up some kerning, use this in the panel

This commit is contained in:
K. Lange 2018-04-18 15:15:11 +09:00 committed by Kevin Lange
parent a8ddac6ff2
commit 636a3b1693
3 changed files with 63 additions and 84 deletions

View File

@ -34,6 +34,7 @@
#include <toaru/drawstring.h>
#include <toaru/hashmap.h>
#include <toaru/spinlock.h>
#include <toaru/sdf.h>
#include <kernel/mod/sound.h>
#define PANEL_HEIGHT 28
@ -399,13 +400,9 @@ static void redraw_alttab(void) {
draw_sprite_scaled(actx, icon, center_x_a(24), ALTTAB_OFFSET, 24, 24);
}
#if 0
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(14);
#endif
int t = draw_string_width(ad->name);
int t = draw_sdf_string_width(ad->name, 18);
draw_string(actx, center_x_a(t), 12+ALTTAB_OFFSET+16, rgb(255,255,255), ad->name);
draw_sdf_string(actx, center_x_a(t), 12+ALTTAB_OFFSET+16, ad->name, 18, rgb(255,255,255));
}
flip(actx);
@ -652,7 +649,7 @@ static void redraw_appmenu(int item) {
uint32_t color = (i == item) ? rgb(255,255,255) : rgb(0,0,0);
draw_string(bctx, 30, offset + 2, color, applications[i].title);
draw_sdf_string(bctx, 30, offset + 2, applications[i].title, 18, color);
offset += APPMENU_ITEM_HEIGHT;
}
@ -689,38 +686,22 @@ static void redraw(void) {
/* Hours : Minutes : Seconds */
strftime(buffer, 80, "%H:%M:%S", timeinfo);
#if 0
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(16);
#endif
draw_string(ctx, width - TIME_LEFT, 2, txt_color, buffer);
draw_sdf_string(ctx, width - TIME_LEFT, 2, buffer, 18, txt_color);
#if 0
/* Day-of-week */
strftime(buffer, 80, "%A", timeinfo);
set_font_face(FONT_SANS_SERIF);
set_font_size(9);
t = draw_string_width(buffer);
t = draw_sdf_string_width(buffer, 10);
t = (DATE_WIDTH - t) / 2;
draw_string(ctx, width - TIME_LEFT - DATE_WIDTH + t, 2, txt_color, buffer);
#endif
draw_sdf_string(ctx, width - TIME_LEFT - DATE_WIDTH + t, 2, buffer, 10, txt_color);
/* Month Day */
strftime(buffer, 80, "%h %e", timeinfo);
#if 0
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(9);
#endif
t = draw_string_width(buffer);
t = draw_sdf_string_width(buffer, 10);
t = (DATE_WIDTH - t) / 2;
draw_string(ctx, width - TIME_LEFT - DATE_WIDTH + t, 2, txt_color, buffer);
draw_sdf_string(ctx, width - TIME_LEFT - DATE_WIDTH + t, 12, buffer, 10, txt_color);
/* Applications menu */
#if 0
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(14);
#endif
draw_string(ctx, 10, 2, appmenu ? HILIGHT_COLOR : txt_color, "Applications");
draw_sdf_string(ctx, 10, 2, "Applications", 18, appmenu ? HILIGHT_COLOR : txt_color);
/* Draw each widget */
/* - Volume */
@ -768,7 +749,7 @@ static void redraw(void) {
if (!ad->name[i]) break;
}
while (draw_string_width(tmp_title) > title_width - ICON_PADDING) {
while (draw_sdf_string_width(tmp_title, 16) > title_width - ICON_PADDING) {
t_l--;
tmp_title[t_l] = '.';
tmp_title[t_l+1] = '.';
@ -804,14 +785,14 @@ static void redraw(void) {
/* Then draw the window title, with appropriate color */
if (j == focused_app) {
/* Current hilighted - title should be a light blue */
draw_string(ctx, APP_OFFSET + i + ICON_SIZE + ICON_PADDING * 2, TEXT_Y_OFFSET, HILIGHT_COLOR, s);
draw_sdf_string(ctx, APP_OFFSET + i + ICON_SIZE + ICON_PADDING * 2, TEXT_Y_OFFSET, s, 16, HILIGHT_COLOR);
} else {
if (ad->flags & 1) {
/* Top window should be white */
draw_string(ctx, APP_OFFSET + i + ICON_SIZE + ICON_PADDING * 2, TEXT_Y_OFFSET, FOCUS_COLOR, s);
draw_sdf_string(ctx, APP_OFFSET + i + ICON_SIZE + ICON_PADDING * 2, TEXT_Y_OFFSET, s, 16, FOCUS_COLOR);
} else {
/* Otherwise, off white */
draw_string(ctx, APP_OFFSET + i + ICON_SIZE + ICON_PADDING * 2, TEXT_Y_OFFSET, txt_color, s);
draw_sdf_string(ctx, APP_OFFSET + i + ICON_SIZE + ICON_PADDING * 2, TEXT_Y_OFFSET, s, 16, txt_color);
}
}
}

View File

@ -38,7 +38,7 @@ static int height = 500;
static int left = 200;
static int top = 200;
static int size = 30;
static int size = 16;
static void decors() {
render_decorations(window, ctx, "SDF Demo");
@ -49,10 +49,8 @@ void redraw() {
decors();
char tmp[100];
sprintf(tmp, "Hello, %d sized world!", size);
draw_sdf_string(ctx, 30, 30, tmp, size, rgb(0,0,0));
draw_sdf_string(ctx, 30, 30, "ABCDEFGHIJKLMNOPQRSTUVWXYZABC", size, rgb(0,0,0));
draw_sdf_string(ctx, 30, 60, "abcdefghijklmnopqrstuvwxyzabc", size, rgb(0,0,0));
}
void resize_finish(int w, int h) {

View File

@ -33,17 +33,17 @@ struct {
{'-', 35},
{'.', 35},
{'/', 35},
{'0', 35},
{'1', 35},
{'2', 35},
{'3', 35},
{'4', 35},
{'5', 35},
{'6', 35},
{'7', 35},
{'8', 35},
{'9', 35},
{':', 35},
{'0', 32},
{'1', 32},
{'2', 32},
{'3', 32},
{'4', 32},
{'5', 32},
{'6', 32},
{'7', 32},
{'8', 32},
{'9', 32},
{':', 26},
{';', 35},
{'<', 35},
{'=', 35},
@ -52,27 +52,27 @@ struct {
{'@', 50},
{'A', 35},
{'B', 35},
{'C', 35},
{'D', 35},
{'E', 35},
{'C', 34},
{'D', 36},
{'E', 34},
{'F', 35},
{'G', 35},
{'H', 35},
{'I', 35},
{'J', 35},
{'I', 22},
{'J', 26},
{'K', 35},
{'L', 35},
{'M', 40},
{'N', 35},
{'O', 35},
{'L', 32},
{'M', 45},
{'N', 36},
{'O', 38},
{'P', 35},
{'Q', 35},
{'R', 35},
{'S', 35},
{'Q', 38},
{'R', 36},
{'S', 36},
{'T', 35},
{'U', 35},
{'V', 35},
{'W', 35},
{'V', 37},
{'W', 50},
{'X', 35},
{'Y', 35},
{'Z', 35},
@ -82,36 +82,36 @@ struct {
{'^', 35},
{'_', 35},
{'`', 35},
{'a', 35},
{'b', 35},
{'c', 35},
{'a', 32},
{'b', 32},
{'c', 32},
{'d', 32},
{'e', 32},
{'f', 35},
{'g', 35},
{'h', 35},
{'f', 30},
{'g', 32},
{'h', 32},
{'i', 16},
{'j', 16},
{'k', 30},
{'l', 16},
{'m', 50},
{'n', 50},
{'m', 48},
{'n', 34},
{'o', 32},
{'p', 35},
{'q', 35},
{'p', 32},
{'q', 32},
{'r', 25},
{'s', 35},
{'t', 35},
{'u', 35},
{'v', 35},
{'s', 32},
{'t', 31},
{'u', 32},
{'v', 32},
{'w', 42},
{'x', 35},
{'y', 35},
{'z', 35},
{'{', 35},
{'|', 35},
{'}', 35},
{'~', 35},
{'x', 32},
{'y', 32},
{'z', 32},
{'{', 32},
{'|', 32},
{'}', 32},
{'~', 32},
{' ', 20},
{0,0},
};