- Sync gdiplus with wine head
[reactos.git] / reactos / dll / win32 / gdiplus / font.c
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include <stdarg.h>
20
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"
28
29 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus);
30
31 #include "objbase.h"
32
33 #include "gdiplus.h"
34 #include "gdiplus_private.h"
35
36 static const REAL mm_per_inch = 25.4;
37 static const REAL inch_per_point = 1.0/72.0;
38
39 static inline REAL get_dpi (void)
40 {
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);
48
49 return dpi;
50 }
51
52 static inline REAL point_to_pixel (REAL point)
53 {
54 return point * get_dpi() * inch_per_point;
55 }
56
57 static inline REAL inch_to_pixel (REAL inch)
58 {
59 return inch * get_dpi();
60 }
61
62 static inline REAL document_to_pixel (REAL doc)
63 {
64 return doc * (get_dpi() / 300.0); /* Per MSDN */
65 }
66
67 static inline REAL mm_to_pixel (REAL mm)
68 {
69 return mm * (get_dpi() / mm_per_inch);
70 }
71
72 /*******************************************************************************
73 * GdipCreateFont [GDIPLUS.@]
74 *
75 * Create a new font based off of a FontFamily
76 *
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
83 *
84 * RETURNS
85 * SUCCESS: Ok
86 * FAILURE: InvalidParameter if fontfamily or font is NULL.
87 * FAILURE: FontFamilyNotFound if an invalid FontFamily is given
88 *
89 * NOTES
90 * UnitDisplay is unsupported.
91 * emSize is stored separately from lfHeight, to hold the fraction.
92 */
93 GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
94 REAL emSize, INT style, Unit unit, GpFont **font)
95 {
96 WCHAR facename[LF_FACESIZE];
97 LOGFONTW* lfw;
98 const NEWTEXTMETRICW* tmw;
99 GpStatus stat;
100
101 if (!fontFamily || !font)
102 return InvalidParameter;
103
104 TRACE("%p (%s), %f, %d, %d, %p\n", fontFamily,
105 debugstr_w(fontFamily->FamilyName), emSize, style, unit, font);
106
107 stat = GdipGetFamilyName (fontFamily, facename, 0);
108 if (stat != Ok) return stat;
109 *font = GdipAlloc(sizeof(GpFont));
110
111 tmw = &fontFamily->tmw;
112 lfw = &((*font)->lfw);
113 ZeroMemory(&(*lfw), sizeof(*lfw));
114
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);
122
123 switch (unit)
124 {
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;
145 }
146
147 lfw->lfHeight *= -1;
148
149 lfw->lfWeight = style & FontStyleBold ? 700 : 400;
150 lfw->lfItalic = style & FontStyleItalic;
151 lfw->lfUnderline = style & FontStyleUnderline;
152 lfw->lfStrikeOut = style & FontStyleStrikeout;
153
154 (*font)->unit = unit;
155 (*font)->emSize = emSize;
156
157 return Ok;
158 }
159
160 /*******************************************************************************
161 * GdipCreateFontFromLogfontW [GDIPLUS.@]
162 */
163 GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
164 GDIPCONST LOGFONTW *logfont, GpFont **font)
165 {
166 HFONT hfont, oldfont;
167 TEXTMETRICW textmet;
168
169 TRACE("(%p, %p, %p)\n", hdc, logfont, font);
170
171 if(!logfont || !font)
172 return InvalidParameter;
173
174 if (logfont->lfFaceName[0] == 0)
175 return NotTrueTypeFont;
176
177 *font = GdipAlloc(sizeof(GpFont));
178 if(!*font) return OutOfMemory;
179
180 memcpy((*font)->lfw.lfFaceName, logfont->lfFaceName, LF_FACESIZE *
181 sizeof(WCHAR));
182 (*font)->lfw.lfHeight = logfont->lfHeight;
183 (*font)->lfw.lfItalic = logfont->lfItalic;
184 (*font)->lfw.lfUnderline = logfont->lfUnderline;
185 (*font)->lfw.lfStrikeOut = logfont->lfStrikeOut;
186
187 (*font)->emSize = logfont->lfHeight;
188 (*font)->unit = UnitPixel;
189
190 hfont = CreateFontIndirectW(&(*font)->lfw);
191 oldfont = SelectObject(hdc, hfont);
192 GetTextMetricsW(hdc, &textmet);
193
194 (*font)->lfw.lfHeight = -textmet.tmHeight;
195 (*font)->lfw.lfWeight = textmet.tmWeight;
196
197 SelectObject(hdc, oldfont);
198 DeleteObject(hfont);
199
200 return Ok;
201 }
202
203 /*******************************************************************************
204 * GdipCreateFontFromLogfontA [GDIPLUS.@]
205 */
206 GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc,
207 GDIPCONST LOGFONTA *lfa, GpFont **font)
208 {
209 LOGFONTW lfw;
210
211 TRACE("(%p, %p, %p)\n", hdc, lfa, font);
212
213 if(!lfa || !font)
214 return InvalidParameter;
215
216 memcpy(&lfw, lfa, FIELD_OFFSET(LOGFONTA,lfFaceName) );
217
218 if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE))
219 return GenericError;
220
221 GdipCreateFontFromLogfontW(hdc, &lfw, font);
222
223 return Ok;
224 }
225
226 /*******************************************************************************
227 * GdipDeleteFont [GDIPLUS.@]
228 */
229 GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
230 {
231 TRACE("(%p)\n", font);
232
233 if(!font)
234 return InvalidParameter;
235
236 GdipFree(font);
237
238 return Ok;
239 }
240
241 /*******************************************************************************
242 * GdipCreateFontFromDC [GDIPLUS.@]
243 */
244 GpStatus WINGDIPAPI GdipCreateFontFromDC(HDC hdc, GpFont **font)
245 {
246 HFONT hfont;
247 LOGFONTW lfw;
248
249 TRACE("(%p, %p)\n", hdc, font);
250
251 if(!font)
252 return InvalidParameter;
253
254 hfont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
255 if(!hfont)
256 return GenericError;
257
258 if(!GetObjectW(hfont, sizeof(LOGFONTW), &lfw))
259 return GenericError;
260
261 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
262 }
263
264 /*******************************************************************************
265 * GdipGetFamily [GDIPLUS.@]
266 *
267 * Returns the FontFamily for the specified Font
268 *
269 * PARAMS
270 * font [I] Font to request from
271 * family [O] Resulting FontFamily object
272 *
273 * RETURNS
274 * SUCCESS: Ok
275 * FAILURE: An element of GpStatus
276 */
277 GpStatus WINGDIPAPI GdipGetFamily(GpFont *font, GpFontFamily **family)
278 {
279 TRACE("%p %p\n", font, family);
280
281 if (!(font && family))
282 return InvalidParameter;
283
284 return GdipCreateFontFamilyFromName(font->lfw.lfFaceName, NULL, family);
285 }
286
287 /******************************************************************************
288 * GdipGetFontSize [GDIPLUS.@]
289 *
290 * Returns the size of the font in Units
291 *
292 * PARAMS
293 * *font [I] The font to retrieve size from
294 * *size [O] Pointer to hold retrieved value
295 *
296 * RETURNS
297 * SUCCESS: Ok
298 * FAILURE: InvalidParamter (font or size was NULL)
299 *
300 * NOTES
301 * Size returned is actually emSize -- not internal size used for drawing.
302 */
303 GpStatus WINGDIPAPI GdipGetFontSize(GpFont *font, REAL *size)
304 {
305 TRACE("(%p, %p)\n", font, size);
306
307 if (!(font && size)) return InvalidParameter;
308
309 *size = font->emSize;
310
311 return Ok;
312 }
313
314 /*******************************************************************************
315 * GdipGetFontStyle [GDIPLUS.@]
316 *
317 * Gets the font's style, returned in bitwise OR of FontStyle enumeration
318 *
319 * PARAMS
320 * font [I] font to request from
321 * style [O] resulting pointer to a FontStyle enumeration
322 *
323 * RETURNS
324 * SUCCESS: Ok
325 * FAILURE: InvalidParameter
326 */
327 GpStatus WINGDIPAPI GdipGetFontStyle(GpFont *font, INT *style)
328 {
329 TRACE("%p %p\n", font, style);
330
331 if (!(font && style))
332 return InvalidParameter;
333
334 if (font->lfw.lfWeight > 400)
335 *style = FontStyleBold;
336 else
337 *style = 0;
338 if (font->lfw.lfItalic)
339 *style |= FontStyleItalic;
340 if (font->lfw.lfUnderline)
341 *style |= FontStyleUnderline;
342 if (font->lfw.lfStrikeOut)
343 *style |= FontStyleStrikeout;
344
345 return Ok;
346 }
347
348 /*******************************************************************************
349 * GdipGetFontUnit [GDIPLUS.@]
350 *
351 * PARAMS
352 * font [I] Font to retrieve from
353 * unit [O] Return value
354 *
355 * RETURNS
356 * FAILURE: font or unit was NULL
357 * OK: otherwise
358 */
359 GpStatus WINGDIPAPI GdipGetFontUnit(GpFont *font, Unit *unit)
360 {
361 TRACE("(%p, %p)\n", font, unit);
362
363 if (!(font && unit)) return InvalidParameter;
364
365 *unit = font->unit;
366
367 return Ok;
368 }
369
370 /*******************************************************************************
371 * GdipGetLogFontW [GDIPLUS.@]
372 */
373 GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics,
374 LOGFONTW *lfw)
375 {
376 TRACE("(%p, %p, %p)\n", font, graphics, lfw);
377
378 /* FIXME: use graphics */
379 if(!font || !graphics || !lfw)
380 return InvalidParameter;
381
382 *lfw = font->lfw;
383
384 return Ok;
385 }
386
387 /*******************************************************************************
388 * GdipCloneFont [GDIPLUS.@]
389 */
390 GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
391 {
392 TRACE("(%p, %p)\n", font, cloneFont);
393
394 if(!font || !cloneFont)
395 return InvalidParameter;
396
397 *cloneFont = GdipAlloc(sizeof(GpFont));
398 if(!*cloneFont) return OutOfMemory;
399
400 **cloneFont = *font;
401
402 return Ok;
403 }
404
405 /*******************************************************************************
406 * GdipGetFontHeight [GDIPLUS.@]
407 * PARAMS
408 * font [I] Font to retrieve height from
409 * graphics [I] The current graphics context
410 * height [O] Resulting height
411 * RETURNS
412 * SUCCESS: Ok
413 * FAILURE: Another element of GpStatus
414 *
415 * NOTES
416 * Forwards to GdipGetFontHeightGivenDPI
417 */
418 GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font,
419 GDIPCONST GpGraphics *graphics, REAL *height)
420 {
421 REAL dpi;
422
423 TRACE("%p %p %p\n", font, graphics, height);
424
425 dpi = GetDeviceCaps(graphics->hdc, LOGPIXELSY);
426
427 return GdipGetFontHeightGivenDPI(font, dpi, height);
428 }
429
430 /*******************************************************************************
431 * GdipGetFontHeightGivenDPI [GDIPLUS.@]
432 * PARAMS
433 * font [I] Font to retrieve DPI from
434 * dpi [I] DPI to assume
435 * height [O] Return value
436 *
437 * RETURNS
438 * SUCCESS: Ok
439 * FAILURE: InvalidParameter if font or height is NULL
440 *
441 * NOTES
442 * According to MSDN, the result is (lineSpacing)*(fontSize / emHeight)*dpi
443 * (for anything other than unit Pixel)
444 */
445 GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
446 {
447 TRACE("%p (%s), %f, %p\n", font,
448 debugstr_w(font->lfw.lfFaceName), dpi, height);
449
450 if (!(font && height)) return InvalidParameter;
451
452 switch (font->unit)
453 {
454 case UnitPixel:
455 *height = font->emSize;
456 break;
457 default:
458 FIXME("Unhandled unit type: %d\n", font->unit);
459 return NotImplemented;
460 }
461
462 return Ok;
463 }
464
465 /***********************************************************************
466 * Borrowed from GDI32:
467 *
468 * Elf is really an ENUMLOGFONTEXW, and ntm is a NEWTEXTMETRICEXW.
469 * We have to use other types because of the FONTENUMPROCW definition.
470 */
471 static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf,
472 const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
473 {
474 if (!ntm)
475 {
476 return 1;
477 }
478
479 *(NEWTEXTMETRICW*)lParam = *(const NEWTEXTMETRICW*)ntm;
480
481 return 0;
482 }
483
484 static BOOL find_installed_font(const WCHAR *name, NEWTEXTMETRICW *ntm)
485 {
486 HDC hdc = GetDC(0);
487 BOOL ret = FALSE;
488
489 if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, (LPARAM)ntm))
490 ret = TRUE;
491
492 ReleaseDC(0, hdc);
493 return ret;
494 }
495
496 /*******************************************************************************
497 * GdipCreateFontFamilyFromName [GDIPLUS.@]
498 *
499 * Creates a font family object based on a supplied name
500 *
501 * PARAMS
502 * name [I] Name of the font
503 * fontCollection [I] What font collection (if any) the font belongs to (may be NULL)
504 * FontFamily [O] Pointer to the resulting FontFamily object
505 *
506 * RETURNS
507 * SUCCESS: Ok
508 * FAILURE: FamilyNotFound if the requested FontFamily does not exist on the system
509 * FAILURE: Invalid parameter if FontFamily or name is NULL
510 *
511 * NOTES
512 * If fontCollection is NULL then the object is not part of any collection
513 *
514 */
515
516 GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
517 GpFontCollection *fontCollection,
518 GpFontFamily **FontFamily)
519 {
520 GpFontFamily* ffamily;
521 NEWTEXTMETRICW ntm;
522
523 TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
524
525 if (!(name && FontFamily))
526 return InvalidParameter;
527 if (fontCollection)
528 FIXME("No support for FontCollections yet!\n");
529
530 if (!find_installed_font(name, &ntm))
531 return FontFamilyNotFound;
532
533 ffamily = GdipAlloc(sizeof (GpFontFamily));
534 if (!ffamily) return OutOfMemory;
535
536 ffamily->tmw = ntm;
537 lstrcpynW(ffamily->FamilyName, name, LF_FACESIZE);
538
539 *FontFamily = ffamily;
540
541 return Ok;
542 }
543
544 /*******************************************************************************
545 * GdipCloneFontFamily [GDIPLUS.@]
546 *
547 * Creates a deep copy of a Font Family object
548 *
549 * PARAMS
550 * FontFamily [I] Font to clone
551 * clonedFontFamily [O] The resulting cloned font
552 *
553 * RETURNS
554 * SUCCESS: Ok
555 */
556 GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily* FontFamily, GpFontFamily** clonedFontFamily)
557 {
558 if (!(FontFamily && clonedFontFamily)) return InvalidParameter;
559
560 TRACE("stub: %p (%s), %p\n", FontFamily,
561 debugstr_w(FontFamily->FamilyName), clonedFontFamily);
562
563 *clonedFontFamily = GdipAlloc(sizeof(GpFontFamily));
564 if (!*clonedFontFamily) return OutOfMemory;
565
566 (*clonedFontFamily)->tmw = FontFamily->tmw;
567 lstrcpyW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName);
568
569 return Ok;
570 }
571
572 /*******************************************************************************
573 * GdipGetFamilyName [GDIPLUS.@]
574 *
575 * Returns the family name into name
576 *
577 * PARAMS
578 * *family [I] Family to retrieve from
579 * *name [O] WCHARS of the family name
580 * LANGID [I] charset
581 *
582 * RETURNS
583 * SUCCESS: Ok
584 * FAILURE: InvalidParameter if family is NULL
585 *
586 * NOTES
587 * If name is a NULL ptr, then both XP and Vista will crash (so we do as well)
588 */
589 GpStatus WINGDIPAPI GdipGetFamilyName (GDIPCONST GpFontFamily *family,
590 WCHAR *name, LANGID language)
591 {
592 if (family == NULL)
593 return InvalidParameter;
594
595 TRACE("%p, %p, %d\n", family, name, language);
596
597 if (language != LANG_NEUTRAL)
598 FIXME("No support for handling of multiple languages!\n");
599
600 lstrcpynW (name, family->FamilyName, LF_FACESIZE);
601
602 return Ok;
603 }
604
605
606 /*****************************************************************************
607 * GdipDeleteFontFamily [GDIPLUS.@]
608 *
609 * Removes the specified FontFamily
610 *
611 * PARAMS
612 * *FontFamily [I] The family to delete
613 *
614 * RETURNS
615 * SUCCESS: Ok
616 * FAILURE: InvalidParameter if FontFamily is NULL.
617 *
618 */
619 GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
620 {
621 if (!FontFamily)
622 return InvalidParameter;
623 TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName));
624
625 GdipFree (FontFamily);
626
627 return Ok;
628 }
629
630 GpStatus WINGDIPAPI GdipGetCellAscent(GDIPCONST GpFontFamily *family,
631 INT style, UINT16* CellAscent)
632 {
633 if (!(family && CellAscent)) return InvalidParameter;
634
635 *CellAscent = family->tmw.tmAscent;
636
637 return Ok;
638 }
639
640 GpStatus WINGDIPAPI GdipGetCellDescent(GDIPCONST GpFontFamily *family,
641 INT style, UINT16* CellDescent)
642 {
643 TRACE("(%p, %d, %p)\n", family, style, CellDescent);
644
645 if (!(family && CellDescent)) return InvalidParameter;
646
647 *CellDescent = family->tmw.tmDescent;
648
649 return Ok;
650 }
651
652 /*******************************************************************************
653 * GdipGetEmHeight [GDIPLUS.@]
654 *
655 * Gets the height of the specified family in EmHeights
656 *
657 * PARAMS
658 * family [I] Family to retrieve from
659 * style [I] (optional) style
660 * EmHeight [O] return value
661 *
662 * RETURNS
663 * SUCCESS: Ok
664 * FAILURE: InvalidParameter
665 */
666 GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, UINT16* EmHeight)
667 {
668 if (!(family && EmHeight)) return InvalidParameter;
669
670 TRACE("%p (%s), %d, %p, stub!\n", family,
671 debugstr_w(family->FamilyName), style, EmHeight);
672
673 *EmHeight = family->tmw.ntmSizeEM;
674
675 return Ok;
676 }
677
678
679 /*******************************************************************************
680 * GdipGetLineSpacing [GDIPLUS.@]
681 *
682 * Returns the line spacing in design units
683 *
684 * PARAMS
685 * family [I] Family to retrieve from
686 * style [I] (Optional) font style
687 * LineSpacing [O] Return value
688 *
689 * RETURNS
690 * SUCCESS: Ok
691 * FAILURE: InvalidParameter (family or LineSpacing was NULL)
692 */
693 GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family,
694 INT style, UINT16* LineSpacing)
695 {
696 if (!(family && LineSpacing)) return InvalidParameter;
697
698 FIXME("stub!\n");
699
700 return NotImplemented;
701 }
702
703 GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family,
704 INT style, BOOL* IsStyleAvailable)
705 {
706 FIXME("%p %d %p stub!\n", family, style, IsStyleAvailable);
707
708 if (!(family && IsStyleAvailable))
709 return InvalidParameter;
710
711 return NotImplemented;
712 }
713
714 /*****************************************************************************
715 * GdipGetGenericFontFamilyMonospace [GDIPLUS.@]
716 *
717 * Obtains a serif family (Courier New on Windows)
718 *
719 * PARAMS
720 * **nativeFamily [I] Where the font will be stored
721 *
722 * RETURNS
723 * InvalidParameter if nativeFamily is NULL.
724 * Ok otherwise.
725 */
726 GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily)
727 {
728 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
729
730 if (nativeFamily == NULL) return InvalidParameter;
731
732 return GdipCreateFontFamilyFromName(CourierNew, NULL, nativeFamily);
733 }
734
735 /*****************************************************************************
736 * GdipGetGenericFontFamilySerif [GDIPLUS.@]
737 *
738 * Obtains a serif family (Times New Roman on Windows)
739 *
740 * PARAMS
741 * **nativeFamily [I] Where the font will be stored
742 *
743 * RETURNS
744 * InvalidParameter if nativeFamily is NULL.
745 * Ok otherwise.
746 */
747 GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
748 {
749 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
750
751 TRACE("(%p)\n", nativeFamily);
752
753 if (nativeFamily == NULL) return InvalidParameter;
754
755 return GdipCreateFontFamilyFromName(TimesNewRoman, NULL, nativeFamily);
756 }
757
758 /*****************************************************************************
759 * GdipGetGenericFontFamilySansSerif [GDIPLUS.@]
760 *
761 * Obtains a serif family (Microsoft Sans Serif on Windows)
762 *
763 * PARAMS
764 * **nativeFamily [I] Where the font will be stored
765 *
766 * RETURNS
767 * InvalidParameter if nativeFamily is NULL.
768 * Ok otherwise.
769 */
770 GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily)
771 {
772 /* FIXME: On Windows this is called Microsoft Sans Serif, this shouldn't
773 * affect anything */
774 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
775
776 TRACE("(%p)\n", nativeFamily);
777
778 if (nativeFamily == NULL) return InvalidParameter;
779
780 return GdipCreateFontFamilyFromName(MSSansSerif, NULL, nativeFamily);
781 }
782
783 /*****************************************************************************
784 * GdipGetGenericFontFamilySansSerif [GDIPLUS.@]
785 */
786 GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollection)
787 {
788 FIXME("stub %p\n", fontCollection);
789
790 if (!fontCollection)
791 return InvalidParameter;
792
793 return NotImplemented;
794 }
795
796 /*****************************************************************************
797 * GdipDeletePrivateFontCollection [GDIPLUS.@]
798 */
799 GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection)
800 {
801 FIXME("stub %p\n", fontCollection);
802
803 if (!fontCollection)
804 return InvalidParameter;
805
806 return NotImplemented;
807 }
808
809 /*****************************************************************************
810 * GdipPrivateAddFontFile [GDIPLUS.@]
811 */
812 GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection* fontCollection,
813 GDIPCONST WCHAR* filename)
814 {
815 FIXME("stub: %p, %s\n", fontCollection, debugstr_w(filename));
816
817 if (!(fontCollection && filename))
818 return InvalidParameter;
819
820 return NotImplemented;
821 }
822
823 /*****************************************************************************
824 * GdipGetFontCollectionFamilyCount [GDIPLUS.@]
825 */
826 GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(
827 GpFontCollection* fontCollection, INT* numFound)
828 {
829 FIXME("stub: %p, %p\n", fontCollection, numFound);
830
831 if (!(fontCollection && numFound))
832 return InvalidParameter;
833
834 return NotImplemented;
835 }
836
837 /*****************************************************************************
838 * GdipGetFontCollectionFamilyList [GDIPLUS.@]
839 */
840 GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(
841 GpFontCollection* fontCollection, INT numSought,
842 GpFontFamily* gpfamilies[], INT* numFound)
843 {
844 FIXME("stub: %p, %d, %p, %p\n", fontCollection, numSought, gpfamilies,
845 numFound);
846
847 if (!(fontCollection && gpfamilies && numFound))
848 return InvalidParameter;
849
850 return NotImplemented;
851 }