/* See the FT2 documentation - this builds an error table */ #undef FTERRORS_H_ #define FT_ERRORDEF( e, v, s ) { e, s }, #define FT_ERROR_START_LIST { #define FT_ERROR_END_LIST { 0, NULL } };
staticconststruct
{ int err_code; constchar *err_msg;
} ft_errors[] = #include <freetype/fterrors.h> #ifdef __cppcheck__ // avoid syntaxError by providing the array contents
{}; #endif
/**************************************************************************//**
* Parses a unicode character value
*
* @param str String containing value
* @return Resulting character value
*/ staticunsignedint
parse_ucode_name(constchar *str)
{ unsignedint rv; if (toupper(str[0]) == 'U' && str[1] == '+')
{ char *hex = g_strdup(str);
hex[0] = '0';
hex[1] = 'x';
rv = g_atoix(hex);
g_free(hex);
} elseif (str[0] == '@')
{
rv = str[1];
} else
{
rv = g_atoix(str);
} return rv;
}
/**************************************************************************//**
* Parses the program args
*
* @param argc Passed to main
* @param @argv Passed to main
* @param pa program_pargs structure for resulting values
* @return !=0for success
*/ staticint
parse_program_args(int argc, char *argv[], struct program_args *pa)
{ int params_ok = 1; int opt;
/**************************************************************************//**
* Implement sans10 compatibility for a glyph
*
* The original Windows font generator made a few different choices for the
* character x offset than freetype2 does. These are particularly noticeable
* with a small font.
*
* This routine checks the glyph, and implements the original offset size
* for popular English characters, which are all that the user will probably
* be displaying with xrdp v0.9.x
*
* @param g Glyph to check
*/ staticvoid
implement_sans10_compatibility(struct fv1_glyph *g, unsignedint ucode)
{ constunsignedint max_index = sizeof(original_sans10_data) / sizeof(original_sans10_data[0]);
if (g->offset != d->offset)
{ if (g->width != d->width)
{
LOG(LOG_LEVEL_WARNING, "Can't set compatibility offset for U+%04X: width %d != %d",
ucode, g->width, d->width);
} elseif (g->inc_by != d->inc_by)
{
LOG(LOG_LEVEL_WARNING, "Can't set compatibility offset for U+%04X: inc_by %d != %d",
ucode, g->inc_by, d->inc_by);
} else
{
LOG(LOG_LEVEL_INFO, "Changing compatibility offset for U+%04X: from %d to %d",
ucode, g->offset, d->offset);
}
g->offset = d->offset;
}
}
/**************************************************************************//**
* Converts a freetype 2 bitmap to a fv1 glyph
* @param ft_glyph Freetype2 glyph. Must be a monochrome bitmap
* @param ucode Unicode character for error reporting
* @param pa Program args
* @return fv1 glyph, or NULL for error
*/ staticstruct fv1_glyph *
convert_mono_glyph(FT_GlyphSlot ft_glyph, unsignedint ucode, conststruct program_args *pa)
{ short width = ft_glyph->bitmap.width; short height = ft_glyph->bitmap.rows; struct fv1_glyph *g;
/* Number of bytes in a glyph row */ constunsignedint glyph_row_size = ((width + 7) / 8);
for (y = 0; y < g->height; ++y)
{
g_memcpy(dstptr, srcptr, glyph_row_size);
dstptr += glyph_row_size;
srcptr += ft_glyph->bitmap.pitch;
}
/* Optimise the glyph by removing any blank lines at the bottom
* and top */ if (g->width > 0)
{ while (g->height > 0 &&
is_blank_glyph_row(g, g->height - 1))
{
--g->height;
}
y = 0; while (y < g->height && is_blank_glyph_row(g, y))
{
++y;
}
unsignedint u; for (u = FV1_MIN_CHAR; u <= pa.max_ucode; ++u)
{ /* retrieve glyph index from character code */
FT_UInt glyph_index = FT_Get_Char_Index(face, u);
/* load glyph image into the slot (erase previous one) */
error = FT_Load_Glyph(face, glyph_index,
FT_LOAD_RENDER | FT_LOAD_TARGET_MONO); if (error)
{
get_ft_error(error, errstr, sizeof(errstr));
LOG(LOG_LEVEL_WARNING, "Unable to get bitmap for U+%04X %s", u, errstr);
g = NULL;
} elseif (face->glyph->format != FT_GLYPH_FORMAT_BITMAP ||
face->glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO)
{
LOG(LOG_LEVEL_WARNING, "Internal error; U+%04X was not loaded as a bitmap",
u);
g = NULL;
} else
{
g = convert_mono_glyph(face->glyph, u, &pa);
}
list_add_item(fv1->glyphs, (tintptr)g);
}
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.