while (p != NULL)
{ /* DPI value must be next in string */ if (!isdigit(*p))
{
bad_selector = 1; break;
} unsignedint field_dpi = g_atoi(p); if (field_dpi <= dpi)
{ /* Use this font */
p = g_strchr(p, ':'); if (p == NULL)
{
bad_selector = 1;
} else
{
++p; constchar *q = g_strchr(p, ','); if (q == NULL)
{
q = p + g_strlen(p);
} if (q - p > (font_name_len - 1))
{
q = p + font_name_len - 1;
}
g_memcpy(font_name, p, q - p);
font_name[q - p] = '\0';
} break;
} else
{
p = g_strchr(p, ','); if (p != NULL)
{
++p;
}
}
}
if (bad_selector)
{
LOG(LOG_LEVEL_WARNING, "Unable to parse fv1_select configuration");
}
if (font_name[0] == '\0')
{
LOG(LOG_LEVEL_WARNING, "Loading default font " DEFAULT_FONT_NAME);
g_snprintf(font_name, font_name_len, DEFAULT_FONT_NAME);
}
}
/*****************************************************************************/ struct xrdp_font *
xrdp_font_create(struct xrdp_wm *wm, unsignedint dpi)
{ struct xrdp_font *self; struct stream *s; int fd; int b; int i; unsignedint char_count; unsignedint datasize; // Size of glyph data on disk int file_size; struct xrdp_font_char *f; constchar *file_path; char file_path_buff[256]; int min_descender; char font_name[256]; conststruct xrdp_cfg_globals *globals = &wm->xrdp_config->cfg_globals;
LOG_DEVEL(LOG_LEVEL_TRACE, "in xrdp_font_create");
if (dpi == 0)
{
LOG(LOG_LEVEL_WARNING, "No DPI value is available to find login font");
dpi = globals->default_dpi;
LOG(LOG_LEVEL_WARNING, "Using the default_dpi of %u", dpi);
}
get_font_name_from_dpi(globals, dpi, font_name, sizeof(font_name));
if (!g_file_exist(file_path))
{ /* Try to fall back to the default */ constchar *default_file_path = XRDP_SHARE_PATH "/" DEFAULT_FONT_NAME; if (g_file_exist(default_file_path))
{
LOG(LOG_LEVEL_WARNING, "xrdp_font_create: font file [%s] does not exist - using [%s]",
file_path, default_file_path);
file_path = default_file_path;
} else
{
LOG(LOG_LEVEL_ERROR, "xrdp_font_create: Can't load either [%s] or [%s]",
file_path, default_file_path); return0;
}
}
file_size = g_file_get_size(file_path);
if (file_size < 1)
{
LOG(LOG_LEVEL_ERROR, "xrdp_font_create: error reading font from file [%s]",
file_path); return0;
}
if (fd < 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_font_create: Can't open %s - %s", file_path,
g_get_strerror());
g_free(self);
self = NULL;
} else
{
b = g_file_read(fd, s->data, file_size + 1024);
g_file_close(fd);
// Got at least a header? if (b < (4 + 32 + 2 + 2 + 2 + 2 + 4))
{
LOG(LOG_LEVEL_ERROR, "xrdp_font_create: Font %s is truncated", file_path);
g_free(self);
self = NULL;
} else
{
s->end = s->data + b;
in_uint8s(s, 4);
in_uint8a(s, self->name, 32);
in_uint16_le(s, self->size);
in_uint16_le(s, self->style);
in_uint16_le(s, self->body_height);
in_sint16_le(s, min_descender);
in_uint8s(s, 4);
char_count = FIRST_CHAR;
while (!s_check_end(s))
{ if (!s_check_rem(s, 16))
{
LOG(LOG_LEVEL_WARNING, "xrdp_font_create: " "Can't parse header for character U+%X", char_count); break;
}
if (!s_check_rem(s, datasize))
{
LOG(LOG_LEVEL_ERROR, "xrdp_font_create: " "Not enough data for character U+%X", char_count); break;
}
if (datasize == 0)
{ /* Allocate a single blank pixel for the glyph, so
* that it can be added to the glyph cache if required */
f->width = 1;
f->height = 1;
/* GOTCHA - we need to allocate more than one byte in
* memory for this glyph */
f->data = (char *)g_malloc(FONT_DATASIZE(f), 1);
} else
{
f->data = (char *)g_malloc(datasize, 0);
}
if (f->data == NULL)
{
LOG(LOG_LEVEL_ERROR, "xrdp_font_create: " "Allocation error for character U+%X", char_count); break;
}
in_uint8a(s, f->data, datasize);
++char_count;
}
self->char_count = char_count; if (char_count <= FIRST_CHAR)
{ /* We read no characters from the font */
xrdp_font_delete(self);
self = NULL;
} else
{ if (self->body_height == 0)
{ /* Older font made for xrdp v0.9.x. Synthesise this
* value from the first glyph */
self->body_height = -self->chars[FIRST_CHAR].baseline + 1;
}
/*****************************************************************************/ /* free the font and all the items */ void
xrdp_font_delete(struct xrdp_font *self)
{ unsignedint i;
if (self == 0)
{ return;
}
for (i = FIRST_CHAR; i < self->char_count; i++)
{
g_free(self->chars[i].data);
}
g_free(self);
}
/*****************************************************************************/ /* compare the two font items returns 1 if they match */ int
xrdp_font_item_compare(struct xrdp_font_char *font1, struct xrdp_font_char *font2)
{ int datasize;
if (font1 == 0)
{ return0;
}
if (font2 == 0)
{ return0;
}
if (font1->offset != font2->offset)
{ return0;
}
if (font1->baseline != font2->baseline)
{ return0;
}
if (font1->width != font2->width)
{ return0;
}
if (font1->height != font2->height)
{ return0;
}
datasize = FONT_DATASIZE(font1);
if (g_memcmp(font1->data, font2->data, datasize) == 0)
{ return1;
}
return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet am 2026-07-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.