comparison src/graph_engine_cairo.c @ 822:586e50f82c1f

Unify coding style tag for emacs and vim.
author Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
date Tue, 14 Sep 2010 01:08:39 +0800
parents e813ac222f48
children 74e3ba4d3fa1
comparison
equal deleted inserted replaced
821:bfdc82bbd6e4 822:586e50f82c1f
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
2 // vim: sw=4:ts=8:sts=4
1 #include <fontconfig/fontconfig.h> 3 #include <fontconfig/fontconfig.h>
2 #include <cairo-ft.h> 4 #include <cairo-ft.h>
3 #include "mb_graph_engine_cairo.h" 5 #include "mb_graph_engine_cairo.h"
4 #include "mb_shapes.h" 6 #include "mb_shapes.h"
5 7
35 goto err; 37 goto err;
36 38
37 val.type = FcTypeString; 39 val.type = FcTypeString;
38 val.u.s = family; 40 val.u.s = family;
39 FcPatternAdd(ptn, "family", val, FcTrue); 41 FcPatternAdd(ptn, "family", val, FcTrue);
40 42
41 val.type = FcTypeInteger; 43 val.type = FcTypeInteger;
42 val.u.i = slant_map[slant]; 44 val.u.i = slant_map[slant];
43 FcPatternAdd(ptn, "slant", val, FcTrue); 45 FcPatternAdd(ptn, "slant", val, FcTrue);
44 46
45 val.type = FcTypeInteger; 47 val.type = FcTypeInteger;
46 val.u.i = weight; 48 val.u.i = weight;
47 FcPatternAdd(ptn, "weight", val, FcTrue); 49 FcPatternAdd(ptn, "weight", val, FcTrue);
48 50
49 r = FcConfigSubstituteWithPat(cfg, ptn, NULL, FcMatchPattern); 51 r = FcConfigSubstituteWithPat(cfg, ptn, NULL, FcMatchPattern);
50 if(!r) 52 if(!r)
51 goto err; 53 goto err;
52 54
53 r = FcConfigSubstituteWithPat(cfg, p, ptn, FcMatchFont); 55 r = FcConfigSubstituteWithPat(cfg, p, ptn, FcMatchFont);
54 if(!r) 56 if(!r)
55 goto err; 57 goto err;
56 58
57 FcDefaultSubstitute(p); 59 FcDefaultSubstitute(p);
70 if(fn_ptn == NULL) 72 if(fn_ptn == NULL)
71 goto err; 73 goto err;
72 74
73 FcPatternDestroy(ptn); 75 FcPatternDestroy(ptn);
74 FcPatternDestroy(p); 76 FcPatternDestroy(p);
75 77
76 return fn_ptn; 78 return fn_ptn;
77 79
78 err: 80 err:
79 if(ptn) 81 if(ptn)
80 FcPatternDestroy(ptn); 82 FcPatternDestroy(ptn);
81 if(p) 83 if(p)
82 FcPatternDestroy(p); 84 FcPatternDestroy(p);
92 */ 94 */
93 mbe_font_face_t * 95 mbe_font_face_t *
94 mbe_query_font_face(const char *family, int slant, int weight) { 96 mbe_query_font_face(const char *family, int slant, int weight) {
95 mbe_font_face_t *cface; 97 mbe_font_face_t *cface;
96 FcPattern *ptn; 98 FcPattern *ptn;
97 99
98 ptn = query_font_pattern(family, slant, weight); 100 ptn = query_font_pattern(family, slant, weight);
99 cface = cairo_ft_font_face_create_for_pattern(ptn); 101 cface = cairo_ft_font_face_create_for_pattern(ptn);
100 FcPatternDestroy(ptn); 102 FcPatternDestroy(ptn);
101 103
102 return cface; 104 return cface;
103 } 105 }
104 106
105 void 107 void
106 mbe_free_font_face(mbe_font_face_t *face) { 108 mbe_free_font_face(mbe_font_face_t *face) {
119 121
120 ptn = cairo_pattern_create_radial(cx0, cy0, radius0, 122 ptn = cairo_pattern_create_radial(cx0, cy0, radius0,
121 cx1, cy1, radius1); 123 cx1, cy1, radius1);
122 if(ptn == NULL) 124 if(ptn == NULL)
123 return NULL; 125 return NULL;
124 126
125 stop = stops; 127 stop = stops;
126 for(i = 0; i < stop_cnt; i++) { 128 for(i = 0; i < stop_cnt; i++) {
127 cairo_pattern_add_color_stop_rgba(ptn, stop->offset, 129 cairo_pattern_add_color_stop_rgba(ptn, stop->offset,
128 stop->r, stop->g, stop->b, stop->a); 130 stop->r, stop->g, stop->b, stop->a);
129 stop++; 131 stop++;