diff options
Diffstat (limited to 'navit/font/freetype/font_freetype.c')
-rw-r--r-- | navit/font/freetype/font_freetype.c | 69 |
1 files changed, 19 insertions, 50 deletions
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c index 640f3619a..bb3a88d21 100644 --- a/navit/font/freetype/font_freetype.c +++ b/navit/font/freetype/font_freetype.c @@ -86,11 +86,7 @@ static int library_init = 0; static int library_deinit = 0; -static void -font_freetype_get_text_bbox(struct graphics_priv *gr, - struct font_freetype_font *font, char *text, - int dx, int dy, struct point *ret, - int estimate) { +static void font_freetype_get_text_bbox(struct graphics_priv *gr, struct font_freetype_font *font, char *text, int dx, int dy, struct point *ret, int estimate) { char *p = text; FT_BBox bbox; FT_UInt glyph_index; @@ -191,9 +187,7 @@ font_freetype_get_text_bbox(struct graphics_priv *gr, } } -static struct font_freetype_text * -font_freetype_text_new(char *text, struct font_freetype_font *font, int dx, - int dy) { +static struct font_freetype_text *font_freetype_text_new(char *text, struct font_freetype_font *font, int dx, int dy) { FT_Matrix matrix; FT_Vector pen; FT_UInt glyph_index; @@ -319,8 +313,7 @@ static char *fontfamilies[] = { NULL, }; -static void -font_destroy(struct graphics_font_priv *font) { +static void font_destroy(struct graphics_font_priv *font) { g_free(font); /* TODO: free font->face */ } @@ -330,8 +323,7 @@ static struct graphics_font_methods font_methods = { }; -static void -font_freetype_text_destroy(struct font_freetype_text *text) { +static void font_freetype_text_destroy(struct font_freetype_text *text) { int i; struct font_freetype_glyph **gp; @@ -370,10 +362,7 @@ static FT_Error face_requester( FTC_FaceID face_id, FT_Library library, FT_Point #endif /** Implementation of font_freetype_methods.font_new */ -static struct font_freetype_font * -font_freetype_font_new(struct graphics_priv *gr, - struct graphics_font_methods *meth, - char *fontfamily, int size, int flags) { +static struct font_freetype_font *font_freetype_font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags) { struct font_freetype_font *font = g_new(struct font_freetype_font, 1); int exact, found=0; @@ -413,21 +402,15 @@ font_freetype_font_new(struct graphics_priv *gr, while (*family && !found) { - dbg(lvl_info, "Looking for font family %s. exact=%d", - *family, exact); - FcPattern *required = - FcPatternBuild(NULL, FC_FAMILY, FcTypeString, - *family, NULL); + dbg(lvl_info, "Looking for font family %s. exact=%d", *family, exact); + FcPattern *required = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, *family, NULL); if (flags) - FcPatternAddInteger(required, FC_WEIGHT, - FC_WEIGHT_BOLD); - FcConfigSubstitute(FcConfigGetCurrent(), required, - FcMatchFont); + FcPatternAddInteger(required, FC_WEIGHT, FC_WEIGHT_BOLD); + FcConfigSubstitute(FcConfigGetCurrent(), required, FcMatchFont); FcDefaultSubstitute(required); FcResult result; FcPattern *matched = - FcFontMatch(FcConfigGetCurrent(), required, - &result); + FcFontMatch(FcConfigGetCurrent(), required, &result); if (matched) { FcValue v1, v2; FcChar8 *fontfile; @@ -435,17 +418,13 @@ font_freetype_font_new(struct graphics_priv *gr, FcPatternGet(required, FC_FAMILY, 0, &v1); FcPatternGet(matched, FC_FAMILY, 0, &v2); FcResult r1 = - FcPatternGetString(matched, FC_FILE, 0, - &fontfile); + FcPatternGetString(matched, FC_FILE, 0, &fontfile); FcResult r2 = - FcPatternGetInteger(matched, FC_INDEX, - 0, &fontindex); + FcPatternGetInteger(matched, FC_INDEX, 0, &fontindex); if ((r1 == FcResultMatch) && (r2 == FcResultMatch) && (FcValueEqual(v1, v2) || !exact)) { - dbg(lvl_info, - "About to load font from file %s index %d", - fontfile, fontindex); + dbg(lvl_info, "About to load font from file %s index %d", fontfile, fontindex); #if USE_CACHING idstr=g_strdup_printf("%s/%d", fontfile, fontindex); font->scaler.face_id=(FTC_FaceID)atom(idstr); @@ -464,10 +443,7 @@ font_freetype_font_new(struct graphics_priv *gr, FTC_Manager_LookupFace(manager, font->scaler.face_id, &face); font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0; #else /* USE_CACHING */ - FT_New_Face(library, - (char *) fontfile, - fontindex, - &font->face); + FT_New_Face(library, (char *) fontfile, fontindex, &font->face); #endif /* USE_CACHING */ found = 1; } @@ -527,9 +503,7 @@ font_freetype_font_new(struct graphics_priv *gr, } /** Implementation of font_freetype_methods.get_shadow. */ -static int -font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, - unsigned char *data, int stride, struct color *foreground, struct color *background) { +static int font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, unsigned char *data, int stride, struct color *foreground, struct color *background) { int x, y, w = g->w, h = g->h; unsigned int bg, fg; unsigned char *pm, *psp,*ps,*psn; @@ -581,9 +555,7 @@ font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, } /** Implementation of font_freetype_methods.get_glyph. */ -static int -font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, - unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent) { +static int font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent) { int x, y, w = g->w, h = g->h; unsigned int tr; unsigned char v,vi,*pm, *ps; @@ -617,8 +589,7 @@ font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, return 1; } -static void -font_freetype_destroy(void) { +static void font_freetype_destroy(void) { // Do not call FcFini here: GdkPixbuf also (indirectly) uses fontconfig (for SVGs with // text), but does not properly deallocate all objects, so FcFini assert()s. if (!library_deinit) { @@ -640,14 +611,12 @@ static struct font_freetype_methods methods = { font_freetype_glyph_get_glyph, }; -static struct font_priv * -font_freetype_new(void *meth) { +static struct font_priv *font_freetype_new(void *meth) { *((struct font_freetype_methods *) meth) = methods; return &dummy; } -void -plugin_init(void) { +void plugin_init(void) { plugin_register_category_font("freetype", font_freetype_new); #ifdef HAVE_FONTCONFIG FcInit(); |