Skip to content

Commit

Permalink
use better font for chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
notsecure committed Aug 11, 2014
1 parent fdd90cc commit e237d54
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions android/freetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ static void loadfonts(void)

font_open(&font[FONT_LIST_NAME], F(12.0), 0);

font_open(&font[FONT_MSG], F(11.0), 2);
font_open(&font[FONT_MSG_NAME], F(10.0), 2);
//font_open(&font[FONT_MSG], F(11.0), 2);
//font_open(&font[FONT_MSG_NAME], F(10.0), 2);
font_open(&font[FONT_MISC], F(10.0), 0);
font_open(&font[FONT_MSG_LINK], F(11.0), 2);
//font_open(&font[FONT_MSG_LINK], F(11.0), 2);
#undef F

font_small_lineheight = (font[FONT_TEXT].face->size->metrics.height + (1 << 5)) >> 6;
font_msg_lineheight = (font[FONT_MSG].face->size->metrics.height + (1 << 5)) >> 6;
//font_msg_lineheight = (font[FONT_MSG].face->size->metrics.height + (1 << 5)) >> 6;
}

static void freefonts(void)
Expand Down
4 changes: 2 additions & 2 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ enum
FONT_TEXT,
FONT_TITLE,

FONT_MSG,
/*FONT_MSG,
FONT_MSG_NAME,
FONT_MSG_LINK,
FONT_MSG_LINK,*/

FONT_SELF_NAME,
FONT_STATUS,
Expand Down
22 changes: 11 additions & 11 deletions messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
void messages_draw(MESSAGES *m, int x, int y, int width, int height)
{
setcolor(0);
setfont(FONT_MSG);
setfont(FONT_TEXT);

uint8_t lastauthor = 0xFF;

Expand Down Expand Up @@ -32,13 +32,13 @@ void messages_draw(MESSAGES *m, int x, int y, int width, int height)
if(m->type) {
/* group */
setcolor(0);
setfont(FONT_MSG_NAME);
setfont(FONT_TEXT);
drawtextwidth_right(x, MESSAGES_X - NAME_OFFSET, y, &msg->msg[msg->length] + 1, msg->msg[msg->length]);
} else {
FRIEND *f = &friend[m->data->id];
uint8_t author = msg->flags & 1;
if(author != lastauthor) {
setfont(FONT_MSG_NAME);
setfont(FONT_TEXT);
if(!author) {
setcolor(0);
drawtextwidth_right(x, MESSAGES_X - NAME_OFFSET, y, f->name, f->name_length);
Expand Down Expand Up @@ -80,8 +80,8 @@ void messages_draw(MESSAGES *m, int x, int y, int width, int height)
h2 = 0xFFFF;
}

setfont(FONT_MSG);
int ny = drawtextmultiline(x + MESSAGES_X, x + width - TIME_WIDTH, y, y, y + msg->height, font_msg_lineheight, msg->msg, msg->length, h1, h2 - h1, 1);
setfont(FONT_TEXT);
int ny = drawtextmultiline(x + MESSAGES_X, x + width - TIME_WIDTH, y, y, y + msg->height, font_small_lineheight, msg->msg, msg->length, h1, h2 - h1, 1);
if(ny - y != msg->height - MESSAGES_SPACING) {
debug("error101 %u %u\n", ny -y, msg->height - MESSAGES_SPACING);
}
Expand Down Expand Up @@ -215,7 +215,7 @@ _Bool messages_mmove(MESSAGES *m, int px, int py, int width, int height, int mx,
return 0;
}

setfont(FONT_MSG);
setfont(FONT_TEXT);

void **p = m->data->data;
int i = 0, n = m->data->n;
Expand All @@ -233,7 +233,7 @@ _Bool messages_mmove(MESSAGES *m, int px, int py, int width, int height, int mx,
case 2:
case 3: {
/* normal message */
m->over = hittextmultiline(mx - MESSAGES_X, width - MESSAGES_X - TIME_WIDTH, my < 0 ? 0 : my, msg->height, font_msg_lineheight, msg->msg, msg->length, 1);
m->over = hittextmultiline(mx - MESSAGES_X, width - MESSAGES_X - TIME_WIDTH, my < 0 ? 0 : my, msg->height, font_small_lineheight, msg->msg, msg->length, 1);
m->urlover = 0xFFFF;

if(my < 0 || my >= dy || mx < MESSAGES_X || m->over == msg->length) {
Expand Down Expand Up @@ -693,7 +693,7 @@ static int msgheight(MESSAGE *msg, int width)
case 1:
case 2:
case 3: {
return text_height(width - MESSAGES_X - TIME_WIDTH, font_msg_lineheight, msg->msg, msg->length) + MESSAGES_SPACING;
return text_height(width - MESSAGES_X - TIME_WIDTH, font_small_lineheight, msg->msg, msg->length) + MESSAGES_SPACING;
}

case 4:
Expand All @@ -720,7 +720,7 @@ void messages_updateheight(MESSAGES *m)
return;
}

setfont(FONT_MSG);
setfont(FONT_TEXT);

uint32_t height = 0;
int i = 0;
Expand All @@ -743,7 +743,7 @@ static void message_setheight(MESSAGES *m, MESSAGE *msg, MSG_DATA *p)
return;
}

setfont(FONT_MSG);
setfont(FONT_TEXT);

msg->height = msgheight(msg, m->width);
p->height += msg->height;
Expand All @@ -758,7 +758,7 @@ void message_updateheight(MESSAGES *m, MESSAGE *msg, MSG_DATA *p)
return;
}

setfont(FONT_MSG);
setfont(FONT_TEXT);

p->height -= msg->height;
msg->height = msgheight(msg, m->width);
Expand Down
10 changes: 5 additions & 5 deletions win32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,22 +1007,22 @@ void setscale(void)
font[FONT_SELF_NAME] = CreateFontIndirect(&lf);
lf.lfHeight = F(10);
font[FONT_MISC] = CreateFontIndirect(&lf);
lf.lfWeight = FW_NORMAL; //FW_LIGHT <- light fonts dont antialias
/*lf.lfWeight = FW_NORMAL; //FW_LIGHT <- light fonts dont antialias
font[FONT_MSG_NAME] = CreateFontIndirect(&lf);
lf.lfHeight = F(11);
font[FONT_MSG] = CreateFontIndirect(&lf);
lf.lfUnderline = 1;
font[FONT_MSG_LINK] = CreateFontIndirect(&lf);
font[FONT_MSG_LINK] = CreateFontIndirect(&lf);*/

#undef F

TEXTMETRIC tm;
SelectObject(hdc, font[FONT_TEXT]);
GetTextMetrics(hdc, &tm);
font_small_lineheight = tm.tmHeight + tm.tmExternalLeading;
SelectObject(hdc, font[FONT_MSG]);
GetTextMetrics(hdc, &tm);
font_msg_lineheight = tm.tmHeight + tm.tmExternalLeading;
//SelectObject(hdc, font[FONT_MSG]);
//GetTextMetrics(hdc, &tm);
//font_msg_lineheight = tm.tmHeight + tm.tmExternalLeading;

svg_draw(1);
}
Expand Down
6 changes: 3 additions & 3 deletions xlib/freetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ static void loadfonts(void)

font_open(&font[FONT_LIST_NAME], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(12.0), NULL);

font_open(&font[FONT_MSG], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(11.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL);
font_open(&font[FONT_MSG_NAME], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(10.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL);
//font_open(&font[FONT_MSG], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(11.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL);
//font_open(&font[FONT_MSG_NAME], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(10.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL);
font_open(&font[FONT_MISC], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(10.0), NULL);
font_open(&font[FONT_MSG_LINK], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(11.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL);
//font_open(&font[FONT_MSG_LINK], FC_FAMILY, FcTypeString, "Roboto", FC_PIXEL_SIZE, FcTypeDouble, F(11.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL);
#undef F
}

Expand Down
2 changes: 1 addition & 1 deletion xlib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void setscale(void)
loadfonts();

font_small_lineheight = (font[FONT_TEXT].info[0].face->size->metrics.height + (1 << 5)) >> 6;
font_msg_lineheight = (font[FONT_MSG].info[0].face->size->metrics.height + (1 << 5)) >> 6;
//font_msg_lineheight = (font[FONT_MSG].info[0].face->size->metrics.height + (1 << 5)) >> 6;

if(xsh) {
XFree(xsh);
Expand Down

0 comments on commit e237d54

Please sign in to comment.