@@ -144,13 +144,15 @@ GdipDeletePrivateFontCollection (GpFontCollection **font_collection)
144
144
GdipFree ((void * )* font_collection );
145
145
}
146
146
147
+ * font_collection = NULL ;
147
148
return Ok ;
148
149
}
149
150
150
151
GpStatus WINGDIPAPI
151
- GdipPrivateAddFontFile (GpFontCollection * font_collection , GDIPCONST WCHAR * filename )
152
+ GdipPrivateAddFontFile (GpFontCollection * font_collection , GDIPCONST WCHAR * filename )
152
153
{
153
154
BYTE * file ;
155
+ FILE * fileHandle ;
154
156
155
157
if (!font_collection || !filename )
156
158
return InvalidParameter ;
@@ -159,6 +161,13 @@ GdipPrivateAddFontFile (GpFontCollection *font_collection, GDIPCONST WCHAR *fil
159
161
if (!file )
160
162
return OutOfMemory ;
161
163
164
+ fileHandle = fopen ((char * )file , "r" );
165
+ if (!fileHandle ) {
166
+ GdipFree (file );
167
+ return FileNotFound ;
168
+ }
169
+
170
+ fclose (fileHandle );
162
171
FcConfigAppFontAddFile (font_collection -> config , file );
163
172
164
173
GdipFree (file );
@@ -290,13 +299,13 @@ GdipGetFontCollectionFamilyList (GpFontCollection *font_collection, INT num_soug
290
299
if (font_collection -> config )
291
300
gdip_createPrivateFontSet (font_collection );
292
301
293
- for (i = 0 ; i < font_collection -> fontset -> nfont ; i ++ ) {
302
+ for (i = 0 ; i < num_sought && i < font_collection -> fontset -> nfont ; i ++ ) {
294
303
gdip_createFontFamily (& gpfamilies [i ]);
295
304
gpfamilies [i ]-> pattern = font_collection -> fontset -> fonts [i ];
296
305
gpfamilies [i ]-> allocated = FALSE;
297
306
}
298
307
299
- * num_found = font_collection -> fontset -> nfont ;
308
+ * num_found = i ;
300
309
return Ok ;
301
310
}
302
311
@@ -1127,7 +1136,6 @@ GdipCreateFontFromLogfontW(void *hdc, GDIPCONST LOGFONTW *logfont, GpFont **font
1127
1136
GpStatus WINGDIPAPI
1128
1137
GdipPrivateAddMemoryFont (GpFontCollection * fontCollection , GDIPCONST void * memory , INT length )
1129
1138
{
1130
- FcBool result ;
1131
1139
FcChar8 fontfile [256 ];
1132
1140
int f ;
1133
1141
@@ -1152,14 +1160,12 @@ GdipPrivateAddMemoryFont(GpFontCollection *fontCollection, GDIPCONST void *memor
1152
1160
}
1153
1161
close (f );
1154
1162
1155
- /* FIXME - this doesn't seems to catch "bad" (e.g. invalid) font files */
1156
- result = FcConfigAppFontAddFile (fontCollection -> config , fontfile );
1157
-
1163
+ FcConfigAppFontAddFile (fontCollection -> config , fontfile );
1158
1164
/* FIXME - May we delete our temporary font file or does
1159
1165
FcConfigAppFontAddFile just reference our file? */
1160
1166
/* unlink(fontfile); */
1161
1167
1162
- return result ? Ok : FileNotFound ;
1168
+ return Ok ;
1163
1169
}
1164
1170
1165
1171
GpStatus WINGDIPAPI
0 commit comments