push 337eb2e2d902d84a5d689451984c5832d7e04fc4
[wine/hacks.git] / dlls / gdiplus / font.c
blob220409b7a05bbdcc6409cd20580adfe8274b264e
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "wingdi.h"
24 #include "winnls.h"
25 #include "winreg.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
29 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus);
31 #include "objbase.h"
33 #include "gdiplus.h"
34 #include "gdiplus_private.h"
36 static const REAL mm_per_inch = 25.4;
37 static const REAL inch_per_point = 1.0/72.0;
39 static inline REAL get_dpi (void)
41 REAL dpi;
42 GpGraphics *graphics;
43 HDC hdc = GetDC(0);
44 GdipCreateFromHDC (hdc, &graphics);
45 GdipGetDpiX(graphics, &dpi);
46 GdipDeleteGraphics(graphics);
47 ReleaseDC (0, hdc);
49 return dpi;
52 static inline REAL point_to_pixel (REAL point)
54 return point * get_dpi() * inch_per_point;
57 static inline REAL inch_to_pixel (REAL inch)
59 return inch * get_dpi();
62 static inline REAL document_to_pixel (REAL doc)
64 return doc * (get_dpi() / 300.0); /* Per MSDN */
67 static inline REAL mm_to_pixel (REAL mm)
69 return mm * (get_dpi() / mm_per_inch);
72 /*******************************************************************************
73 * GdipCreateFont [GDIPLUS.@]
75 * Create a new font based off of a FontFamily
77 * PARAMS
78 * *fontFamily [I] Family to base the font off of
79 * emSize [I] Size of the font
80 * style [I] Bitwise OR of FontStyle enumeration
81 * unit [I] Unit emSize is measured in
82 * **font [I] the resulting Font object
84 * RETURNS
85 * SUCCESS: Ok
86 * FAILURE: InvalidParameter if fontfamily or font is NULL.
87 * FAILURE: FontFamilyNotFound if an invalid FontFamily is given
89 * NOTES
90 * UnitDisplay is unsupported.
91 * emSize is stored separately from lfHeight, to hold the fraction.
93 GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
94 REAL emSize, INT style, Unit unit, GpFont **font)
96 WCHAR facename[LF_FACESIZE];
97 LOGFONTW* lfw;
98 const NEWTEXTMETRICW* tmw;
99 GpStatus stat;
101 if (!fontFamily || !font)
102 return InvalidParameter;
104 TRACE("%p (%s), %f, %d, %d, %p\n", fontFamily,
105 debugstr_w(fontFamily->FamilyName), emSize, style, unit, font);
107 stat = GdipGetFamilyName (fontFamily, facename, 0);
108 if (stat != Ok) return stat;
109 *font = GdipAlloc(sizeof(GpFont));
111 tmw = &fontFamily->tmw;
112 lfw = &((*font)->lfw);
113 ZeroMemory(&(*lfw), sizeof(*lfw));
115 lfw->lfWeight = tmw->tmWeight;
116 lfw->lfItalic = tmw->tmItalic;
117 lfw->lfUnderline = tmw->tmUnderlined;
118 lfw->lfStrikeOut = tmw->tmStruckOut;
119 lfw->lfCharSet = tmw->tmCharSet;
120 lfw->lfPitchAndFamily = tmw->tmPitchAndFamily;
121 lstrcpynW(lfw->lfFaceName, facename, LF_FACESIZE);
123 switch (unit)
125 case UnitWorld:
126 /* FIXME: Figure out when World != Pixel */
127 lfw->lfHeight = emSize; break;
128 case UnitDisplay:
129 FIXME("Unknown behavior for UnitDisplay! Please report!\n");
130 /* FIXME: Figure out how this works...
131 * MSDN says that if "DISPLAY" is a monitor, then pixel should be
132 * used. That's not what I got. Tests on Windows revealed no output,
133 * and the tests in tests/font crash windows */
134 lfw->lfHeight = 0; break;
135 case UnitPixel:
136 lfw->lfHeight = emSize; break;
137 case UnitPoint:
138 lfw->lfHeight = point_to_pixel(emSize); break;
139 case UnitInch:
140 lfw->lfHeight = inch_to_pixel(emSize); break;
141 case UnitDocument:
142 lfw->lfHeight = document_to_pixel(emSize); break;
143 case UnitMillimeter:
144 lfw->lfHeight = mm_to_pixel(emSize); break;
147 lfw->lfHeight *= -1;
149 lfw->lfWeight = style & FontStyleBold ? 700 : 400;
150 lfw->lfItalic = style & FontStyleItalic;
151 lfw->lfUnderline = style & FontStyleUnderline;
152 lfw->lfStrikeOut = style & FontStyleStrikeout;
154 (*font)->unit = unit;
155 (*font)->emSize = emSize;
156 (*font)->height = tmw->ntmSizeEM;
157 (*font)->line_spacing = tmw->tmAscent + tmw->tmDescent + tmw->tmExternalLeading;
159 return Ok;
162 /*******************************************************************************
163 * GdipCreateFontFromLogfontW [GDIPLUS.@]
165 GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
166 GDIPCONST LOGFONTW *logfont, GpFont **font)
168 HFONT hfont, oldfont;
169 TEXTMETRICW textmet;
171 TRACE("(%p, %p, %p)\n", hdc, logfont, font);
173 if(!logfont || !font)
174 return InvalidParameter;
176 if (logfont->lfFaceName[0] == 0)
177 return NotTrueTypeFont;
179 *font = GdipAlloc(sizeof(GpFont));
180 if(!*font) return OutOfMemory;
182 memcpy((*font)->lfw.lfFaceName, logfont->lfFaceName, LF_FACESIZE *
183 sizeof(WCHAR));
184 (*font)->lfw.lfHeight = logfont->lfHeight;
185 (*font)->lfw.lfItalic = logfont->lfItalic;
186 (*font)->lfw.lfUnderline = logfont->lfUnderline;
187 (*font)->lfw.lfStrikeOut = logfont->lfStrikeOut;
189 (*font)->emSize = logfont->lfHeight;
190 (*font)->unit = UnitPixel;
192 hfont = CreateFontIndirectW(&(*font)->lfw);
193 oldfont = SelectObject(hdc, hfont);
194 GetTextMetricsW(hdc, &textmet);
196 (*font)->lfw.lfHeight = -textmet.tmHeight;
197 (*font)->lfw.lfWeight = textmet.tmWeight;
199 (*font)->height = 1; /* FIXME: need NEWTEXTMETRIC.ntmSizeEM here */
200 (*font)->line_spacing = textmet.tmAscent + textmet.tmDescent + textmet.tmExternalLeading;
202 SelectObject(hdc, oldfont);
203 DeleteObject(hfont);
205 return Ok;
208 /*******************************************************************************
209 * GdipCreateFontFromLogfontA [GDIPLUS.@]
211 GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc,
212 GDIPCONST LOGFONTA *lfa, GpFont **font)
214 LOGFONTW lfw;
216 TRACE("(%p, %p, %p)\n", hdc, lfa, font);
218 if(!lfa || !font)
219 return InvalidParameter;
221 memcpy(&lfw, lfa, FIELD_OFFSET(LOGFONTA,lfFaceName) );
223 if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE))
224 return GenericError;
226 GdipCreateFontFromLogfontW(hdc, &lfw, font);
228 return Ok;
231 /*******************************************************************************
232 * GdipDeleteFont [GDIPLUS.@]
234 GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
236 TRACE("(%p)\n", font);
238 if(!font)
239 return InvalidParameter;
241 GdipFree(font);
243 return Ok;
246 /*******************************************************************************
247 * GdipCreateFontFromDC [GDIPLUS.@]
249 GpStatus WINGDIPAPI GdipCreateFontFromDC(HDC hdc, GpFont **font)
251 HFONT hfont;
252 LOGFONTW lfw;
254 TRACE("(%p, %p)\n", hdc, font);
256 if(!font)
257 return InvalidParameter;
259 hfont = GetCurrentObject(hdc, OBJ_FONT);
260 if(!hfont)
261 return GenericError;
263 if(!GetObjectW(hfont, sizeof(LOGFONTW), &lfw))
264 return GenericError;
266 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
269 /*******************************************************************************
270 * GdipGetFamily [GDIPLUS.@]
272 * Returns the FontFamily for the specified Font
274 * PARAMS
275 * font [I] Font to request from
276 * family [O] Resulting FontFamily object
278 * RETURNS
279 * SUCCESS: Ok
280 * FAILURE: An element of GpStatus
282 GpStatus WINGDIPAPI GdipGetFamily(GpFont *font, GpFontFamily **family)
284 TRACE("%p %p\n", font, family);
286 if (!(font && family))
287 return InvalidParameter;
289 return GdipCreateFontFamilyFromName(font->lfw.lfFaceName, NULL, family);
292 /******************************************************************************
293 * GdipGetFontSize [GDIPLUS.@]
295 * Returns the size of the font in Units
297 * PARAMS
298 * *font [I] The font to retrieve size from
299 * *size [O] Pointer to hold retrieved value
301 * RETURNS
302 * SUCCESS: Ok
303 * FAILURE: InvalidParamter (font or size was NULL)
305 * NOTES
306 * Size returned is actually emSize -- not internal size used for drawing.
308 GpStatus WINGDIPAPI GdipGetFontSize(GpFont *font, REAL *size)
310 TRACE("(%p, %p)\n", font, size);
312 if (!(font && size)) return InvalidParameter;
314 *size = font->emSize;
316 return Ok;
319 /*******************************************************************************
320 * GdipGetFontStyle [GDIPLUS.@]
322 * Gets the font's style, returned in bitwise OR of FontStyle enumeration
324 * PARAMS
325 * font [I] font to request from
326 * style [O] resulting pointer to a FontStyle enumeration
328 * RETURNS
329 * SUCCESS: Ok
330 * FAILURE: InvalidParameter
332 GpStatus WINGDIPAPI GdipGetFontStyle(GpFont *font, INT *style)
334 TRACE("%p %p\n", font, style);
336 if (!(font && style))
337 return InvalidParameter;
339 if (font->lfw.lfWeight > 400)
340 *style = FontStyleBold;
341 else
342 *style = 0;
343 if (font->lfw.lfItalic)
344 *style |= FontStyleItalic;
345 if (font->lfw.lfUnderline)
346 *style |= FontStyleUnderline;
347 if (font->lfw.lfStrikeOut)
348 *style |= FontStyleStrikeout;
350 return Ok;
353 /*******************************************************************************
354 * GdipGetFontUnit [GDIPLUS.@]
356 * PARAMS
357 * font [I] Font to retrieve from
358 * unit [O] Return value
360 * RETURNS
361 * FAILURE: font or unit was NULL
362 * OK: otherwise
364 GpStatus WINGDIPAPI GdipGetFontUnit(GpFont *font, Unit *unit)
366 TRACE("(%p, %p)\n", font, unit);
368 if (!(font && unit)) return InvalidParameter;
370 *unit = font->unit;
372 return Ok;
375 /*******************************************************************************
376 * GdipGetLogFontW [GDIPLUS.@]
378 GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics,
379 LOGFONTW *lfw)
381 TRACE("(%p, %p, %p)\n", font, graphics, lfw);
383 /* FIXME: use graphics */
384 if(!font || !graphics || !lfw)
385 return InvalidParameter;
387 *lfw = font->lfw;
389 return Ok;
392 /*******************************************************************************
393 * GdipCloneFont [GDIPLUS.@]
395 GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
397 TRACE("(%p, %p)\n", font, cloneFont);
399 if(!font || !cloneFont)
400 return InvalidParameter;
402 *cloneFont = GdipAlloc(sizeof(GpFont));
403 if(!*cloneFont) return OutOfMemory;
405 **cloneFont = *font;
407 return Ok;
410 /*******************************************************************************
411 * GdipGetFontHeight [GDIPLUS.@]
412 * PARAMS
413 * font [I] Font to retrieve height from
414 * graphics [I] The current graphics context
415 * height [O] Resulting height
416 * RETURNS
417 * SUCCESS: Ok
418 * FAILURE: Another element of GpStatus
420 * NOTES
421 * Forwards to GdipGetFontHeightGivenDPI
423 GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font,
424 GDIPCONST GpGraphics *graphics, REAL *height)
426 REAL dpi;
428 TRACE("%p %p %p\n", font, graphics, height);
430 dpi = GetDeviceCaps(graphics->hdc, LOGPIXELSY);
432 return GdipGetFontHeightGivenDPI(font, dpi, height);
435 /*******************************************************************************
436 * GdipGetFontHeightGivenDPI [GDIPLUS.@]
437 * PARAMS
438 * font [I] Font to retrieve DPI from
439 * dpi [I] DPI to assume
440 * height [O] Return value
442 * RETURNS
443 * SUCCESS: Ok
444 * FAILURE: InvalidParameter if font or height is NULL
446 * NOTES
447 * According to MSDN, the result is (lineSpacing)*(fontSize / emHeight)*dpi
448 * (for anything other than unit Pixel)
450 GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
452 REAL font_height;
454 TRACE("%p (%s), %f, %p\n", font,
455 debugstr_w(font->lfw.lfFaceName), dpi, height);
457 if (!(font && height)) return InvalidParameter;
459 font_height = font->line_spacing * (font->emSize / font->height);
461 switch (font->unit)
463 case UnitPixel:
464 *height = font_height;
465 break;
466 case UnitPoint:
467 *height = font_height * dpi * inch_per_point;
468 break;
469 case UnitInch:
470 *height = font_height * dpi;
471 break;
472 case UnitDocument:
473 *height = font_height * (dpi / 300.0);
474 break;
475 case UnitMillimeter:
476 *height = font_height * (dpi / mm_per_inch);
477 break;
478 default:
479 FIXME("Unhandled unit type: %d\n", font->unit);
480 return NotImplemented;
483 return Ok;
486 /***********************************************************************
487 * Borrowed from GDI32:
489 * Elf is really an ENUMLOGFONTEXW, and ntm is a NEWTEXTMETRICEXW.
490 * We have to use other types because of the FONTENUMPROCW definition.
492 static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf,
493 const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
495 if (!ntm)
497 return 1;
500 *(NEWTEXTMETRICW*)lParam = *(const NEWTEXTMETRICW*)ntm;
502 return 0;
505 static BOOL find_installed_font(const WCHAR *name, NEWTEXTMETRICW *ntm)
507 HDC hdc = GetDC(0);
508 BOOL ret = FALSE;
510 if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, (LPARAM)ntm))
511 ret = TRUE;
513 ReleaseDC(0, hdc);
514 return ret;
517 /*******************************************************************************
518 * GdipCreateFontFamilyFromName [GDIPLUS.@]
520 * Creates a font family object based on a supplied name
522 * PARAMS
523 * name [I] Name of the font
524 * fontCollection [I] What font collection (if any) the font belongs to (may be NULL)
525 * FontFamily [O] Pointer to the resulting FontFamily object
527 * RETURNS
528 * SUCCESS: Ok
529 * FAILURE: FamilyNotFound if the requested FontFamily does not exist on the system
530 * FAILURE: Invalid parameter if FontFamily or name is NULL
532 * NOTES
533 * If fontCollection is NULL then the object is not part of any collection
537 GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
538 GpFontCollection *fontCollection,
539 GpFontFamily **FontFamily)
541 GpFontFamily* ffamily;
542 NEWTEXTMETRICW ntm;
544 TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
546 if (!(name && FontFamily))
547 return InvalidParameter;
548 if (fontCollection)
549 FIXME("No support for FontCollections yet!\n");
551 if (!find_installed_font(name, &ntm))
552 return FontFamilyNotFound;
554 ffamily = GdipAlloc(sizeof (GpFontFamily));
555 if (!ffamily) return OutOfMemory;
557 ffamily->tmw = ntm;
558 lstrcpynW(ffamily->FamilyName, name, LF_FACESIZE);
560 *FontFamily = ffamily;
562 return Ok;
565 /*******************************************************************************
566 * GdipCloneFontFamily [GDIPLUS.@]
568 * Creates a deep copy of a Font Family object
570 * PARAMS
571 * FontFamily [I] Font to clone
572 * clonedFontFamily [O] The resulting cloned font
574 * RETURNS
575 * SUCCESS: Ok
577 GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily* FontFamily, GpFontFamily** clonedFontFamily)
579 if (!(FontFamily && clonedFontFamily)) return InvalidParameter;
581 TRACE("stub: %p (%s), %p\n", FontFamily,
582 debugstr_w(FontFamily->FamilyName), clonedFontFamily);
584 *clonedFontFamily = GdipAlloc(sizeof(GpFontFamily));
585 if (!*clonedFontFamily) return OutOfMemory;
587 (*clonedFontFamily)->tmw = FontFamily->tmw;
588 lstrcpyW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName);
590 return Ok;
593 /*******************************************************************************
594 * GdipGetFamilyName [GDIPLUS.@]
596 * Returns the family name into name
598 * PARAMS
599 * *family [I] Family to retrieve from
600 * *name [O] WCHARS of the family name
601 * LANGID [I] charset
603 * RETURNS
604 * SUCCESS: Ok
605 * FAILURE: InvalidParameter if family is NULL
607 * NOTES
608 * If name is a NULL ptr, then both XP and Vista will crash (so we do as well)
610 GpStatus WINGDIPAPI GdipGetFamilyName (GDIPCONST GpFontFamily *family,
611 WCHAR *name, LANGID language)
613 if (family == NULL)
614 return InvalidParameter;
616 TRACE("%p, %p, %d\n", family, name, language);
618 if (language != LANG_NEUTRAL)
619 FIXME("No support for handling of multiple languages!\n");
621 lstrcpynW (name, family->FamilyName, LF_FACESIZE);
623 return Ok;
627 /*****************************************************************************
628 * GdipDeleteFontFamily [GDIPLUS.@]
630 * Removes the specified FontFamily
632 * PARAMS
633 * *FontFamily [I] The family to delete
635 * RETURNS
636 * SUCCESS: Ok
637 * FAILURE: InvalidParameter if FontFamily is NULL.
640 GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
642 if (!FontFamily)
643 return InvalidParameter;
644 TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName));
646 GdipFree (FontFamily);
648 return Ok;
651 GpStatus WINGDIPAPI GdipGetCellAscent(GDIPCONST GpFontFamily *family,
652 INT style, UINT16* CellAscent)
654 if (!(family && CellAscent)) return InvalidParameter;
656 *CellAscent = family->tmw.tmAscent;
658 return Ok;
661 GpStatus WINGDIPAPI GdipGetCellDescent(GDIPCONST GpFontFamily *family,
662 INT style, UINT16* CellDescent)
664 TRACE("(%p, %d, %p)\n", family, style, CellDescent);
666 if (!(family && CellDescent)) return InvalidParameter;
668 *CellDescent = family->tmw.tmDescent;
670 return Ok;
673 /*******************************************************************************
674 * GdipGetEmHeight [GDIPLUS.@]
676 * Gets the height of the specified family in EmHeights
678 * PARAMS
679 * family [I] Family to retrieve from
680 * style [I] (optional) style
681 * EmHeight [O] return value
683 * RETURNS
684 * SUCCESS: Ok
685 * FAILURE: InvalidParameter
687 GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, UINT16* EmHeight)
689 if (!(family && EmHeight)) return InvalidParameter;
691 TRACE("%p (%s), %d, %p\n", family, debugstr_w(family->FamilyName), style, EmHeight);
693 *EmHeight = family->tmw.ntmSizeEM;
695 return Ok;
699 /*******************************************************************************
700 * GdipGetLineSpacing [GDIPLUS.@]
702 * Returns the line spacing in design units
704 * PARAMS
705 * family [I] Family to retrieve from
706 * style [I] (Optional) font style
707 * LineSpacing [O] Return value
709 * RETURNS
710 * SUCCESS: Ok
711 * FAILURE: InvalidParameter (family or LineSpacing was NULL)
713 GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family,
714 INT style, UINT16* LineSpacing)
716 TRACE("%p, %d, %p\n", family, style, LineSpacing);
718 if (!(family && LineSpacing))
719 return InvalidParameter;
721 if (style) FIXME("ignoring style\n");
723 *LineSpacing = family->tmw.tmAscent + family->tmw.tmDescent + family->tmw.tmExternalLeading;
725 return Ok;
728 GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family,
729 INT style, BOOL* IsStyleAvailable)
731 FIXME("%p %d %p stub!\n", family, style, IsStyleAvailable);
733 if (!(family && IsStyleAvailable))
734 return InvalidParameter;
736 return NotImplemented;
739 /*****************************************************************************
740 * GdipGetGenericFontFamilyMonospace [GDIPLUS.@]
742 * Obtains a serif family (Courier New on Windows)
744 * PARAMS
745 * **nativeFamily [I] Where the font will be stored
747 * RETURNS
748 * InvalidParameter if nativeFamily is NULL.
749 * Ok otherwise.
751 GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily)
753 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
755 if (nativeFamily == NULL) return InvalidParameter;
757 return GdipCreateFontFamilyFromName(CourierNew, NULL, nativeFamily);
760 /*****************************************************************************
761 * GdipGetGenericFontFamilySerif [GDIPLUS.@]
763 * Obtains a serif family (Times New Roman on Windows)
765 * PARAMS
766 * **nativeFamily [I] Where the font will be stored
768 * RETURNS
769 * InvalidParameter if nativeFamily is NULL.
770 * Ok otherwise.
772 GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
774 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
776 TRACE("(%p)\n", nativeFamily);
778 if (nativeFamily == NULL) return InvalidParameter;
780 return GdipCreateFontFamilyFromName(TimesNewRoman, NULL, nativeFamily);
783 /*****************************************************************************
784 * GdipGetGenericFontFamilySansSerif [GDIPLUS.@]
786 * Obtains a serif family (Microsoft Sans Serif on Windows)
788 * PARAMS
789 * **nativeFamily [I] Where the font will be stored
791 * RETURNS
792 * InvalidParameter if nativeFamily is NULL.
793 * Ok otherwise.
795 GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily)
797 /* FIXME: On Windows this is called Microsoft Sans Serif, this shouldn't
798 * affect anything */
799 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
801 TRACE("(%p)\n", nativeFamily);
803 if (nativeFamily == NULL) return InvalidParameter;
805 return GdipCreateFontFamilyFromName(MSSansSerif, NULL, nativeFamily);
808 /*****************************************************************************
809 * GdipGetGenericFontFamilySansSerif [GDIPLUS.@]
811 GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollection)
813 TRACE("%p\n", fontCollection);
815 if (!fontCollection)
816 return InvalidParameter;
818 *fontCollection = GdipAlloc(sizeof(GpFontCollection));
819 if (!*fontCollection) return OutOfMemory;
821 (*fontCollection)->FontFamilies = NULL;
822 (*fontCollection)->count = 0;
823 return Ok;
826 /*****************************************************************************
827 * GdipDeletePrivateFontCollection [GDIPLUS.@]
829 GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection)
831 INT i;
833 TRACE("%p\n", fontCollection);
835 if (!fontCollection)
836 return InvalidParameter;
838 for (i = 0; i < (*fontCollection)->count; i++) GdipFree((*fontCollection)->FontFamilies[i]);
839 GdipFree(*fontCollection);
841 return Ok;
844 /*****************************************************************************
845 * GdipPrivateAddFontFile [GDIPLUS.@]
847 GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection* fontCollection,
848 GDIPCONST WCHAR* filename)
850 FIXME("stub: %p, %s\n", fontCollection, debugstr_w(filename));
852 if (!(fontCollection && filename))
853 return InvalidParameter;
855 return NotImplemented;
858 /*****************************************************************************
859 * GdipPrivateAddMemoryFont [GDIPLUS.@]
861 GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
862 GDIPCONST void* memory, INT length)
864 FIXME("%p, %p, %d\n", fontCollection, memory, length);
866 if (!(fontCollection && memory && length))
867 return InvalidParameter;
869 return Ok;
872 /*****************************************************************************
873 * GdipGetFontCollectionFamilyCount [GDIPLUS.@]
875 GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(
876 GpFontCollection* fontCollection, INT* numFound)
878 TRACE("%p, %p\n", fontCollection, numFound);
880 if (!(fontCollection && numFound))
881 return InvalidParameter;
883 *numFound = fontCollection->count;
884 return Ok;
887 /*****************************************************************************
888 * GdipGetFontCollectionFamilyList [GDIPLUS.@]
890 GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(
891 GpFontCollection* fontCollection, INT numSought,
892 GpFontFamily* gpfamilies[], INT* numFound)
894 INT i;
896 TRACE("%p, %d, %p, %p\n", fontCollection, numSought, gpfamilies, numFound);
898 if (!(fontCollection && gpfamilies && numFound))
899 return InvalidParameter;
901 for (i = 0; i < numSought && i < fontCollection->count; i++)
903 gpfamilies[i] = fontCollection->FontFamilies[i];
905 *numFound = i;
906 return Ok;
909 GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
910 GpFontCollection** fontCollection)
912 FIXME("stub: %p\n",fontCollection);
914 if (!fontCollection)
915 return InvalidParameter;
917 return NotImplemented;