commit d16169765fc12c4a3a5e97b595b5fafe77243ab2 from: Onana Onana Xavier Manuel date: Sun Jun 7 04:09:00 2026 UTC Fixed font glyphs alignement commit - dce7925e4db111a53ade6365f1974faa87a67a6b commit + d16169765fc12c4a3a5e97b595b5fafe77243ab2 blob - 12fd9e67dff779157cc6973427a032b85a55df06 blob + 36e5840033333dc2939c3fdef1206d01fdc1f8c5 --- Makefile +++ Makefile @@ -12,7 +12,7 @@ SRCS= button.c \ xcb.c \ widget.c \ window.c -CFLAGS+= -fPIC -O0 -std=c99 -Werror +CFLAGS= -fPIC -O0 -std=c99 -Werror OBJS= ${SRCS:.c=.o} INCS= -I /usr/X11R6/include -I /usr/X11R6/include/freetype2 HDR= aui.h blob - 1cbbc57aac8584e88169e72a6f8dfaf2fea214b2 blob + 7a3b05d627cd9f5f83b902e24a7cb39c0c2a8f96 --- button.c +++ button.c @@ -118,7 +118,7 @@ button_set_geometry(struct aui_widget *widget, struct .height = geom->height - 2 }; struct aui_geometry tgeom = driver->ops->get_text_geometry(widget->primitives.list[2]); int tx = geom->x + geom->width / 2 - tgeom.width / 2; - int ty = geom->y + geom->height / 2 - tgeom.height / 2; + int ty = geom->y + geom->height / 2 + tgeom.height / 2; memcpy(&widget->geom, geom, sizeof(struct aui_geometry)); driver->ops->set_rectangle_geometry(widget->window, widget->primitives.list[0], geom); blob - 2f2e44ec95086e6a528f490e7d7085451c140634 blob + 8107740db41370a86a6c633928fae71d642c87e0 --- font.c +++ font.c @@ -24,8 +24,8 @@ font_init() return -1; } - font.base = find_font_fc("sans-serif"); font.size = 12; + font.base = find_font_fc("sans-serif"); if (FT_Init_FreeType(&font.ft_library) != 0) { fprintf(stderr, "libaui: FT_Init_FreeType failed!\n"); @@ -60,12 +60,13 @@ font_load_glyphs(struct glyph *gptr, unsigned int dt) } FT_Bitmap bmp = face->glyph->bitmap; + g->x = -face->glyph->bitmap_left; g->y = face->glyph->bitmap_top; g->height = bmp.rows; g->width = bmp.width; - g->x_offset = face->glyph->advance.x/64; - g->y_offset = face->glyph->advance.y/64; + g->x_offset = face->glyph->advance.x >> 6; /* 26.6 format to pixels */ + g->y_offset = face->glyph->metrics.horiBearingY >> 6; g->stride = (g->width + 3) &~3; g->bitmap = calloc(g->stride * g->height, sizeof(*g->bitmap)); blob - 32939cc0c25c8b136819e324102218f673ce70c7 blob + b88d6b81f550c899060e146947338007cd7960c5 --- xcb.c +++ xcb.c @@ -26,7 +26,7 @@ struct aui_dri_xcb { xcb_render_glyphset_t glyphset; xcb_render_picture_t glyphpic; struct glyph *glyphs; - unsigned int font_height; + int font_height; xcb_render_pictformat_t fmt_normal; xcb_render_pictformat_t fmt_alpha8; xcb_render_pictformat_t fmt_argb32; @@ -134,7 +134,7 @@ xcb_driver_open(void) .x = g->x, .y = g->y, .x_off = g->x_offset, - .y_off = g->y_offset, + .y_off = 0, /* We are only rendering horizontaly. This is unecessary */ }; xcb_render_add_glyphs( @@ -147,7 +147,8 @@ xcb_driver_open(void) g->bitmap ); - dri_xcb->font_height = (dri_xcb->font_height < g->height) ? g->height : dri_xcb->font_height; + if (dri_xcb->font_height < g->y_offset) + dri_xcb->font_height = g->y_offset; } dri_xcb->glyphpic = xcb_generate_id(dri_xcb->conn); @@ -539,8 +540,7 @@ aui_dri_get_text_geometry(struct primitive *p) } struct glyph *g = &dri_xcb->glyphs[glyphid]; - - geom.width += g->width; + geom.width += g->x_offset; } geom.height = dri_xcb->font_height;