push c6bab2db4fc296bd36abf8f7d9cf443d4a73048e
[wine/hacks.git] / dlls / gdiplus / font.c
blob6454765d85c0732c433d80ce1275f284acfc8de0
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;
198 (*font)->lfw.lfCharSet = textmet.tmCharSet;
200 (*font)->height = 1; /* FIXME: need NEWTEXTMETRIC.ntmSizeEM here */
201 (*font)->line_spacing = textmet.tmAscent + textmet.tmDescent + textmet.tmExternalLeading;
203 SelectObject(hdc, oldfont);
204 DeleteObject(hfont);
206 return Ok;
209 /*******************************************************************************
210 * GdipCreateFontFromLogfontA [GDIPLUS.@]
212 GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc,
213 GDIPCONST LOGFONTA *lfa, GpFont **font)
215 LOGFONTW lfw;
217 TRACE("(%p, %p, %p)\n", hdc, lfa, font);
219 if(!lfa || !font)
220 return InvalidParameter;
222 memcpy(&lfw, lfa, FIELD_OFFSET(LOGFONTA,lfFaceName) );
224 if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE))
225 return GenericError;
227 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
230 /*******************************************************************************
231 * GdipDeleteFont [GDIPLUS.@]
233 GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
235 TRACE("(%p)\n", font);
237 if(!font)
238 return InvalidParameter;
240 GdipFree(font);
242 return Ok;
245 /*******************************************************************************
246 * GdipCreateFontFromDC [GDIPLUS.@]
248 GpStatus WINGDIPAPI GdipCreateFontFromDC(HDC hdc, GpFont **font)
250 HFONT hfont;
251 LOGFONTW lfw;
253 TRACE("(%p, %p)\n", hdc, font);
255 if(!font)
256 return InvalidParameter;
258 hfont = GetCurrentObject(hdc, OBJ_FONT);
259 if(!hfont)
260 return GenericError;
262 if(!GetObjectW(hfont, sizeof(LOGFONTW), &lfw))
263 return GenericError;
265 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
268 /*******************************************************************************
269 * GdipGetFamily [GDIPLUS.@]
271 * Returns the FontFamily for the specified Font
273 * PARAMS
274 * font [I] Font to request from
275 * family [O] Resulting FontFamily object
277 * RETURNS
278 * SUCCESS: Ok
279 * FAILURE: An element of GpStatus
281 GpStatus WINGDIPAPI GdipGetFamily(GpFont *font, GpFontFamily **family)
283 TRACE("%p %p\n", font, family);
285 if (!(font && family))
286 return InvalidParameter;
288 return GdipCreateFontFamilyFromName(font->lfw.lfFaceName, NULL, family);
291 /******************************************************************************
292 * GdipGetFontSize [GDIPLUS.@]
294 * Returns the size of the font in Units
296 * PARAMS
297 * *font [I] The font to retrieve size from
298 * *size [O] Pointer to hold retrieved value
300 * RETURNS
301 * SUCCESS: Ok
302 * FAILURE: InvalidParameter (font or size was NULL)
304 * NOTES
305 * Size returned is actually emSize -- not internal size used for drawing.
307 GpStatus WINGDIPAPI GdipGetFontSize(GpFont *font, REAL *size)
309 TRACE("(%p, %p)\n", font, size);
311 if (!(font && size)) return InvalidParameter;
313 *size = font->emSize;
315 return Ok;
318 /*******************************************************************************
319 * GdipGetFontStyle [GDIPLUS.@]
321 * Gets the font's style, returned in bitwise OR of FontStyle enumeration
323 * PARAMS
324 * font [I] font to request from
325 * style [O] resulting pointer to a FontStyle enumeration
327 * RETURNS
328 * SUCCESS: Ok
329 * FAILURE: InvalidParameter
331 GpStatus WINGDIPAPI GdipGetFontStyle(GpFont *font, INT *style)
333 TRACE("%p %p\n", font, style);
335 if (!(font && style))
336 return InvalidParameter;
338 if (font->lfw.lfWeight > 400)
339 *style = FontStyleBold;
340 else
341 *style = 0;
342 if (font->lfw.lfItalic)
343 *style |= FontStyleItalic;
344 if (font->lfw.lfUnderline)
345 *style |= FontStyleUnderline;
346 if (font->lfw.lfStrikeOut)
347 *style |= FontStyleStrikeout;
349 return Ok;
352 /*******************************************************************************
353 * GdipGetFontUnit [GDIPLUS.@]
355 * PARAMS
356 * font [I] Font to retrieve from
357 * unit [O] Return value
359 * RETURNS
360 * FAILURE: font or unit was NULL
361 * OK: otherwise
363 GpStatus WINGDIPAPI GdipGetFontUnit(GpFont *font, Unit *unit)
365 TRACE("(%p, %p)\n", font, unit);
367 if (!(font && unit)) return InvalidParameter;
369 *unit = font->unit;
371 return Ok;
374 /*******************************************************************************
375 * GdipGetLogFontA [GDIPLUS.@]
377 GpStatus WINGDIPAPI GdipGetLogFontA(GpFont *font, GpGraphics *graphics,
378 LOGFONTA *lfa)
380 GpStatus status;
381 LOGFONTW lfw;
383 TRACE("(%p, %p, %p)\n", font, graphics, lfa);
385 status = GdipGetLogFontW(font, graphics, &lfw);
386 if(status != Ok)
387 return status;
389 memcpy(lfa, &lfw, FIELD_OFFSET(LOGFONTA,lfFaceName) );
391 if(!WideCharToMultiByte(CP_ACP, 0, lfw.lfFaceName, -1, lfa->lfFaceName, LF_FACESIZE, NULL, NULL))
392 return GenericError;
394 return Ok;
397 /*******************************************************************************
398 * GdipGetLogFontW [GDIPLUS.@]
400 GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics,
401 LOGFONTW *lfw)
403 TRACE("(%p, %p, %p)\n", font, graphics, lfw);
405 /* FIXME: use graphics */
406 if(!font || !graphics || !lfw)
407 return InvalidParameter;
409 *lfw = font->lfw;
411 return Ok;
414 /*******************************************************************************
415 * GdipCloneFont [GDIPLUS.@]
417 GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
419 TRACE("(%p, %p)\n", font, cloneFont);
421 if(!font || !cloneFont)
422 return InvalidParameter;
424 *cloneFont = GdipAlloc(sizeof(GpFont));
425 if(!*cloneFont) return OutOfMemory;
427 **cloneFont = *font;
429 return Ok;
432 /*******************************************************************************
433 * GdipGetFontHeight [GDIPLUS.@]
434 * PARAMS
435 * font [I] Font to retrieve height from
436 * graphics [I] The current graphics context
437 * height [O] Resulting height
438 * RETURNS
439 * SUCCESS: Ok
440 * FAILURE: Another element of GpStatus
442 * NOTES
443 * Forwards to GdipGetFontHeightGivenDPI
445 GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font,
446 GDIPCONST GpGraphics *graphics, REAL *height)
448 REAL dpi;
450 TRACE("%p %p %p\n", font, graphics, height);
452 dpi = GetDeviceCaps(graphics->hdc, LOGPIXELSY);
454 return GdipGetFontHeightGivenDPI(font, dpi, height);
457 /*******************************************************************************
458 * GdipGetFontHeightGivenDPI [GDIPLUS.@]
459 * PARAMS
460 * font [I] Font to retrieve DPI from
461 * dpi [I] DPI to assume
462 * height [O] Return value
464 * RETURNS
465 * SUCCESS: Ok
466 * FAILURE: InvalidParameter if font or height is NULL
468 * NOTES
469 * According to MSDN, the result is (lineSpacing)*(fontSize / emHeight)*dpi
470 * (for anything other than unit Pixel)
472 GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
474 REAL font_height;
476 TRACE("%p (%s), %f, %p\n", font,
477 debugstr_w(font->lfw.lfFaceName), dpi, height);
479 if (!(font && height)) return InvalidParameter;
481 font_height = font->line_spacing * (font->emSize / font->height);
483 switch (font->unit)
485 case UnitPixel:
486 *height = font_height;
487 break;
488 case UnitPoint:
489 *height = font_height * dpi * inch_per_point;
490 break;
491 case UnitInch:
492 *height = font_height * dpi;
493 break;
494 case UnitDocument:
495 *height = font_height * (dpi / 300.0);
496 break;
497 case UnitMillimeter:
498 *height = font_height * (dpi / mm_per_inch);
499 break;
500 default:
501 FIXME("Unhandled unit type: %d\n", font->unit);
502 return NotImplemented;
505 return Ok;
508 /***********************************************************************
509 * Borrowed from GDI32:
511 * Elf is really an ENUMLOGFONTEXW, and ntm is a NEWTEXTMETRICEXW.
512 * We have to use other types because of the FONTENUMPROCW definition.
514 static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf,
515 const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
517 if (!ntm)
519 return 1;
522 *(NEWTEXTMETRICW*)lParam = *(const NEWTEXTMETRICW*)ntm;
524 return 0;
527 static BOOL find_installed_font(const WCHAR *name, NEWTEXTMETRICW *ntm)
529 HDC hdc = GetDC(0);
530 BOOL ret = FALSE;
532 if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, (LPARAM)ntm))
533 ret = TRUE;
535 ReleaseDC(0, hdc);
536 return ret;
539 /*******************************************************************************
540 * GdipCreateFontFamilyFromName [GDIPLUS.@]
542 * Creates a font family object based on a supplied name
544 * PARAMS
545 * name [I] Name of the font
546 * fontCollection [I] What font collection (if any) the font belongs to (may be NULL)
547 * FontFamily [O] Pointer to the resulting FontFamily object
549 * RETURNS
550 * SUCCESS: Ok
551 * FAILURE: FamilyNotFound if the requested FontFamily does not exist on the system
552 * FAILURE: Invalid parameter if FontFamily or name is NULL
554 * NOTES
555 * If fontCollection is NULL then the object is not part of any collection
559 GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
560 GpFontCollection *fontCollection,
561 GpFontFamily **FontFamily)
563 GpFontFamily* ffamily;
564 NEWTEXTMETRICW ntm;
566 TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
568 if (!(name && FontFamily))
569 return InvalidParameter;
570 if (fontCollection)
571 FIXME("No support for FontCollections yet!\n");
573 if (!find_installed_font(name, &ntm))
574 return FontFamilyNotFound;
576 ffamily = GdipAlloc(sizeof (GpFontFamily));
577 if (!ffamily) return OutOfMemory;
579 ffamily->tmw = ntm;
580 lstrcpynW(ffamily->FamilyName, name, LF_FACESIZE);
582 *FontFamily = ffamily;
584 return Ok;
587 /*******************************************************************************
588 * GdipCloneFontFamily [GDIPLUS.@]
590 * Creates a deep copy of a Font Family object
592 * PARAMS
593 * FontFamily [I] Font to clone
594 * clonedFontFamily [O] The resulting cloned font
596 * RETURNS
597 * SUCCESS: Ok
599 GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily* FontFamily, GpFontFamily** clonedFontFamily)
601 if (!(FontFamily && clonedFontFamily)) return InvalidParameter;
603 TRACE("stub: %p (%s), %p\n", FontFamily,
604 debugstr_w(FontFamily->FamilyName), clonedFontFamily);
606 *clonedFontFamily = GdipAlloc(sizeof(GpFontFamily));
607 if (!*clonedFontFamily) return OutOfMemory;
609 (*clonedFontFamily)->tmw = FontFamily->tmw;
610 lstrcpyW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName);
612 return Ok;
615 /*******************************************************************************
616 * GdipGetFamilyName [GDIPLUS.@]
618 * Returns the family name into name
620 * PARAMS
621 * *family [I] Family to retrieve from
622 * *name [O] WCHARS of the family name
623 * LANGID [I] charset
625 * RETURNS
626 * SUCCESS: Ok
627 * FAILURE: InvalidParameter if family is NULL
629 * NOTES
630 * If name is a NULL ptr, then both XP and Vista will crash (so we do as well)
632 GpStatus WINGDIPAPI GdipGetFamilyName (GDIPCONST GpFontFamily *family,
633 WCHAR *name, LANGID language)
635 if (family == NULL)
636 return InvalidParameter;
638 TRACE("%p, %p, %d\n", family, name, language);
640 if (language != LANG_NEUTRAL)
641 FIXME("No support for handling of multiple languages!\n");
643 lstrcpynW (name, family->FamilyName, LF_FACESIZE);
645 return Ok;
649 /*****************************************************************************
650 * GdipDeleteFontFamily [GDIPLUS.@]
652 * Removes the specified FontFamily
654 * PARAMS
655 * *FontFamily [I] The family to delete
657 * RETURNS
658 * SUCCESS: Ok
659 * FAILURE: InvalidParameter if FontFamily is NULL.
662 GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
664 if (!FontFamily)
665 return InvalidParameter;
666 TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName));
668 GdipFree (FontFamily);
670 return Ok;
673 GpStatus WINGDIPAPI GdipGetCellAscent(GDIPCONST GpFontFamily *family,
674 INT style, UINT16* CellAscent)
676 if (!(family && CellAscent)) return InvalidParameter;
678 *CellAscent = family->tmw.tmAscent;
680 return Ok;
683 GpStatus WINGDIPAPI GdipGetCellDescent(GDIPCONST GpFontFamily *family,
684 INT style, UINT16* CellDescent)
686 TRACE("(%p, %d, %p)\n", family, style, CellDescent);
688 if (!(family && CellDescent)) return InvalidParameter;
690 *CellDescent = family->tmw.tmDescent;
692 return Ok;
695 /*******************************************************************************
696 * GdipGetEmHeight [GDIPLUS.@]
698 * Gets the height of the specified family in EmHeights
700 * PARAMS
701 * family [I] Family to retrieve from
702 * style [I] (optional) style
703 * EmHeight [O] return value
705 * RETURNS
706 * SUCCESS: Ok
707 * FAILURE: InvalidParameter
709 GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, UINT16* EmHeight)
711 if (!(family && EmHeight)) return InvalidParameter;
713 TRACE("%p (%s), %d, %p\n", family, debugstr_w(family->FamilyName), style, EmHeight);
715 *EmHeight = family->tmw.ntmSizeEM;
717 return Ok;
721 /*******************************************************************************
722 * GdipGetLineSpacing [GDIPLUS.@]
724 * Returns the line spacing in design units
726 * PARAMS
727 * family [I] Family to retrieve from
728 * style [I] (Optional) font style
729 * LineSpacing [O] Return value
731 * RETURNS
732 * SUCCESS: Ok
733 * FAILURE: InvalidParameter (family or LineSpacing was NULL)
735 GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family,
736 INT style, UINT16* LineSpacing)
738 TRACE("%p, %d, %p\n", family, style, LineSpacing);
740 if (!(family && LineSpacing))
741 return InvalidParameter;
743 if (style) FIXME("ignoring style\n");
745 *LineSpacing = family->tmw.tmAscent + family->tmw.tmDescent + family->tmw.tmExternalLeading;
747 return Ok;
750 GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family,
751 INT style, BOOL* IsStyleAvailable)
753 FIXME("%p %d %p stub!\n", family, style, IsStyleAvailable);
755 if (!(family && IsStyleAvailable))
756 return InvalidParameter;
758 return NotImplemented;
761 /*****************************************************************************
762 * GdipGetGenericFontFamilyMonospace [GDIPLUS.@]
764 * Obtains a serif family (Courier New on Windows)
766 * PARAMS
767 * **nativeFamily [I] Where the font will be stored
769 * RETURNS
770 * InvalidParameter if nativeFamily is NULL.
771 * Ok otherwise.
773 GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily)
775 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
777 if (nativeFamily == NULL) return InvalidParameter;
779 return GdipCreateFontFamilyFromName(CourierNew, NULL, nativeFamily);
782 /*****************************************************************************
783 * GdipGetGenericFontFamilySerif [GDIPLUS.@]
785 * Obtains a serif family (Times New Roman on Windows)
787 * PARAMS
788 * **nativeFamily [I] Where the font will be stored
790 * RETURNS
791 * InvalidParameter if nativeFamily is NULL.
792 * Ok otherwise.
794 GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
796 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
798 TRACE("(%p)\n", nativeFamily);
800 if (nativeFamily == NULL) return InvalidParameter;
802 return GdipCreateFontFamilyFromName(TimesNewRoman, NULL, nativeFamily);
805 /*****************************************************************************
806 * GdipGetGenericFontFamilySansSerif [GDIPLUS.@]
808 * Obtains a serif family (Microsoft Sans Serif on Windows)
810 * PARAMS
811 * **nativeFamily [I] Where the font will be stored
813 * RETURNS
814 * InvalidParameter if nativeFamily is NULL.
815 * Ok otherwise.
817 GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily)
819 /* FIXME: On Windows this is called Microsoft Sans Serif, this shouldn't
820 * affect anything */
821 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
823 TRACE("(%p)\n", nativeFamily);
825 if (nativeFamily == NULL) return InvalidParameter;
827 return GdipCreateFontFamilyFromName(MSSansSerif, NULL, nativeFamily);
830 /*****************************************************************************
831 * GdipGetGenericFontFamilySansSerif [GDIPLUS.@]
833 GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollection)
835 TRACE("%p\n", fontCollection);
837 if (!fontCollection)
838 return InvalidParameter;
840 *fontCollection = GdipAlloc(sizeof(GpFontCollection));
841 if (!*fontCollection) return OutOfMemory;
843 (*fontCollection)->FontFamilies = NULL;
844 (*fontCollection)->count = 0;
845 return Ok;
848 /*****************************************************************************
849 * GdipDeletePrivateFontCollection [GDIPLUS.@]
851 GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection)
853 INT i;
855 TRACE("%p\n", fontCollection);
857 if (!fontCollection)
858 return InvalidParameter;
860 for (i = 0; i < (*fontCollection)->count; i++) GdipFree((*fontCollection)->FontFamilies[i]);
861 GdipFree(*fontCollection);
863 return Ok;
866 /*****************************************************************************
867 * GdipPrivateAddFontFile [GDIPLUS.@]
869 GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection* fontCollection,
870 GDIPCONST WCHAR* filename)
872 FIXME("stub: %p, %s\n", fontCollection, debugstr_w(filename));
874 if (!(fontCollection && filename))
875 return InvalidParameter;
877 return NotImplemented;
880 /*****************************************************************************
881 * GdipPrivateAddMemoryFont [GDIPLUS.@]
883 GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
884 GDIPCONST void* memory, INT length)
886 FIXME("%p, %p, %d\n", fontCollection, memory, length);
888 if (!(fontCollection && memory && length))
889 return InvalidParameter;
891 return Ok;
894 /*****************************************************************************
895 * GdipGetFontCollectionFamilyCount [GDIPLUS.@]
897 GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(
898 GpFontCollection* fontCollection, INT* numFound)
900 TRACE("%p, %p\n", fontCollection, numFound);
902 if (!(fontCollection && numFound))
903 return InvalidParameter;
905 *numFound = fontCollection->count;
906 return Ok;
909 /*****************************************************************************
910 * GdipGetFontCollectionFamilyList [GDIPLUS.@]
912 GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(
913 GpFontCollection* fontCollection, INT numSought,
914 GpFontFamily* gpfamilies[], INT* numFound)
916 INT i;
918 TRACE("%p, %d, %p, %p\n", fontCollection, numSought, gpfamilies, numFound);
920 if (!(fontCollection && gpfamilies && numFound))
921 return InvalidParameter;
923 for (i = 0; i < numSought && i < fontCollection->count; i++)
925 gpfamilies[i] = fontCollection->FontFamilies[i];
927 *numFound = i;
928 return Ok;
931 GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
932 GpFontCollection** fontCollection)
934 FIXME("stub: %p\n",fontCollection);
936 if (!fontCollection)
937 return InvalidParameter;
939 return NotImplemented;