Improve font rendering.
This commit is contained in:
1 parent
ddf98cf673
commit
0b9a244a12
2 files changed
+33
-9
No files matched your search
@@ -56,7 +56,7 @@ ifeq ($(OS),OS_MACOS)
|
||||
LIBS =
|
||||
FRAMEWORKS =
|
||||
else ifeq ($(OS),OS_LINUX)
|
||||
# FLAGS = -ggdb -DDEBUG=1 -DINTERNAL=1
|
||||
# FLAGS = -ggdb3 -O0 -DDEBUG=1 -DINTERNAL=1
|
||||
FLAGS = -O3
|
||||
INCLUDE = -I/usr/include -I/usr/X11R6/include \
|
||||
-I./libs/include/freetype2
|
||||
|
||||
@@ -361,7 +361,6 @@ draw_glyph(void *memory, int width, int height, int bytes_per_pixel,
|
||||
bitmap_width = face->glyph->bitmap.width;
|
||||
bitmap_rows = face->glyph->bitmap.rows;
|
||||
bitmap_pixels = (void *)face->glyph->bitmap.buffer;
|
||||
y -= face->glyph->bitmap_top;
|
||||
|
||||
row = 0;
|
||||
column = 0;
|
||||
@@ -452,9 +451,12 @@ draw_string(void *buffer, int width, int height,
|
||||
break;
|
||||
}
|
||||
|
||||
draw_glyph(buffer, width, height, 4, face, start_x, start_y);
|
||||
draw_glyph(buffer,
|
||||
width, height, 4, face,
|
||||
start_x + face->glyph->bitmap_left,
|
||||
start_y - face->glyph->bitmap_top);
|
||||
|
||||
start_x += face->glyph->bitmap.width;
|
||||
start_x += (face->glyph->advance.x + 32) >> 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,7 +490,7 @@ get_string_dimension(int *width, int *height, const char *str, FT_Face face)
|
||||
break;
|
||||
}
|
||||
|
||||
result_width += face->glyph->bitmap.width;
|
||||
result_width += (face->glyph->advance.x + 32) >> 6;
|
||||
if(face->glyph->bitmap.rows > (unsigned int)result_height)
|
||||
result_height = face->glyph->bitmap.rows;
|
||||
}
|
||||
@@ -544,13 +546,21 @@ render_screen(struct arena *arena,
|
||||
time_str = (char *)arena_alloc(&temp_arena, time_str_len);
|
||||
get_time_str(time_str, time_str_len);
|
||||
if(FT_Set_Pixel_Sizes(main_font_face, 0, 200) == 0) {
|
||||
int pos_x, pos_y;
|
||||
|
||||
int mwidth, mheight;
|
||||
get_string_dimension(&mwidth, &mheight, time_str, main_font_face);
|
||||
|
||||
pos_x = width/2-mwidth/2;
|
||||
if(pass_len > 0 || failure)
|
||||
pos_y = height/4+mheight/2;
|
||||
else
|
||||
pos_y = height/2+mheight/2;
|
||||
draw_string(data,
|
||||
width, height,
|
||||
time_str,
|
||||
main_font_face,
|
||||
width/2-mwidth/2, height/4+mheight/2);
|
||||
pos_x, pos_y);
|
||||
}
|
||||
|
||||
if(FT_Set_Pixel_Sizes(secondary_font_face, 0, 30) == 0) {
|
||||
@@ -564,7 +574,7 @@ render_screen(struct arena *arena,
|
||||
if(locked && failure)
|
||||
memcpy(message_str, "wrong password", 15);
|
||||
else if(locked)
|
||||
memcpy(message_str, "locked", 7);
|
||||
/*memcpy(message_str, "locked", 7);*/
|
||||
if(pass_len > 0) {
|
||||
unsigned int i;
|
||||
|
||||
@@ -612,9 +622,10 @@ static void dpms_disable(Display *dpy, struct dpms_state *state)
|
||||
&state->dpmsoff))
|
||||
{
|
||||
state->dpmsavailable = 1;
|
||||
if(state->dpmsstate)
|
||||
if(state->dpmsstate) {
|
||||
DPMSDisable(dpy);
|
||||
XSync(dpy, 0);
|
||||
XSync(dpy, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,6 +1015,19 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||
CWOverrideRedirect | CWBackPixel, &wa);
|
||||
#endif
|
||||
|
||||
/*XStoreName(dpy, lock->win, "Title");*/
|
||||
|
||||
#if DEBUG
|
||||
{
|
||||
XClassHint hint;
|
||||
hint.res_name = "testing_full";
|
||||
hint.res_class = "testing_class";
|
||||
|
||||
XSetClassHint(dpy, lock->win, &hint);
|
||||
XSync(dpy, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
XSetWindowBackground(dpy, lock->win, BlackPixel(dpy, screen));
|
||||
XClearWindow(dpy, lock->win);
|
||||
|
||||
|
||||
Reference in new issue
Block a user