ReactOS 0.4.16-dev-106-g10b08aa
font.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "winreg.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "objbase.h"
#include "gdiplus.h"
#include "gdiplus_private.h"
#include "pshpack2.h"
#include "poppack.h"
Include dependency graph for font.c:

Go to the source code of this file.

Classes

struct  TT_OS2_V2
 
struct  TT_HHEA
 
struct  font_metrics
 
struct  tt_header
 
struct  tt_table_directory
 
struct  tt_name_table
 
struct  tt_name_record
 
struct  add_font_param
 

Macros

#define GET_BE_WORD(x)   MAKEWORD(HIBYTE(x), LOBYTE(x))
 
#define GET_BE_DWORD(x)   MAKELONG(GET_BE_WORD(HIWORD(x)), GET_BE_WORD(LOWORD(x)));
 
#define MS_MAKE_TAG(ch0, ch1, ch2, ch3)
 
#define MS_OS2_TAG   MS_MAKE_TAG('O','S','/','2')
 
#define MS_HHEA_TAG   MS_MAKE_TAG('h','h','e','a')
 
#define TT_PLATFORM_APPLE_UNICODE   0
 
#define TT_PLATFORM_MACINTOSH   1
 
#define TT_PLATFORM_MICROSOFT   3
 
#define TT_APPLE_ID_DEFAULT   0
 
#define TT_APPLE_ID_ISO_10646   2
 
#define TT_APPLE_ID_UNICODE_2_0   3
 
#define TT_MS_ID_SYMBOL_CS   0
 
#define TT_MS_ID_UNICODE_CS   1
 
#define TT_MAC_ID_SIMPLIFIED_CHINESE   25
 
#define NAME_ID_FULL_FONT_NAME   4
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus)
 
static GpStatus clone_font_family (const GpFontFamily *, GpFontFamily **)
 
GpStatus WINGDIPAPI GdipCreateFont (GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font)
 
GpStatus WINGDIPAPI GdipCreateFontFromLogfontW (HDC hdc, GDIPCONST LOGFONTW *logfont, GpFont **font)
 
GpStatus WINGDIPAPI GdipCreateFontFromLogfontA (HDC hdc, GDIPCONST LOGFONTA *lfa, GpFont **font)
 
GpStatus WINGDIPAPI GdipDeleteFont (GpFont *font)
 
GpStatus WINGDIPAPI GdipCreateFontFromDC (HDC hdc, GpFont **font)
 
GpStatus WINGDIPAPI GdipGetFamily (GpFont *font, GpFontFamily **family)
 
static REAL get_font_size (const GpFont *font)
 
GpStatus WINGDIPAPI GdipGetFontSize (GpFont *font, REAL *size)
 
static INT get_font_style (const GpFont *font)
 
GpStatus WINGDIPAPI GdipGetFontStyle (GpFont *font, INT *style)
 
GpStatus WINGDIPAPI GdipGetFontUnit (GpFont *font, Unit *unit)
 
GpStatus WINGDIPAPI GdipGetLogFontA (GpFont *font, GpGraphics *graphics, LOGFONTA *lfa)
 
GpStatus WINGDIPAPI GdipGetLogFontW (GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
 
GpStatus WINGDIPAPI GdipCloneFont (GpFont *font, GpFont **cloneFont)
 
GpStatus WINGDIPAPI GdipGetFontHeight (GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height)
 
GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI (GDIPCONST GpFont *font, REAL dpi, REAL *height)
 
static INT CALLBACK is_font_installed_proc (const LOGFONTW *elf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
 
static BOOL get_font_metrics (HDC hdc, struct font_metrics *fm)
 
static GpStatus find_installed_font (const WCHAR *name, struct font_metrics *fm)
 
GpStatus WINGDIPAPI GdipCreateFontFamilyFromName (GDIPCONST WCHAR *name, GpFontCollection *fontCollection, GpFontFamily **FontFamily)
 
GpStatus WINGDIPAPI GdipCloneFontFamily (GpFontFamily *FontFamily, GpFontFamily **clonedFontFamily)
 
GpStatus WINGDIPAPI GdipGetFamilyName (GDIPCONST GpFontFamily *family, WCHAR *name, LANGID language)
 
GpStatus WINGDIPAPI GdipDeleteFontFamily (GpFontFamily *FontFamily)
 
GpStatus WINGDIPAPI GdipGetCellAscent (GDIPCONST GpFontFamily *family, INT style, UINT16 *CellAscent)
 
GpStatus WINGDIPAPI GdipGetCellDescent (GDIPCONST GpFontFamily *family, INT style, UINT16 *CellDescent)
 
GpStatus WINGDIPAPI GdipGetEmHeight (GDIPCONST GpFontFamily *family, INT style, UINT16 *EmHeight)
 
GpStatus WINGDIPAPI GdipGetLineSpacing (GDIPCONST GpFontFamily *family, INT style, UINT16 *LineSpacing)
 
static INT CALLBACK font_has_style_proc (const LOGFONTW *elf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
 
GpStatus WINGDIPAPI GdipIsStyleAvailable (GDIPCONST GpFontFamily *family, INT style, BOOL *IsStyleAvailable)
 
GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace (GpFontFamily **nativeFamily)
 
GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif (GpFontFamily **nativeFamily)
 
GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif (GpFontFamily **nativeFamily)
 
GpStatus WINGDIPAPI GdipNewPrivateFontCollection (GpFontCollection **fontCollection)
 
GpStatus WINGDIPAPI GdipDeletePrivateFontCollection (GpFontCollection **fontCollection)
 
GpStatus WINGDIPAPI GdipPrivateAddFontFile (GpFontCollection *collection, GDIPCONST WCHAR *name)
 
static WORD get_mac_code_page (const tt_name_record *name)
 
static int match_name_table_language (const tt_name_record *name, LANGID lang)
 
static WCHARcopy_name_table_string (const tt_name_record *name, const BYTE *data)
 
static WCHARload_ttf_name_id (const BYTE *mem, DWORD_PTR size, DWORD id)
 
static INT CALLBACK add_font_proc (const LOGFONTW *lfw, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
 
GpStatus WINGDIPAPI GdipPrivateAddMemoryFont (GpFontCollection *fontCollection, GDIPCONST void *memory, INT length)
 
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount (GpFontCollection *fontCollection, INT *numFound)
 
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList (GpFontCollection *fontCollection, INT numSought, GpFontFamily *gpfamilies[], INT *numFound)
 
void free_installed_fonts (void)
 
GpStatus WINGDIPAPI GdipNewInstalledFontCollection (GpFontCollection **fontCollection)
 

Variables

static GpFontCollection installedFontCollection = {0}
 
static const LANGID mac_langid_table []
 

Macro Definition Documentation

◆ GET_BE_DWORD

#define GET_BE_DWORD (   x)    MAKELONG(GET_BE_WORD(HIWORD(x)), GET_BE_WORD(LOWORD(x)));

Definition at line 110 of file font.c.

◆ GET_BE_WORD

#define GET_BE_WORD (   x)    MAKEWORD(HIBYTE(x), LOBYTE(x))

Definition at line 109 of file font.c.

◆ MS_HHEA_TAG

#define MS_HHEA_TAG   MS_MAKE_TAG('h','h','e','a')

Definition at line 117 of file font.c.

◆ MS_MAKE_TAG

#define MS_MAKE_TAG (   ch0,
  ch1,
  ch2,
  ch3 
)
Value:
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
unsigned char BYTE
Definition: xxhash.c:193

Definition at line 113 of file font.c.

◆ MS_OS2_TAG

#define MS_OS2_TAG   MS_MAKE_TAG('O','S','/','2')

Definition at line 116 of file font.c.

◆ NAME_ID_FULL_FONT_NAME

#define NAME_ID_FULL_FONT_NAME   4

Definition at line 1185 of file font.c.

◆ TT_APPLE_ID_DEFAULT

#define TT_APPLE_ID_DEFAULT   0

Definition at line 1176 of file font.c.

◆ TT_APPLE_ID_ISO_10646

#define TT_APPLE_ID_ISO_10646   2

Definition at line 1177 of file font.c.

◆ TT_APPLE_ID_UNICODE_2_0

#define TT_APPLE_ID_UNICODE_2_0   3

Definition at line 1178 of file font.c.

◆ TT_MAC_ID_SIMPLIFIED_CHINESE

#define TT_MAC_ID_SIMPLIFIED_CHINESE   25

Definition at line 1183 of file font.c.

◆ TT_MS_ID_SYMBOL_CS

#define TT_MS_ID_SYMBOL_CS   0

Definition at line 1180 of file font.c.

◆ TT_MS_ID_UNICODE_CS

#define TT_MS_ID_UNICODE_CS   1

Definition at line 1181 of file font.c.

◆ TT_PLATFORM_APPLE_UNICODE

#define TT_PLATFORM_APPLE_UNICODE   0

Definition at line 1172 of file font.c.

◆ TT_PLATFORM_MACINTOSH

#define TT_PLATFORM_MACINTOSH   1

Definition at line 1173 of file font.c.

◆ TT_PLATFORM_MICROSOFT

#define TT_PLATFORM_MICROSOFT   3

Definition at line 1174 of file font.c.

Function Documentation

◆ add_font_proc()

static INT CALLBACK add_font_proc ( const LOGFONTW lfw,
const TEXTMETRICW ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 1617 of file font.c.

1619{
1620 struct add_font_param *param = (struct add_font_param *)lParam;
1621 GpFontCollection *fonts = param->collection;
1622 GpFontFamily* family;
1623 GpStatus stat;
1624 int i;
1625
1626 param->stat = Ok;
1627
1628 if (type == RASTER_FONTTYPE)
1629 return 1;
1630
1631 /* skip rotated fonts */
1632 if (lfw->lfFaceName[0] == '@')
1633 return 1;
1634
1635 if (fonts->count && strcmpiW(lfw->lfFaceName, fonts->FontFamilies[fonts->count-1]->FamilyName) == 0)
1636 return 1;
1637
1638 if (fonts->allocated == fonts->count)
1639 {
1640 INT new_alloc_count = fonts->allocated+50;
1641 GpFontFamily** new_family_list = heap_alloc(new_alloc_count*sizeof(void*));
1642
1643 if (!new_family_list)
1644 {
1645 param->stat = OutOfMemory;
1646 return 0;
1647 }
1648
1649 memcpy(new_family_list, fonts->FontFamilies, fonts->count*sizeof(void*));
1650 heap_free(fonts->FontFamilies);
1651 fonts->FontFamilies = new_family_list;
1652 fonts->allocated = new_alloc_count;
1653 }
1654
1655 if ((stat = GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &family)) != Ok)
1656 {
1657 WARN("Failed to create font family for %s, status %d.\n", debugstr_w(lfw->lfFaceName), stat);
1658 if (param->is_system)
1659 return 1;
1660 param->stat = stat;
1661 return 0;
1662 }
1663
1664 /* skip duplicates */
1665 for (i=0; i<fonts->count; i++)
1666 {
1667 if (strcmpiW(family->FamilyName, fonts->FontFamilies[i]->FamilyName) == 0)
1668 {
1669 GdipDeleteFontFamily(family);
1670 return 1;
1671 }
1672 }
1673
1674 fonts->FontFamilies[fonts->count++] = family;
1675
1676 return 1;
1677}
#define stat
Definition: acwin.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define WARN(fmt,...)
Definition: precomp.h:61
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
Definition: font.c:869
GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, GpFontCollection *fontCollection, GpFontFamily **FontFamily)
Definition: font.c:746
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
@ OutOfMemory
Definition: gdiplustypes.h:29
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define strcmpiW(s1, s2)
Definition: unicode.h:45
GpFontFamily ** FontFamilies
WCHAR FamilyName[LF_FACESIZE]
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
Definition: stat.h:55
int32_t INT
Definition: typedefs.h:58
#define RASTER_FONTTYPE
Definition: wingdi.h:1107

Referenced by GdipNewInstalledFontCollection(), and GdipPrivateAddMemoryFont().

◆ clone_font_family()

static GpStatus clone_font_family ( const GpFontFamily family,
GpFontFamily **  clone 
)
static

Definition at line 781 of file font.c.

782{
783 *clone = heap_alloc_zero(sizeof(GpFontFamily));
784 if (!*clone) return OutOfMemory;
785
786 **clone = *family;
787
788 return Ok;
789}

Referenced by GdipCloneFontFamily(), and GdipCreateFont().

◆ copy_name_table_string()

static WCHAR * copy_name_table_string ( const tt_name_record name,
const BYTE data 
)
static

Definition at line 1397 of file font.c.

1398{
1399 WORD name_len = GET_BE_WORD(name->length);
1400 WORD codepage;
1401 WCHAR *ret;
1402 int len;
1403
1404 switch (GET_BE_WORD(name->platform_id))
1405 {
1408 ret = heap_alloc((name_len / 2 + 1) * sizeof(WCHAR));
1409 for (len = 0; len < name_len / 2; len++)
1410 ret[len] = (data[len * 2] << 8) | data[len * 2 + 1];
1411 ret[len] = 0;
1412 return ret;
1415 len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, NULL, 0 ) + 1;
1416 if (!len)
1417 return NULL;
1418 ret = heap_alloc(len * sizeof(WCHAR));
1419 len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, ret, len - 1 );
1420 ret[len] = 0;
1421 return ret;
1422 }
1423 return NULL;
1424}
#define MultiByteToWideChar
Definition: compat.h:110
static WORD get_mac_code_page(const tt_name_record *name)
Definition: font.c:1344
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
#define TT_PLATFORM_MACINTOSH
Definition: font.c:1173
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1172
#define GET_BE_WORD(x)
Definition: font.c:109
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
Definition: name.c:39
int ret
int codepage
Definition: win_iconv.c:156
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by load_ttf_name_id().

◆ find_installed_font()

static GpStatus find_installed_font ( const WCHAR name,
struct font_metrics fm 
)
static

Definition at line 703 of file font.c.

704{
705 LOGFONTW lf;
708
710 {
711 HFONT hfont, old_font;
712
713 strcpyW(fm->facename, lf.lfFaceName);
714
716 old_font = SelectObject(hdc, hfont);
718 SelectObject(hdc, old_font);
720 }
721
722 DeleteDC(hdc);
723 return ret;
724}
static HFONT hfont
static BOOL get_font_metrics(HDC hdc, struct font_metrics *fm)
Definition: font.c:654
static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
Definition: font.c:632
pKey DeleteObject()
@ NotTrueTypeFont
Definition: gdiplustypes.h:42
@ FontFamilyNotFound
Definition: gdiplustypes.h:40
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define strcpyW(d, s)
Definition: unicode.h:35
WCHAR facename[LF_FACESIZE]
Definition: font.c:649
LONG_PTR LPARAM
Definition: windef.h:208
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI EnumFontFamiliesW(_In_ HDC, _In_opt_ LPCWSTR, _In_ FONTENUMPROCW, _In_ LPARAM)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by GdipCreateFontFamilyFromName().

◆ font_has_style_proc()

static INT CALLBACK font_has_style_proc ( const LOGFONTW elf,
const TEXTMETRICW ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 961 of file font.c.

963{
964 INT fontstyle = FontStyleRegular;
965
966 if (!ntm) return 1;
967
968 if (ntm->tmWeight >= FW_BOLD) fontstyle |= FontStyleBold;
969 if (ntm->tmItalic) fontstyle |= FontStyleItalic;
970 if (ntm->tmUnderlined) fontstyle |= FontStyleUnderline;
971 if (ntm->tmStruckOut) fontstyle |= FontStyleStrikeout;
972
973 return (INT)lParam != fontstyle;
974}
@ FontStyleUnderline
Definition: gdiplusenums.h:307
@ FontStyleBold
Definition: gdiplusenums.h:304
@ FontStyleStrikeout
Definition: gdiplusenums.h:308
@ FontStyleRegular
Definition: gdiplusenums.h:303
@ FontStyleItalic
Definition: gdiplusenums.h:305
BYTE tmItalic
Definition: wingdi.h:2398
BYTE tmStruckOut
Definition: wingdi.h:2400
BYTE tmUnderlined
Definition: wingdi.h:2399
LONG tmWeight
Definition: wingdi.h:2390
#define FW_BOLD
Definition: wingdi.h:378

Referenced by GdipIsStyleAvailable().

◆ free_installed_fonts()

void free_installed_fonts ( void  )

◆ GdipCloneFont()

GpStatus WINGDIPAPI GdipCloneFont ( GpFont font,
GpFont **  cloneFont 
)

Definition at line 520 of file font.c.

521{
523
524 TRACE("(%p, %p)\n", font, cloneFont);
525
526 if(!font || !cloneFont)
527 return InvalidParameter;
528
529 *cloneFont = heap_alloc_zero(sizeof(GpFont));
530 if(!*cloneFont) return OutOfMemory;
531
532 **cloneFont = *font;
533 stat = GdipCloneFontFamily(font->family, &(*cloneFont)->family);
534 if (stat != Ok) heap_free(*cloneFont);
535
536 return stat;
537}
GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily *FontFamily, GpFontFamily **clonedFontFamily)
Definition: font.c:803
@ InvalidParameter
Definition: gdiplustypes.h:28
Definition: mk_font.cpp:20
#define TRACE(s)
Definition: solgame.cpp:4

◆ GdipCloneFontFamily()

GpStatus WINGDIPAPI GdipCloneFontFamily ( GpFontFamily FontFamily,
GpFontFamily **  clonedFontFamily 
)

Definition at line 803 of file font.c.

804{
806
807 if (!(FontFamily && clonedFontFamily)) return InvalidParameter;
808
809 TRACE("%p (%s), %p\n", FontFamily,
810 debugstr_w(FontFamily->FamilyName), clonedFontFamily);
811
812 status = clone_font_family(FontFamily, clonedFontFamily);
813 if (status != Ok) return status;
814
815 TRACE("<-- %p\n", *clonedFontFamily);
816
817 return Ok;
818}
static GpStatus clone_font_family(const GpFontFamily *, GpFontFamily **)
Definition: font.c:781
Definition: ps.c:97

Referenced by GdipCloneFont(), GdipGetFamily(), GdipGetFontCollectionFamilyList(), and test_fontfamily().

◆ GdipCreateFont()

GpStatus WINGDIPAPI GdipCreateFont ( GDIPCONST GpFontFamily fontFamily,
REAL  emSize,
INT  style,
Unit  unit,
GpFont **  font 
)

Definition at line 144 of file font.c.

146{
147 HFONT hfont;
149 LOGFONTW lfw;
150 HDC hdc;
152 int ret;
153
154 if (!fontFamily || !font || emSize < 0.0)
155 return InvalidParameter;
156
157 TRACE("%p (%s), %f, %d, %d, %p\n", fontFamily,
158 debugstr_w(fontFamily->FamilyName), emSize, style, unit, font);
159
160 memset(&lfw, 0, sizeof(lfw));
161
162 stat = GdipGetFamilyName(fontFamily, lfw.lfFaceName, LANG_NEUTRAL);
163 if (stat != Ok) return stat;
164
165 lfw.lfHeight = -units_to_pixels(emSize, unit, fontFamily->dpi);
170
174 otm.otmSize = sizeof(otm);
176 DeleteDC(hdc);
178
179 if (!ret) return NotTrueTypeFont;
180
181 *font = heap_alloc_zero(sizeof(GpFont));
182 if (!*font) return OutOfMemory;
183
184 (*font)->unit = unit;
185 (*font)->emSize = emSize;
186 (*font)->otm = otm;
187
188 stat = clone_font_family(fontFamily, &(*font)->family);
189 if (stat != Ok)
190 {
191 heap_free(*font);
192 return stat;
193 }
194
195 TRACE("<-- %p\n", *font);
196
197 return Ok;
198}
Arabic default style
Definition: afstyles.h:94
GpStatus WINGDIPAPI GdipGetFamilyName(GDIPCONST GpFontFamily *family, WCHAR *name, LANGID language)
Definition: font.c:837
REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi)
Definition: gdiplus.c:327
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
#define LANG_NEUTRAL
Definition: nls.h:22
#define memset(x, y, z)
Definition: compat.h:39
BYTE lfStrikeOut
Definition: dimm.idl:66
BYTE lfItalic
Definition: dimm.idl:64
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
BYTE lfUnderline
Definition: dimm.idl:65
#define FW_REGULAR
Definition: wingdi.h:374
UINT WINAPI GetOutlineTextMetricsW(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICW potm)

Referenced by check_family(), GdipAddPathString(), METAFILE_PlaybackObject(), test_createfont(), test_font_height_scaling(), test_font_metrics(), test_font_substitution(), test_GdipMeasureString(), test_heightgivendpi(), test_long_name(), test_measure_string(), test_measured_extra_space(), and test_string_functions().

◆ GdipCreateFontFamilyFromName()

GpStatus WINGDIPAPI GdipCreateFontFamilyFromName ( GDIPCONST WCHAR name,
GpFontCollection fontCollection,
GpFontFamily **  FontFamily 
)

Definition at line 746 of file font.c.

749{
751 GpFontFamily* ffamily;
752 struct font_metrics fm;
753
754 TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
755
756 if (!(name && FontFamily))
757 return InvalidParameter;
758 if (fontCollection)
759 FIXME("No support for FontCollections yet!\n");
760
762 if (stat != Ok) return stat;
763
764 ffamily = heap_alloc_zero(sizeof (GpFontFamily));
765 if (!ffamily) return OutOfMemory;
766
767 lstrcpyW(ffamily->FamilyName, fm.facename);
768 ffamily->em_height = fm.em_height;
769 ffamily->ascent = fm.ascent;
770 ffamily->descent = fm.descent;
771 ffamily->line_spacing = fm.line_spacing;
772 ffamily->dpi = fm.dpi;
773
774 *FontFamily = ffamily;
775
776 TRACE("<-- %p\n", ffamily);
777
778 return Ok;
779}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define lstrcpyW
Definition: compat.h:749
static GpStatus find_installed_font(const WCHAR *name, struct font_metrics *fm)
Definition: font.c:703

Referenced by add_font_proc(), GdipCreateFontFromLogfontW(), GdipGetGenericFontFamilyMonospace(), GdipGetGenericFontFamilySansSerif(), GdipGetGenericFontFamilySerif(), METAFILE_PlaybackObject(), test_createfont(), test_font_height_scaling(), test_font_metrics(), test_font_substitution(), test_fontfamily(), test_fontfamily_properties(), test_GdipMeasureString(), test_heightgivendpi(), test_measure_string(), test_measured_extra_space(), and test_string_functions().

◆ GdipCreateFontFromDC()

GpStatus WINGDIPAPI GdipCreateFontFromDC ( HDC  hdc,
GpFont **  font 
)

Definition at line 286 of file font.c.

287{
288 HFONT hfont;
289 LOGFONTW lfw;
290
291 TRACE("(%p, %p)\n", hdc, font);
292
293 if(!font)
294 return InvalidParameter;
295
297 if(!hfont)
298 return GenericError;
299
300 if(!GetObjectW(hfont, sizeof(LOGFONTW), &lfw))
301 return GenericError;
302
303 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
304}
GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, GDIPCONST LOGFONTW *logfont, GpFont **font)
Definition: font.c:203
@ GenericError
Definition: gdiplustypes.h:27
#define OBJ_FONT
Definition: objidl.idl:1414
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428

◆ GdipCreateFontFromLogfontA()

GpStatus WINGDIPAPI GdipCreateFontFromLogfontA ( HDC  hdc,
GDIPCONST LOGFONTA lfa,
GpFont **  font 
)

Definition at line 249 of file font.c.

251{
252 LOGFONTW lfw;
253
254 TRACE("(%p, %p, %p)\n", hdc, lfa, font);
255
256 if(!lfa || !font)
257 return InvalidParameter;
258
259 memcpy(&lfw, lfa, FIELD_OFFSET(LOGFONTA,lfFaceName) );
260
261 if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE))
262 return GenericError;
263
264 return GdipCreateFontFromLogfontW(hdc, &lfw, font);
265}
#define LF_FACESIZE
Definition: dimm.idl:39
#define CP_ACP
Definition: compat.h:109
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by test_font_substitution(), test_font_transform(), test_GdipDrawString(), and test_logfont().

◆ GdipCreateFontFromLogfontW()

GpStatus WINGDIPAPI GdipCreateFontFromLogfontW ( HDC  hdc,
GDIPCONST LOGFONTW logfont,
GpFont **  font 
)

Definition at line 203 of file font.c.

205{
206 HFONT hfont, oldfont;
208 WCHAR facename[LF_FACESIZE];
210 int ret;
211
212 TRACE("(%p, %p, %p)\n", hdc, logfont, font);
213
214 if (!hdc || !logfont || !font)
215 return InvalidParameter;
216
217 hfont = CreateFontIndirectW(logfont);
218 oldfont = SelectObject(hdc, hfont);
219 otm.otmSize = sizeof(otm);
221 GetTextFaceW(hdc, LF_FACESIZE, facename);
222 SelectObject(hdc, oldfont);
224
225 if (!ret) return NotTrueTypeFont;
226
227 *font = heap_alloc_zero(sizeof(GpFont));
228 if (!*font) return OutOfMemory;
229
230 (*font)->unit = UnitWorld;
231 (*font)->emSize = otm.otmTextMetrics.tmAscent;
232 (*font)->otm = otm;
233
234 stat = GdipCreateFontFamilyFromName(facename, NULL, &(*font)->family);
235 if (stat != Ok)
236 {
237 heap_free(*font);
238 return NotTrueTypeFont;
239 }
240
241 TRACE("<-- %p\n", *font);
242
243 return Ok;
244}
@ UnitWorld
Definition: gdiplusenums.h:27
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2514
LONG tmAscent
Definition: wingdi.h:2384
int WINAPI GetTextFaceW(_In_ HDC hdc, _In_ int c, _Out_writes_to_opt_(c, return) LPWSTR lpName)

Referenced by GdipCreateFontFromDC(), GdipCreateFontFromLogfontA(), and test_font_metrics().

◆ GdipDeleteFont()

◆ GdipDeleteFontFamily()

◆ GdipDeletePrivateFontCollection()

GpStatus WINGDIPAPI GdipDeletePrivateFontCollection ( GpFontCollection **  fontCollection)

Definition at line 1118 of file font.c.

1119{
1120 INT i;
1121
1122 TRACE("%p\n", fontCollection);
1123
1124 if (!fontCollection)
1125 return InvalidParameter;
1126
1127 for (i = 0; i < (*fontCollection)->count; i++) heap_free((*fontCollection)->FontFamilies[i]);
1128 heap_free((*fontCollection)->FontFamilies);
1129 heap_free(*fontCollection);
1130
1131 return Ok;
1132}

Referenced by test_long_name().

◆ GdipGetCellAscent()

GpStatus WINGDIPAPI GdipGetCellAscent ( GDIPCONST GpFontFamily family,
INT  style,
UINT16 CellAscent 
)

Definition at line 880 of file font.c.

882{
883 if (!(family && CellAscent)) return InvalidParameter;
884
885 *CellAscent = family->ascent;
886 TRACE("%s => %u\n", debugstr_w(family->FamilyName), *CellAscent);
887
888 return Ok;
889}

Referenced by gdip_get_font_metrics(), and test_fontfamily_properties().

◆ GdipGetCellDescent()

GpStatus WINGDIPAPI GdipGetCellDescent ( GDIPCONST GpFontFamily family,
INT  style,
UINT16 CellDescent 
)

Definition at line 891 of file font.c.

893{
894 TRACE("(%p, %d, %p)\n", family, style, CellDescent);
895
896 if (!(family && CellDescent)) return InvalidParameter;
897
898 *CellDescent = family->descent;
899 TRACE("%s => %u\n", debugstr_w(family->FamilyName), *CellDescent);
900
901 return Ok;
902}

Referenced by gdip_get_font_metrics(), and test_fontfamily_properties().

◆ GdipGetEmHeight()

GpStatus WINGDIPAPI GdipGetEmHeight ( GDIPCONST GpFontFamily family,
INT  style,
UINT16 EmHeight 
)

Definition at line 918 of file font.c.

919{
920 if (!(family && EmHeight)) return InvalidParameter;
921
922 TRACE("%p (%s), %d, %p\n", family, debugstr_w(family->FamilyName), style, EmHeight);
923
924 *EmHeight = family->em_height;
925 TRACE("%s => %u\n", debugstr_w(family->FamilyName), *EmHeight);
926
927 return Ok;
928}

Referenced by gdip_get_font_metrics(), GdipAddPathString(), GdipGetFontHeightGivenDPI(), test_fontfamily_properties(), and test_logfont().

◆ GdipGetFamily()

GpStatus WINGDIPAPI GdipGetFamily ( GpFont font,
GpFontFamily **  family 
)

Definition at line 319 of file font.c.

320{
321 TRACE("%p %p\n", font, family);
322
323 if (!(font && family))
324 return InvalidParameter;
325
326 return GdipCloneFontFamily(font->family, family);
327}

Referenced by gdip_get_font_metrics(), test_createfont(), and test_logfont().

◆ GdipGetFamilyName()

GpStatus WINGDIPAPI GdipGetFamilyName ( GDIPCONST GpFontFamily family,
WCHAR name,
LANGID  language 
)

Definition at line 837 of file font.c.

839{
840 static int lang_fixme;
841
842 if (family == NULL)
843 return InvalidParameter;
844
845 TRACE("%p, %p, %d\n", family, name, language);
846
847 if (language != LANG_NEUTRAL && !lang_fixme++)
848 FIXME("No support for handling of multiple languages!\n");
849
850 lstrcpynW (name, family->FamilyName, LF_FACESIZE);
851
852 return Ok;
853}
#define lstrcpynW
Definition: compat.h:738

Referenced by check_family(), GdipCreateFont(), test_createfont(), test_fontfamily(), and test_long_name().

◆ GdipGetFontCollectionFamilyCount()

GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount ( GpFontCollection fontCollection,
INT numFound 
)

Definition at line 1559 of file font.c.

1561{
1562 TRACE("%p, %p\n", fontCollection, numFound);
1563
1564 if (!(fontCollection && numFound))
1565 return InvalidParameter;
1566
1567 *numFound = fontCollection->count;
1568 return Ok;
1569}

Referenced by test_GdipGetFontCollectionFamilyCount(), test_GdipGetFontCollectionFamilyList(), and test_long_name().

◆ GdipGetFontCollectionFamilyList()

GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList ( GpFontCollection fontCollection,
INT  numSought,
GpFontFamily gpfamilies[],
INT numFound 
)

Definition at line 1574 of file font.c.

1577{
1578 INT i;
1580
1581 TRACE("%p, %d, %p, %p\n", fontCollection, numSought, gpfamilies, numFound);
1582
1583 if (!(fontCollection && gpfamilies && numFound))
1584 return InvalidParameter;
1585
1586 memset(gpfamilies, 0, sizeof(*gpfamilies) * numSought);
1587
1588 for (i = 0; i < numSought && i < fontCollection->count && stat == Ok; i++)
1589 {
1590 stat = GdipCloneFontFamily(fontCollection->FontFamilies[i], &gpfamilies[i]);
1591 }
1592
1593 if (stat == Ok)
1594 *numFound = i;
1595 else
1596 {
1597 int numToFree=i;
1598 for (i=0; i<numToFree; i++)
1599 {
1600 GdipDeleteFontFamily(gpfamilies[i]);
1601 gpfamilies[i] = NULL;
1602 }
1603 }
1604
1605 return stat;
1606}

Referenced by test_GdipGetFontCollectionFamilyList(), and test_long_name().

◆ GdipGetFontHeight()

GpStatus WINGDIPAPI GdipGetFontHeight ( GDIPCONST GpFont font,
GDIPCONST GpGraphics graphics,
REAL height 
)

Definition at line 552 of file font.c.

554{
555 REAL dpi;
558
559 TRACE("%p %p %p\n", font, graphics, height);
560
561 if (!font || !height) return InvalidParameter;
562
564 if (stat != Ok) return stat;
565
566 if (!graphics)
567 {
569 TRACE("%s,%d => %f\n",
570 debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *height);
571 return Ok;
572 }
573
574 stat = GdipGetDpiY((GpGraphics *)graphics, &dpi);
575 if (stat != Ok) return stat;
576
577 *height = pixels_to_units(font_height, graphics->unit, dpi);
578
579 TRACE("%s,%d(unit %d) => %f\n",
580 debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, graphics->unit, *height);
581 return Ok;
582}
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
Definition: font.c:599
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6639
REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi)
Definition: gdiplus.c:350
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static int font_height(HFONT hFont)
Definition: combo.c:46
#define dpi
Definition: sysparams.c:23

Referenced by gdip_get_font_metrics(), test_font_height_scaling(), test_font_transform(), and test_logfont().

◆ GdipGetFontHeightGivenDPI()

GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI ( GDIPCONST GpFont font,
REAL  dpi,
REAL height 
)

Definition at line 599 of file font.c.

600{
602 INT style;
603 UINT16 line_spacing, em_height;
605
606 if (!font || !height) return InvalidParameter;
607
608 TRACE("%p (%s), %f, %p\n", font,
609 debugstr_w(font->family->FamilyName), dpi, height);
610
613 stat = GdipGetLineSpacing(font->family, style, &line_spacing);
614 if (stat != Ok) return stat;
615 stat = GdipGetEmHeight(font->family, style, &em_height);
616 if (stat != Ok) return stat;
617
618 *height = (REAL)line_spacing * font_size / (REAL)em_height;
619
620 TRACE("%s,%d => %f\n",
621 debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *height);
622
623 return Ok;
624}
unsigned short UINT16
static INT get_font_style(const GpFont *font)
Definition: font.c:362
GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family, INT style, UINT16 *LineSpacing)
Definition: font.c:945
GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, UINT16 *EmHeight)
Definition: font.c:918
static REAL get_font_size(const GpFont *font)
Definition: font.c:329
static FT_F26Dot6 font_size
Definition: ftrandom.c:89

Referenced by GdipGetFontHeight(), and test_heightgivendpi().

◆ GdipGetFontSize()

GpStatus WINGDIPAPI GdipGetFontSize ( GpFont font,
REAL size 
)

Definition at line 350 of file font.c.

351{
352 TRACE("(%p, %p)\n", font, size);
353
354 if (!(font && size)) return InvalidParameter;
355
357 TRACE("%s,%d => %f\n", debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *size);
358
359 return Ok;
360}
GLsizeiptr size
Definition: glext.h:5919

Referenced by gdip_get_font_metrics(), test_createfont(), test_GdipMeasureString(), test_logfont(), and test_measured_extra_space().

◆ GdipGetFontStyle()

GpStatus WINGDIPAPI GdipGetFontStyle ( GpFont font,
INT style 
)

Definition at line 393 of file font.c.

394{
395 TRACE("%p %p\n", font, style);
396
397 if (!(font && style))
398 return InvalidParameter;
399
401 TRACE("%s,%d => %d\n", debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *style);
402
403 return Ok;
404}

Referenced by gdip_get_font_metrics(), and test_logfont().

◆ GdipGetFontUnit()

GpStatus WINGDIPAPI GdipGetFontUnit ( GpFont font,
Unit unit 
)

Definition at line 417 of file font.c.

418{
419 TRACE("(%p, %p)\n", font, unit);
420
421 if (!(font && unit)) return InvalidParameter;
422
423 *unit = font->unit;
424 TRACE("%s,%d => %d\n", debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *unit);
425
426 return Ok;
427}

Referenced by test_createfont(), test_font_metrics(), test_GdipMeasureString(), test_heightgivendpi(), and test_logfont().

◆ GdipGetGenericFontFamilyMonospace()

GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace ( GpFontFamily **  nativeFamily)

Definition at line 1010 of file font.c.

1011{
1012 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
1013 static const WCHAR LiberationMono[] = {'L','i','b','e','r','a','t','i','o','n',' ','M','o','n','o','\0'};
1014 GpStatus stat;
1015
1016 if (nativeFamily == NULL) return InvalidParameter;
1017
1018 stat = GdipCreateFontFamilyFromName(CourierNew, NULL, nativeFamily);
1019
1020 if (stat == FontFamilyNotFound)
1021 stat = GdipCreateFontFamilyFromName(LiberationMono, NULL, nativeFamily);
1022
1023 if (stat == FontFamilyNotFound)
1024 ERR("Missing 'Courier New' font\n");
1025
1026 return stat;
1027}
#define ERR(fmt,...)
Definition: precomp.h:57

Referenced by test_getgenerics().

◆ GdipGetGenericFontFamilySansSerif()

GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif ( GpFontFamily **  nativeFamily)

Definition at line 1074 of file font.c.

1075{
1076 GpStatus stat;
1077 static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
1078 static const WCHAR Tahoma[] = {'T','a','h','o','m','a','\0'};
1079
1080 TRACE("(%p)\n", nativeFamily);
1081
1082 if (nativeFamily == NULL) return InvalidParameter;
1083
1084 stat = GdipCreateFontFamilyFromName(MicrosoftSansSerif, NULL, nativeFamily);
1085
1086 if (stat == FontFamilyNotFound)
1087 /* FIXME: Microsoft Sans Serif is not installed on Wine. */
1088 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, nativeFamily);
1089
1090 return stat;
1091}
static const WCHAR Tahoma[]
Definition: font.c:36

Referenced by test_getgenerics().

◆ GdipGetGenericFontFamilySerif()

GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif ( GpFontFamily **  nativeFamily)

Definition at line 1041 of file font.c.

1042{
1043 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
1044 static const WCHAR LiberationSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f','\0'};
1045 GpStatus stat;
1046
1047 TRACE("(%p)\n", nativeFamily);
1048
1049 if (nativeFamily == NULL) return InvalidParameter;
1050
1052
1053 if (stat == FontFamilyNotFound)
1054 stat = GdipCreateFontFamilyFromName(LiberationSerif, NULL, nativeFamily);
1055
1056 if (stat == FontFamilyNotFound)
1057 ERR("Missing 'Times New Roman' font\n");
1058
1059 return stat;
1060}
static const WCHAR TimesNewRoman[]
Definition: font.c:35

Referenced by test_getgenerics().

◆ GdipGetLineSpacing()

GpStatus WINGDIPAPI GdipGetLineSpacing ( GDIPCONST GpFontFamily family,
INT  style,
UINT16 LineSpacing 
)

Definition at line 945 of file font.c.

947{
948 TRACE("%p, %d, %p\n", family, style, LineSpacing);
949
950 if (!(family && LineSpacing))
951 return InvalidParameter;
952
953 if (style) FIXME("ignoring style\n");
954
955 *LineSpacing = family->line_spacing;
956 TRACE("%s => %u\n", debugstr_w(family->FamilyName), *LineSpacing);
957
958 return Ok;
959}

Referenced by gdip_get_font_metrics(), GdipGetFontHeightGivenDPI(), test_fontfamily_properties(), and test_logfont().

◆ GdipGetLogFontA()

GpStatus WINGDIPAPI GdipGetLogFontA ( GpFont font,
GpGraphics graphics,
LOGFONTA lfa 
)

Definition at line 432 of file font.c.

434{
436 LOGFONTW lfw;
437
438 TRACE("(%p, %p, %p)\n", font, graphics, lfa);
439
440 status = GdipGetLogFontW(font, graphics, &lfw);
441 if(status != Ok)
442 return status;
443
444 memcpy(lfa, &lfw, FIELD_OFFSET(LOGFONTA,lfFaceName) );
445
447 return GenericError;
448
449 return Ok;
450}
#define WideCharToMultiByte
Definition: compat.h:111
GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
Definition: font.c:455
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55

Referenced by test_font_substitution(), test_font_transform(), and test_logfont().

◆ GdipGetLogFontW()

GpStatus WINGDIPAPI GdipGetLogFontW ( GpFont font,
GpGraphics graphics,
LOGFONTW lf 
)

Definition at line 455 of file font.c.

456{
457 REAL angle, rel_height, height;
459 GpPointF pt[3];
460
461 TRACE("(%p, %p, %p)\n", font, graphics, lf);
462
463 if (!font || !graphics || !lf)
464 return InvalidParameter;
465
466 matrix = graphics->worldtrans;
467
468 if (font->unit == UnitPixel || font->unit == UnitWorld)
469 {
470 height = units_to_pixels(font->emSize, graphics->unit, graphics->yres);
471 if (graphics->unit != UnitDisplay)
472 GdipScaleMatrix(&matrix, graphics->scale, graphics->scale, MatrixOrderAppend);
473 }
474 else
475 {
476 if (graphics->unit == UnitDisplay || graphics->unit == UnitPixel)
477 height = units_to_pixels(font->emSize, font->unit, graphics->xres);
478 else
479 height = units_to_pixels(font->emSize, font->unit, graphics->yres);
480 }
481
482 pt[0].X = 0.0;
483 pt[0].Y = 0.0;
484 pt[1].X = 1.0;
485 pt[1].Y = 0.0;
486 pt[2].X = 0.0;
487 pt[2].Y = 1.0;
489 angle = -gdiplus_atan2((pt[1].Y - pt[0].Y), (pt[1].X - pt[0].X));
490 rel_height = sqrt((pt[2].Y - pt[0].Y) * (pt[2].Y - pt[0].Y)+
491 (pt[2].X - pt[0].X) * (pt[2].X - pt[0].X));
492
493 lf->lfHeight = -gdip_round(height * rel_height);
494 lf->lfWidth = 0;
495 lf->lfEscapement = lf->lfOrientation = gdip_round((angle / M_PI) * 1800.0);
496 if (lf->lfEscapement < 0)
497 {
498 lf->lfEscapement += 3600;
499 lf->lfOrientation += 3600;
500 }
501 lf->lfWeight = font->otm.otmTextMetrics.tmWeight;
502 lf->lfItalic = font->otm.otmTextMetrics.tmItalic ? 1 : 0;
503 lf->lfUnderline = font->otm.otmTextMetrics.tmUnderlined ? 1 : 0;
504 lf->lfStrikeOut = font->otm.otmTextMetrics.tmStruckOut ? 1 : 0;
505 lf->lfCharSet = font->otm.otmTextMetrics.tmCharSet;
509 lf->lfPitchAndFamily = 0;
510 strcpyW(lf->lfFaceName, font->family->FamilyName);
511
512 TRACE("=> %s,%d\n", debugstr_w(lf->lfFaceName), lf->lfHeight);
513
514 return Ok;
515}
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
#define Y(I)
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:289
GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts, INT count)
Definition: matrix.c:363
#define pt(x, y)
Definition: drawing.c:79
REAL gdiplus_atan2(REAL dy, REAL dx)
Definition: gdiplus.c:304
static INT gdip_round(REAL x)
@ MatrixOrderAppend
Definition: gdiplusenums.h:189
@ UnitDisplay
Definition: gdiplusenums.h:28
@ UnitPixel
Definition: gdiplusenums.h:29
GLuint GLenum matrix
Definition: glext.h:9407
GLfloat angle
Definition: glext.h:10853
#define M_PI
Definition: macros.h:263
GpMatrix worldtrans
BYTE lfOutPrecision
Definition: dimm.idl:68
LONG lfOrientation
Definition: dimm.idl:62
LONG lfWidth
Definition: dimm.idl:60
BYTE lfClipPrecision
Definition: dimm.idl:69
LONG lfEscapement
Definition: dimm.idl:61
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfQuality
Definition: dimm.idl:70
BYTE lfPitchAndFamily
Definition: dimm.idl:71
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426

Referenced by GdipGetLogFontA(), test_font_metrics(), and test_GdipMeasureString().

◆ GdipIsStyleAvailable()

GpStatus WINGDIPAPI GdipIsStyleAvailable ( GDIPCONST GpFontFamily family,
INT  style,
BOOL IsStyleAvailable 
)

Definition at line 976 of file font.c.

978{
979 HDC hdc;
980
981 TRACE("%p %d %p\n", family, style, IsStyleAvailable);
982
983 if (!(family && IsStyleAvailable))
984 return InvalidParameter;
985
986 *IsStyleAvailable = FALSE;
987
989
990 if(!EnumFontFamiliesW(hdc, family->FamilyName, font_has_style_proc, (LPARAM)style))
991 *IsStyleAvailable = TRUE;
992
993 DeleteDC(hdc);
994
995 return Ok;
996}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static INT CALLBACK font_has_style_proc(const LOGFONTW *elf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
Definition: font.c:961

◆ GdipNewInstalledFontCollection()

GpStatus WINGDIPAPI GdipNewInstalledFontCollection ( GpFontCollection **  fontCollection)

Definition at line 1679 of file font.c.

1681{
1682 TRACE("(%p)\n",fontCollection);
1683
1684 if (!fontCollection)
1685 return InvalidParameter;
1686
1688 {
1689 struct add_font_param param;
1690 HDC hdc;
1691 LOGFONTW lfw;
1692
1694
1696 lfw.lfFaceName[0] = 0;
1697 lfw.lfPitchAndFamily = 0;
1698
1699 param.collection = &installedFontCollection;
1700 param.is_system = TRUE;
1702 {
1704 DeleteDC(hdc);
1705 return param.stat;
1706 }
1707
1708 DeleteDC(hdc);
1709 }
1710
1711 *fontCollection = &installedFontCollection;
1712
1713 return Ok;
1714}
void free_installed_fonts(void)
Definition: font.c:1608
static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
Definition: font.c:1617
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
#define DEFAULT_CHARSET
Definition: wingdi.h:384

Referenced by test_GdipGetFontCollectionFamilyCount(), test_GdipGetFontCollectionFamilyList(), and test_installedfonts().

◆ GdipNewPrivateFontCollection()

GpStatus WINGDIPAPI GdipNewPrivateFontCollection ( GpFontCollection **  fontCollection)

Definition at line 1096 of file font.c.

1097{
1098 TRACE("%p\n", fontCollection);
1099
1100 if (!fontCollection)
1101 return InvalidParameter;
1102
1103 *fontCollection = heap_alloc_zero(sizeof(GpFontCollection));
1104 if (!*fontCollection) return OutOfMemory;
1105
1106 (*fontCollection)->FontFamilies = NULL;
1107 (*fontCollection)->count = 0;
1108 (*fontCollection)->allocated = 0;
1109
1110 TRACE("<-- %p\n", *fontCollection);
1111
1112 return Ok;
1113}

Referenced by test_long_name().

◆ GdipPrivateAddFontFile()

GpStatus WINGDIPAPI GdipPrivateAddFontFile ( GpFontCollection collection,
GDIPCONST WCHAR name 
)

Definition at line 1137 of file font.c.

1138{
1141 void *mem;
1143
1144 TRACE("%p, %s\n", collection, debugstr_w(name));
1145
1146 if (!collection || !name) return InvalidParameter;
1147
1150
1151 if (!GetFileSizeEx(file, &size) || size.u.HighPart)
1152 {
1154 return InvalidParameter;
1155 }
1156
1159 if (!mapping) return InvalidParameter;
1160
1163 if (!mem) return InvalidParameter;
1164
1165 /* GdipPrivateAddMemoryFont creates a copy of the memory block */
1168
1169 return status;
1170}
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define GetFileSizeEx
Definition: compat.h:757
#define MapViewOfFile
Definition: compat.h:745
GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection *fontCollection, GDIPCONST void *memory, INT length)
Definition: font.c:1509
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static ICollection collection
Definition: typelib.c:184
Definition: fci.c:127
Definition: mem.c:156

Referenced by test_long_name().

◆ GdipPrivateAddMemoryFont()

GpStatus WINGDIPAPI GdipPrivateAddMemoryFont ( GpFontCollection fontCollection,
GDIPCONST void memory,
INT  length 
)

Definition at line 1509 of file font.c.

1511{
1512 WCHAR *name;
1513 DWORD count = 0;
1514 HANDLE font;
1515 GpStatus ret = Ok;
1516 TRACE("%p, %p, %d\n", fontCollection, memory, length);
1517
1518 if (!fontCollection || !memory || !length)
1519 return InvalidParameter;
1520
1522 if (!name)
1523 return OutOfMemory;
1524
1526 TRACE("%s: %p/%u\n", debugstr_w(name), font, count);
1527 if (!font || !count)
1529 else
1530 {
1531 struct add_font_param param;
1532 HDC hdc;
1533 LOGFONTW lfw;
1534
1536
1537 /* Truncate name if necessary, GDI32 can't deal with long names */
1538 if(lstrlenW(name) > LF_FACESIZE - 1)
1539 name[LF_FACESIZE - 1] = 0;
1540
1542 lstrcpyW(lfw.lfFaceName, name);
1543 lfw.lfPitchAndFamily = 0;
1544
1545 param.collection = fontCollection;
1546 param.is_system = FALSE;
1548 ret = param.stat;
1549
1550 DeleteDC(hdc);
1551 }
1552 heap_free(name);
1553 return ret;
1554}
#define lstrlenW
Definition: compat.h:750
#define NAME_ID_FULL_FONT_NAME
Definition: font.c:1185
static WCHAR * load_ttf_name_id(const BYTE *mem, DWORD_PTR size, DWORD id)
Definition: font.c:1426
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
static char memory[1024 *256]
Definition: process.c:116
HANDLE WINAPI AddFontMemResourceEx(_In_reads_bytes_(cjSize) PVOID pvFileView, _In_ DWORD cjSize, _Reserved_ PVOID pvResrved, _In_ DWORD *pNumFonts)

Referenced by GdipPrivateAddFontFile().

◆ get_font_metrics()

static BOOL get_font_metrics ( HDC  hdc,
struct font_metrics fm 
)
static

Definition at line 654 of file font.c.

655{
657 TT_OS2_V2 tt_os2;
658 TT_HHEA tt_hori;
659 LONG size;
660 UINT16 line_gap;
661
662 otm.otmSize = sizeof(otm);
663 if (!GetOutlineTextMetricsW(hdc, otm.otmSize, &otm)) return FALSE;
664
665 fm->em_height = otm.otmEMSquare;
667
668 memset(&tt_hori, 0, sizeof(tt_hori));
669 if (GetFontData(hdc, MS_HHEA_TAG, 0, &tt_hori, sizeof(tt_hori)) != GDI_ERROR)
670 {
671 fm->ascent = GET_BE_WORD(tt_hori.Ascender);
672 fm->descent = -GET_BE_WORD(tt_hori.Descender);
673 TRACE("hhea: ascent %d, descent %d\n", fm->ascent, fm->descent);
674 line_gap = GET_BE_WORD(tt_hori.LineGap);
675 fm->line_spacing = fm->ascent + fm->descent + line_gap;
676 TRACE("line_gap %u, line_spacing %u\n", line_gap, fm->line_spacing);
677 if (fm->ascent + fm->descent != 0) return TRUE;
678 }
679
681 if (size == GDI_ERROR) return FALSE;
682
683 if (size > sizeof(tt_os2)) size = sizeof(tt_os2);
684
685 memset(&tt_os2, 0, sizeof(tt_os2));
686 if (GetFontData(hdc, MS_OS2_TAG, 0, &tt_os2, size) != size) return FALSE;
687
688 fm->ascent = GET_BE_WORD(tt_os2.usWinAscent);
689 fm->descent = GET_BE_WORD(tt_os2.usWinDescent);
690 TRACE("usWinAscent %u, usWinDescent %u\n", fm->ascent, fm->descent);
691 if (fm->ascent + fm->descent == 0)
692 {
693 fm->ascent = GET_BE_WORD(tt_os2.sTypoAscender);
694 fm->descent = GET_BE_WORD(tt_os2.sTypoDescender);
695 TRACE("sTypoAscender %u, sTypoDescender %u\n", fm->ascent, fm->descent);
696 }
697 line_gap = GET_BE_WORD(tt_os2.sTypoLineGap);
698 fm->line_spacing = fm->ascent + fm->descent + line_gap;
699 TRACE("line_gap %u, line_spacing %u\n", line_gap, fm->line_spacing);
700 return TRUE;
701}
#define MS_HHEA_TAG
Definition: font.c:117
#define MS_OS2_TAG
Definition: font.c:116
long LONG
Definition: pedump.c:60
Definition: font.c:87
SHORT LineGap
Definition: font.c:91
SHORT Descender
Definition: font.c:90
SHORT Ascender
Definition: font.c:89
Definition: font.c:40
USHORT usWinAscent
Definition: font.c:73
USHORT sTypoDescender
Definition: font.c:71
USHORT usWinDescent
Definition: font.c:74
USHORT sTypoLineGap
Definition: font.c:72
USHORT sTypoAscender
Definition: font.c:70
int dpi
Definition: font.c:651
UINT16 em_height
Definition: font.c:650
UINT16 ascent
Definition: font.c:650
UINT16 line_spacing
Definition: font.c:650
UINT16 descent
Definition: font.c:650
DWORD WINAPI GetFontData(HDC hdc, DWORD dwTable, DWORD dwOffset, LPVOID lpvBuffer, DWORD cbData)
Definition: font.c:2654
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
#define GDI_ERROR
Definition: wingdi.h:1309

Referenced by find_installed_font().

◆ get_font_size()

static REAL get_font_size ( const GpFont font)
static

Definition at line 329 of file font.c.

330{
331 return font->emSize;
332}

Referenced by GdipGetFontHeightGivenDPI(), and GdipGetFontSize().

◆ get_font_style()

static INT get_font_style ( const GpFont font)
static

Definition at line 362 of file font.c.

363{
364 INT style;
365
366 if (font->otm.otmTextMetrics.tmWeight > FW_REGULAR)
368 else
370 if (font->otm.otmTextMetrics.tmItalic)
372 if (font->otm.otmTextMetrics.tmUnderlined)
374 if (font->otm.otmTextMetrics.tmStruckOut)
376
377 return style;
378}

Referenced by GdipGetFontHeightGivenDPI(), and GdipGetFontStyle().

◆ get_mac_code_page()

static WORD get_mac_code_page ( const tt_name_record name)
inlinestatic

Definition at line 1344 of file font.c.

1345{
1346 WORD encoding_id = GET_BE_WORD(name->encoding_id);
1347 if (encoding_id == TT_MAC_ID_SIMPLIFIED_CHINESE) return 10008; /* special case */
1348 return 10000 + encoding_id;
1349}
#define TT_MAC_ID_SIMPLIFIED_CHINESE
Definition: font.c:1183

Referenced by copy_name_table_string(), and match_name_table_language().

◆ is_font_installed_proc()

static INT CALLBACK is_font_installed_proc ( const LOGFONTW elf,
const TEXTMETRICW ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 632 of file font.c.

634{
635 const ENUMLOGFONTW *elfW = (const ENUMLOGFONTW *)elf;
636 LOGFONTW *lf = (LOGFONTW *)lParam;
637
638 if (type & RASTER_FONTTYPE)
639 return 1;
640
641 *lf = *elf;
642 /* replace substituted font name by a real one */
644 return 0;
645}
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2692

Referenced by find_installed_font(), and is_font_installed().

◆ load_ttf_name_id()

static WCHAR * load_ttf_name_id ( const BYTE mem,
DWORD_PTR  size,
DWORD  id 
)
static

Definition at line 1426 of file font.c.

1427{
1429 const tt_header *header;
1430 const tt_name_table *name_table;
1432 DWORD pos, ofs, count;
1433 int i, res, best_lang = 0, best_index = -1;
1434
1435 if (sizeof(tt_header) > size)
1436 return NULL;
1437 header = (const tt_header*)mem;
1438 count = GET_BE_WORD(header->tables_no);
1439
1440 if (GET_BE_WORD(header->major_version) != 1 || GET_BE_WORD(header->minor_version) != 0)
1441 return NULL;
1442
1443 pos = sizeof(*header);
1444 for (i = 0; i < count; i++)
1445 {
1447 pos += sizeof(*table_directory);
1448 if (memcmp(table_directory->tag, "name", 4) == 0)
1449 {
1450 ofs = GET_BE_DWORD(table_directory->offset);
1451 break;
1452 }
1453 }
1454 if (i >= count)
1455 return NULL;
1456
1457 if (ofs >= size)
1458 return NULL;
1459 pos = ofs + sizeof(*name_table);
1460 if (pos > size)
1461 return NULL;
1462 name_table = (const tt_name_table*)&mem[ofs];
1463 count = GET_BE_WORD(name_table->count);
1464 if (GET_BE_WORD(name_table->string_offset) >= size - ofs) return NULL;
1465 ofs += GET_BE_WORD(name_table->string_offset);
1466 for (i=0; i<count; i++)
1467 {
1468 name_record = (const tt_name_record*)&mem[pos];
1469 pos += sizeof(*name_record);
1470 if (pos > size)
1471 return NULL;
1472
1473 if (GET_BE_WORD(name_record->name_id) != id) continue;
1474 if (GET_BE_WORD(name_record->offset) >= size - ofs) return NULL;
1475 if (GET_BE_WORD(name_record->length) > size - ofs - GET_BE_WORD(name_record->offset)) return NULL;
1476
1478 if (res > best_lang)
1479 {
1480 best_lang = res;
1481 best_index = i;
1482 }
1483 }
1484
1485 if (best_lang)
1486 {
1487 WCHAR *ret;
1488 name_record = (const tt_name_record*)(name_table + 1) + best_index;
1490 TRACE( "name %u found platform %u lang %04x %s\n", GET_BE_WORD(name_record->name_id),
1491 GET_BE_WORD(name_record->platform_id), GET_BE_WORD(name_record->language_id), debugstr_w( ret ));
1492 return ret;
1493 }
1494 return NULL;
1495}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static WCHAR * copy_name_table_string(const tt_name_record *name, const BYTE *data)
Definition: font.c:1397
static int match_name_table_language(const tt_name_record *name, LANGID lang)
Definition: font.c:1351
#define GET_BE_DWORD(x)
Definition: font.c:110
LANGID WINAPI GetSystemDefaultLangID(void)
Definition: locale.c:1193
GLuint res
Definition: glext.h:9613
GLuint id
Definition: glext.h:5910
USHORT LANGID
Definition: mui.h:9
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by font_name_from_file(), GdipPrivateAddMemoryFont(), and msi_get_font_file_version().

◆ match_name_table_language()

static int match_name_table_language ( const tt_name_record name,
LANGID  lang 
)
static

Definition at line 1351 of file font.c.

1352{
1353 LANGID name_lang;
1354
1355 switch (GET_BE_WORD(name->platform_id))
1356 {
1358 switch (GET_BE_WORD(name->encoding_id))
1359 {
1361 case TT_MS_ID_SYMBOL_CS:
1362 name_lang = GET_BE_WORD(name->language_id);
1363 break;
1364 default:
1365 return 0;
1366 }
1367 break;
1369 if (!IsValidCodePage( get_mac_code_page( name ))) return 0;
1370 name_lang = GET_BE_WORD(name->language_id);
1371 if (name_lang >= ARRAY_SIZE(mac_langid_table)) return 0;
1372 name_lang = mac_langid_table[name_lang];
1373 break;
1375 switch (GET_BE_WORD(name->encoding_id))
1376 {
1380 name_lang = GET_BE_WORD(name->language_id);
1381 if (name_lang >= ARRAY_SIZE(mac_langid_table)) return 0;
1382 name_lang = mac_langid_table[name_lang];
1383 break;
1384 default:
1385 return 0;
1386 }
1387 break;
1388 default:
1389 return 0;
1390 }
1391 if (name_lang == lang) return 3;
1392 if (PRIMARYLANGID( name_lang ) == PRIMARYLANGID( lang )) return 2;
1393 if (name_lang == MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT )) return 1;
1394 return 0;
1395}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define TT_APPLE_ID_ISO_10646
Definition: font.c:1177
#define TT_MS_ID_UNICODE_CS
Definition: font.c:1181
#define TT_APPLE_ID_DEFAULT
Definition: font.c:1176
#define TT_APPLE_ID_UNICODE_2_0
Definition: font.c:1178
#define TT_MS_ID_SYMBOL_CS
Definition: font.c:1180
static const LANGID mac_langid_table[]
Definition: font.c:1220
BOOL WINAPI IsValidCodePage(UINT codepage)
Definition: locale.c:2078
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by get_ttf_nametable_entry(), and load_ttf_name_id().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( gdiplus  )

Variable Documentation

◆ installedFontCollection

GpFontCollection installedFontCollection = {0}
static

Definition at line 121 of file font.c.

Referenced by free_installed_fonts(), and GdipNewInstalledFontCollection().

◆ mac_langid_table

const LANGID mac_langid_table[]
static

Definition at line 1220 of file font.c.

Referenced by match_name_table_language().