comparison libvo/font_load_ft.c @ 21501:aecea8c8afee

Properly free fontconfig patterns
author reimar
date Wed, 06 Dec 2006 11:28:49 +0000
parents 1767c271d710
children fa99b3d31d13
comparison
equal deleted inserted replaced
21500:e7e7f397f991 21501:aecea8c8afee
1138 1138
1139 void load_font_ft(int width, int height) 1139 void load_font_ft(int width, int height)
1140 { 1140 {
1141 #ifdef HAVE_FONTCONFIG 1141 #ifdef HAVE_FONTCONFIG
1142 FcPattern *fc_pattern; 1142 FcPattern *fc_pattern;
1143 FcPattern *fc_pattern2;
1143 FcChar8 *s; 1144 FcChar8 *s;
1144 FcBool scalable; 1145 FcBool scalable;
1145 #endif 1146 #endif
1146 vo_image_width = width; 1147 vo_image_width = width;
1147 vo_image_height = height; 1148 vo_image_height = height;
1158 font_name = strdup("sans-serif"); 1159 font_name = strdup("sans-serif");
1159 FcInit(); 1160 FcInit();
1160 fc_pattern = FcNameParse(font_name); 1161 fc_pattern = FcNameParse(font_name);
1161 FcConfigSubstitute(0, fc_pattern, FcMatchPattern); 1162 FcConfigSubstitute(0, fc_pattern, FcMatchPattern);
1162 FcDefaultSubstitute(fc_pattern); 1163 FcDefaultSubstitute(fc_pattern);
1164 fc_pattern2 = fc_pattern;
1163 fc_pattern = FcFontMatch(0, fc_pattern, 0); 1165 fc_pattern = FcFontMatch(0, fc_pattern, 0);
1166 FcPatternDestroy(fc_pattern2);
1164 FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable); 1167 FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable);
1165 if (scalable != FcTrue) { 1168 if (scalable != FcTrue) {
1169 FcPatternDestroy(fc_pattern);
1166 fc_pattern = FcNameParse("sans-serif"); 1170 fc_pattern = FcNameParse("sans-serif");
1167 FcConfigSubstitute(0, fc_pattern, FcMatchPattern); 1171 FcConfigSubstitute(0, fc_pattern, FcMatchPattern);
1168 FcDefaultSubstitute(fc_pattern); 1172 FcDefaultSubstitute(fc_pattern);
1173 fc_pattern2 = fc_pattern;
1169 fc_pattern = FcFontMatch(0, fc_pattern, 0); 1174 fc_pattern = FcFontMatch(0, fc_pattern, 0);
1175 FcPatternDestroy(fc_pattern2);
1170 } 1176 }
1171 // s doesn't need to be freed according to fontconfig docs 1177 // s doesn't need to be freed according to fontconfig docs
1172 FcPatternGetString(fc_pattern, FC_FILE, 0, &s); 1178 FcPatternGetString(fc_pattern, FC_FILE, 0, &s);
1173 vo_font=read_font_desc_ft(s, width, height); 1179 vo_font=read_font_desc_ft(s, width, height);
1174 free(fc_pattern); 1180 FcPatternDestroy(fc_pattern);
1175 } 1181 }
1176 else 1182 else
1177 #endif 1183 #endif
1178 vo_font=read_font_desc_ft(font_name, width, height); 1184 vo_font=read_font_desc_ft(font_name, width, height);
1179 } 1185 }