user32: Fix a message test that would only pass on wine.
[wine.git] / dlls / gdiplus / font.c
blob7d2e14a89db2db4479e991aa58be88c9646b8c32
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"
26 #include "objbase.h"
28 #include "gdiplus.h"
29 #include "gdiplus_private.h"
31 GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
32 GDIPCONST LOGFONTW *logfont, GpFont **font)
34 HFONT hfont, oldfont;
35 TEXTMETRICW textmet;
37 if(!logfont || !font)
38 return InvalidParameter;
40 *font = GdipAlloc(sizeof(GpFont));
41 if(!*font) return OutOfMemory;
43 memcpy(&(*font)->lfw.lfFaceName, logfont->lfFaceName, LF_FACESIZE *
44 sizeof(WCHAR));
45 (*font)->lfw.lfHeight = logfont->lfHeight;
46 (*font)->lfw.lfItalic = logfont->lfItalic;
47 (*font)->lfw.lfUnderline = logfont->lfUnderline;
48 (*font)->lfw.lfStrikeOut = logfont->lfStrikeOut;
50 hfont = CreateFontIndirectW(&(*font)->lfw);
51 oldfont = SelectObject(hdc, hfont);
52 GetTextMetricsW(hdc, &textmet);
54 (*font)->lfw.lfHeight = -textmet.tmHeight;
55 (*font)->lfw.lfWeight = textmet.tmWeight;
57 SelectObject(hdc, oldfont);
58 DeleteObject(hfont);
60 return Ok;
63 GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc,
64 GDIPCONST LOGFONTA *lfa, GpFont **font)
66 LOGFONTW lfw;
68 if(!lfa || !font)
69 return InvalidParameter;
71 memcpy(&lfw, lfa, sizeof(LOGFONTA));
73 if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE))
74 return GenericError;
76 GdipCreateFontFromLogfontW(hdc, &lfw, font);
78 return Ok;
81 GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
83 if(!font)
84 return InvalidParameter;
86 GdipFree(font);
88 return Ok;
91 /* FIXME: use graphics */
92 GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics,
93 LOGFONTW *lfw)
95 if(!font || !graphics || !lfw)
96 return InvalidParameter;
98 memcpy(lfw, &font->lfw, sizeof(LOGFONTW));
100 return Ok;