Remove hard-coded values for font sizes.
The font body height is now explicitly stored in the font structure. This is the definition that would be used for manual typesetting (i.e. the line spacing). This is used for calculating the heights of strings. The window title header has also been increased by 3 pixels from a hard-coded 18 to (font_height + 5), which now equates to 21 pixels with the sans-10.fv1 font.
This commit is contained in:
parent
9875f0c0d8
commit
70622bf92b
@ -301,8 +301,8 @@ xrdp_painter_draw_bitmap(struct xrdp_painter *self,
|
||||
int x, int y, int cx, int cy);
|
||||
int
|
||||
xrdp_painter_text_width(struct xrdp_painter *self, const char *text);
|
||||
int
|
||||
xrdp_painter_text_height(struct xrdp_painter *self, const char *text);
|
||||
unsigned int
|
||||
xrdp_painter_font_body_height(const struct xrdp_painter *self);
|
||||
int
|
||||
xrdp_painter_draw_text(struct xrdp_painter *self,
|
||||
struct xrdp_bitmap *bitmap,
|
||||
|
@ -111,6 +111,7 @@ int
|
||||
xrdp_bitmap_set_focus(struct xrdp_bitmap *self, int focused)
|
||||
{
|
||||
struct xrdp_painter *painter = (struct xrdp_painter *)NULL;
|
||||
unsigned int font_height;
|
||||
|
||||
if (self == 0)
|
||||
{
|
||||
@ -125,19 +126,22 @@ xrdp_bitmap_set_focus(struct xrdp_bitmap *self, int focused)
|
||||
painter = xrdp_painter_create(self->wm, self->wm->session);
|
||||
xrdp_painter_font_needed(painter);
|
||||
xrdp_painter_begin_update(painter);
|
||||
font_height = xrdp_painter_font_body_height(painter);
|
||||
|
||||
if (focused)
|
||||
{
|
||||
/* active title bar */
|
||||
painter->fg_color = self->wm->blue;
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18);
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3,
|
||||
self->width - 5, font_height + 5);
|
||||
painter->fg_color = self->wm->white;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* inactive title bar */
|
||||
painter->fg_color = self->wm->dark_grey;
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18);
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3,
|
||||
self->width - 5, font_height + 5);
|
||||
painter->fg_color = self->wm->black;
|
||||
}
|
||||
|
||||
@ -616,6 +620,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
struct xrdp_rect r1;
|
||||
struct xrdp_rect r2;
|
||||
struct xrdp_painter *painter;
|
||||
unsigned int font_height;
|
||||
twchar wtext[256];
|
||||
char text[256];
|
||||
char *p;
|
||||
@ -632,6 +637,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
|
||||
painter = xrdp_painter_create(self->wm, self->wm->session);
|
||||
xrdp_painter_font_needed(painter);
|
||||
font_height = xrdp_painter_font_body_height(painter);
|
||||
painter->rop = 0xcc; /* copy */
|
||||
|
||||
if (rect == 0)
|
||||
@ -684,14 +690,16 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
{
|
||||
/* active title bar */
|
||||
painter->fg_color = self->wm->blue;
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18);
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3,
|
||||
self->width - 5, font_height + 5);
|
||||
painter->fg_color = self->wm->white;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* inactive title bar */
|
||||
painter->fg_color = self->wm->dark_grey;
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18);
|
||||
xrdp_painter_fill_rect(painter, self, 3, 3,
|
||||
self->width - 5, font_height + 5);
|
||||
painter->fg_color = self->wm->black;
|
||||
}
|
||||
|
||||
@ -742,7 +750,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
xrdp_bitmap_draw_button(self, painter, 0, 0,
|
||||
self->width, self->height, 0);
|
||||
w = xrdp_painter_text_width(painter, self->caption1);
|
||||
h = xrdp_painter_text_height(painter, self->caption1);
|
||||
h = xrdp_painter_font_body_height(painter);
|
||||
painter->fg_color = self->wm->black;
|
||||
xrdp_painter_draw_text(painter, self, self->width / 2 - w / 2,
|
||||
self->height / 2 - h / 2, self->caption1);
|
||||
@ -764,7 +772,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
xrdp_bitmap_draw_button(self, painter, 0, 0,
|
||||
self->width, self->height, 1);
|
||||
w = xrdp_painter_text_width(painter, self->caption1);
|
||||
h = xrdp_painter_text_height(painter, self->caption1);
|
||||
h = xrdp_painter_font_body_height(painter);
|
||||
painter->fg_color = self->wm->black;
|
||||
xrdp_painter_draw_text(painter, self, (self->width / 2 - w / 2) + 1,
|
||||
(self->height / 2 - h / 2) + 1, self->caption1);
|
||||
@ -941,7 +949,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
if (self->popped_from != 0)
|
||||
{
|
||||
/* change height if there are too many items in the list */
|
||||
i = xrdp_painter_text_height(painter, "W");
|
||||
i = xrdp_painter_font_body_height(painter);
|
||||
i = self->popped_from->string_list->count * i;
|
||||
|
||||
if (i > self->height)
|
||||
@ -961,7 +969,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap *self, struct xrdp_rect *rect)
|
||||
for (i = 0; i < self->popped_from->string_list->count; i++)
|
||||
{
|
||||
p = (char *)list_get_item(self->popped_from->string_list, i);
|
||||
h = xrdp_painter_text_height(painter, p);
|
||||
h = xrdp_painter_font_body_height(painter);
|
||||
self->item_height = h;
|
||||
|
||||
if (i == self->item_index)
|
||||
|
@ -157,7 +157,15 @@ xrdp_font_create(struct xrdp_wm *wm)
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
if (self->body_height == 0 && index > 32)
|
||||
{
|
||||
/* Older font made for xrdp v0.9.x. Synthesise this
|
||||
* value from the first glyph */
|
||||
self->body_height = -self->font_items[32].baseline + 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
|
@ -72,20 +72,32 @@ xrdp_wm_login_help_notify(struct xrdp_bitmap *wnd,
|
||||
|
||||
if (p != 0)
|
||||
{
|
||||
const int x = 10;
|
||||
int y = xrdp_painter_font_body_height(p) * 2;
|
||||
const int row_height = xrdp_painter_font_body_height(p);
|
||||
const int end_para_height = row_height * 3 / 2;
|
||||
|
||||
p->fg_color = wnd->wm->black;
|
||||
xrdp_painter_draw_text(p, wnd, 10, 30, "You must be authenticated \
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "You must be authenticated \
|
||||
before using this");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 46, "session.");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 78, "Enter a valid username in \
|
||||
y += row_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "session.");
|
||||
y += end_para_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "Enter a valid username in \
|
||||
the username edit box.");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 94, "Enter the password in \
|
||||
y += end_para_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "Enter the password in \
|
||||
the password edit box.");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 110, "Both the username and \
|
||||
y += end_para_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "Both the username and \
|
||||
password are case");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 126, "sensitive.");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 158, "Contact your system \
|
||||
y += row_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "sensitive.");
|
||||
y += end_para_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "Contact your system \
|
||||
administrator if you are");
|
||||
xrdp_painter_draw_text(p, wnd, 10, 174, "having problems \
|
||||
y += row_height;
|
||||
xrdp_painter_draw_text(p, wnd, x, y, "having problems \
|
||||
logging on.");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(XRDP_PAINTER)
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -464,41 +463,10 @@ xrdp_painter_text_width(struct xrdp_painter *self, const char *text)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int
|
||||
xrdp_painter_text_height(struct xrdp_painter *self, const char *text)
|
||||
unsigned int
|
||||
xrdp_painter_font_body_height(const struct xrdp_painter *self)
|
||||
{
|
||||
int index;
|
||||
int rv;
|
||||
int len;
|
||||
struct xrdp_font_char *font_item;
|
||||
twchar *wstr;
|
||||
|
||||
LOG_DEVEL(LOG_LEVEL_DEBUG, "xrdp_painter_text_height:");
|
||||
xrdp_painter_font_needed(self);
|
||||
|
||||
if (self->font == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (text == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
len = g_mbstowcs(0, text, 0);
|
||||
wstr = (twchar *)g_malloc((len + 2) * sizeof(twchar), 0);
|
||||
g_mbstowcs(wstr, text, len + 1);
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
font_item = self->font->font_items + wstr[index];
|
||||
rv = MAX(rv, font_item->height);
|
||||
}
|
||||
|
||||
g_free(wstr);
|
||||
return rv;
|
||||
return (self->font == NULL) ? 0 : self->font->body_height;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -830,7 +798,6 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
len = g_mbstowcs(0, text, 0);
|
||||
|
||||
if (len < 1)
|
||||
@ -873,7 +840,11 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
||||
font_item = font->font_items + wstr[index];
|
||||
k = font_item->incby;
|
||||
total_width += k;
|
||||
total_height = MAX(total_height, font_item->height);
|
||||
/* Use the nominal height of the font to work out the
|
||||
* actual height of this glyph */
|
||||
int glyph_height =
|
||||
font->body_height + font_item->baseline + font_item->height;
|
||||
total_height = MAX(total_height, glyph_height);
|
||||
}
|
||||
xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy);
|
||||
region = xrdp_region_create(self->wm);
|
||||
@ -912,12 +883,12 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
||||
pat.height = font_item->height;
|
||||
pat.data = font_item->data;
|
||||
x1 = x + font_item->offset;
|
||||
y1 = y + (font_item->height + font_item->baseline);
|
||||
y1 = y + (font->body_height + font_item->baseline);
|
||||
painter_fill_pattern(self->painter, &dst_pb, &pat,
|
||||
0, 0, x1, y1,
|
||||
font_item->width,
|
||||
font_item->height);
|
||||
xrdp_painter_add_dirty_rect(self, x, y,
|
||||
xrdp_painter_add_dirty_rect(self, x1, y1,
|
||||
font_item->width,
|
||||
font_item->height,
|
||||
&draw_rect);
|
||||
@ -954,7 +925,11 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
||||
data[index * 2 + 1] = k;
|
||||
k = font_item->incby;
|
||||
total_width += k;
|
||||
total_height = MAX(total_height, font_item->height);
|
||||
/* Use the nominal height of the font to work out the
|
||||
* actual height of this glyph */
|
||||
int glyph_height =
|
||||
font->body_height + font_item->baseline + font_item->height;
|
||||
total_height = MAX(total_height, glyph_height);
|
||||
}
|
||||
|
||||
xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy);
|
||||
@ -979,7 +954,7 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
||||
if (rect_intersect(&rect, &clip_rect, &draw_rect))
|
||||
{
|
||||
x1 = x;
|
||||
y1 = y + total_height;
|
||||
y1 = y + font->body_height;
|
||||
flags = 0x03; /* 0x03 0x73; TEXT2_IMPLICIT_X and something else */
|
||||
libxrdp_orders_text(self->session, f, flags, 0,
|
||||
self->fg_color, 0,
|
||||
|
@ -626,6 +626,8 @@ struct xrdp_font
|
||||
struct xrdp_font_char font_items[NUM_FONTS];
|
||||
char name[32];
|
||||
int size;
|
||||
/** Body height in pixels */
|
||||
int body_height;
|
||||
int style;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user