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/drawstring.h>
#include <toaru/hashmap.h> #include <toaru/hashmap.h>
#include <toaru/spinlock.h> #include <toaru/spinlock.h>
#include <toaru/sdf.h>
#include <kernel/mod/sound.h> #include <kernel/mod/sound.h>
#define PANEL_HEIGHT 28 #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); draw_sprite_scaled(actx, icon, center_x_a(24), ALTTAB_OFFSET, 24, 24);
} }
#if 0 int t = draw_sdf_string_width(ad->name, 18);
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(14);
#endif
int t = draw_string_width(ad->name);
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); 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); 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; offset += APPMENU_ITEM_HEIGHT;
} }
@ -689,38 +686,22 @@ static void redraw(void) {
/* Hours : Minutes : Seconds */ /* Hours : Minutes : Seconds */
strftime(buffer, 80, "%H:%M:%S", timeinfo); strftime(buffer, 80, "%H:%M:%S", timeinfo);
#if 0 draw_sdf_string(ctx, width - TIME_LEFT, 2, buffer, 18, txt_color);
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(16);
#endif
draw_string(ctx, width - TIME_LEFT, 2, txt_color, buffer);
#if 0
/* Day-of-week */ /* Day-of-week */
strftime(buffer, 80, "%A", timeinfo); strftime(buffer, 80, "%A", timeinfo);
set_font_face(FONT_SANS_SERIF); t = draw_sdf_string_width(buffer, 10);
set_font_size(9);
t = draw_string_width(buffer);
t = (DATE_WIDTH - t) / 2; 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, 2, buffer, 10, txt_color);
#endif
/* Month Day */ /* Month Day */
strftime(buffer, 80, "%h %e", timeinfo); strftime(buffer, 80, "%h %e", timeinfo);
#if 0 t = draw_sdf_string_width(buffer, 10);
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(9);
#endif
t = draw_string_width(buffer);
t = (DATE_WIDTH - t) / 2; 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 */ /* Applications menu */
#if 0 draw_sdf_string(ctx, 10, 2, "Applications", 18, appmenu ? HILIGHT_COLOR : txt_color);
set_font_face(FONT_SANS_SERIF_BOLD);
set_font_size(14);
#endif
draw_string(ctx, 10, 2, appmenu ? HILIGHT_COLOR : txt_color, "Applications");
/* Draw each widget */ /* Draw each widget */
/* - Volume */ /* - Volume */
@ -768,7 +749,7 @@ static void redraw(void) {
if (!ad->name[i]) break; 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--; t_l--;
tmp_title[t_l] = '.'; tmp_title[t_l] = '.';
tmp_title[t_l+1] = '.'; tmp_title[t_l+1] = '.';
@ -804,14 +785,14 @@ static void redraw(void) {
/* Then draw the window title, with appropriate color */ /* Then draw the window title, with appropriate color */
if (j == focused_app) { if (j == focused_app) {
/* Current hilighted - title should be a light blue */ /* 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 { } else {
if (ad->flags & 1) { if (ad->flags & 1) {
/* Top window should be white */ /* 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 { } else {
/* Otherwise, off white */ /* 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 left = 200;
static int top = 200; static int top = 200;
static int size = 30; static int size = 16;
static void decors() { static void decors() {
render_decorations(window, ctx, "SDF Demo"); render_decorations(window, ctx, "SDF Demo");
@ -49,10 +49,8 @@ void redraw() {
decors(); decors();
char tmp[100]; draw_sdf_string(ctx, 30, 30, "ABCDEFGHIJKLMNOPQRSTUVWXYZABC", size, rgb(0,0,0));
sprintf(tmp, "Hello, %d sized world!", size); draw_sdf_string(ctx, 30, 60, "abcdefghijklmnopqrstuvwxyzabc", size, rgb(0,0,0));
draw_sdf_string(ctx, 30, 30, tmp, size, rgb(0,0,0));
} }
void resize_finish(int w, int h) { void resize_finish(int w, int h) {

View File

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