quartz: Remove dead code from DSoundRender.
[wine/wine64.git] / dlls / gdiplus / font.c
blob82523cea4c607116af4e004a2bde00ffd2dd6c1f
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, FIELD_OFFSET(LOGFONTA,lfFaceName) );
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 GpStatus WINGDIPAPI GdipCreateFontFromDC(HDC hdc, GpFont **font)
93 HFONT hfont;
94 LOGFONTW lfw;
96 if(!font)
97 return InvalidParameter;
99 hfont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
100 if(!hfont)
101 return GenericError;
103 if(!GetObjectW(hfont, sizeof(LOGFONTW), &lfw))
104 return GenericError;
106 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
109 /* FIXME: use graphics */
110 GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics,
111 LOGFONTW *lfw)
113 if(!font || !graphics || !lfw)
114 return InvalidParameter;
116 *lfw = font->lfw;
118 return Ok;
121 GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
123 if(!font || !cloneFont)
124 return InvalidParameter;
126 *cloneFont = GdipAlloc(sizeof(GpFont));
127 if(!*cloneFont) return OutOfMemory;
129 **cloneFont = *font;
131 return Ok;