mirror of
https://github.com/mintycube/dmenu.git
synced 2024-10-22 14:05:48 +02:00
pango: add fixes for vertical alignment issues affecting CJK fonts
This commit is contained in:
parent
a686ac9b72
commit
4f71e5593e
20
drw.c
20
drw.c
@ -365,10 +365,10 @@ int
|
|||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int ty;
|
int i, ty, th;
|
||||||
unsigned int ew;
|
unsigned int ew, eh;
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
size_t i, len;
|
size_t len;
|
||||||
int render = x || y || w || h;
|
int render = x || y || w || h;
|
||||||
|
|
||||||
if (!drw || (render && !drw->scheme) || !text || !drw->font)
|
if (!drw || (render && !drw->scheme) || !text || !drw->font)
|
||||||
@ -393,10 +393,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
len = strlen(text);
|
len = strlen(text);
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
drw_font_getexts(drw->font, text, len, &ew, NULL, markup);
|
drw_font_getexts(drw->font, text, len, &ew, &eh, markup);
|
||||||
|
th = eh;
|
||||||
/* shorten text if necessary */
|
/* shorten text if necessary */
|
||||||
for (len = MIN(len, sizeof(buf) - 1); len && ew > w; len--)
|
for (len = MIN(len, sizeof(buf) - 1); len && ew > w; len--) {
|
||||||
drw_font_getexts(drw->font, text, len, &ew, NULL, markup);
|
drw_font_getexts(drw->font, text, len, &ew, &eh, markup);
|
||||||
|
if (eh > th)
|
||||||
|
th = eh;
|
||||||
|
}
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
memcpy(buf, text, len);
|
memcpy(buf, text, len);
|
||||||
@ -406,7 +410,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
; /* NOP */
|
; /* NOP */
|
||||||
|
|
||||||
if (render) {
|
if (render) {
|
||||||
ty = y + (h - drw->font->h) / 2;
|
ty = y + (h - th) / 2;
|
||||||
if (markup)
|
if (markup)
|
||||||
pango_layout_set_markup(drw->font->layout, buf, len);
|
pango_layout_set_markup(drw->font->layout, buf, len);
|
||||||
else
|
else
|
||||||
@ -650,7 +654,7 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w,
|
|||||||
if (w)
|
if (w)
|
||||||
*w = r.width / PANGO_SCALE;
|
*w = r.width / PANGO_SCALE;
|
||||||
if (h)
|
if (h)
|
||||||
*h = font->h;
|
*h = r.height / PANGO_SCALE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user