ReactOS 0.4.15-dev-7705-g2320c37
font.c File Reference
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/heap.h"
#include "wine/test.h"
#include "pshpack2.h"
#include "poppack.h"
Include dependency graph for font.c:

Go to the source code of this file.

Classes

struct  font_data
 
struct  enum_font_data
 
struct  enum_fullname_data
 
struct  enum_font_dataW
 
struct  TT_OS2_V4
 
struct  cmap_header
 
struct  cmap_encoding_record
 
struct  cmap_format_0
 
struct  cmap_format_4
 
struct  cmap_format_4_seg
 
struct  sfnt_name
 

Macros

#define match_off_by_1(a, b, exact)   match_off_by_n((a), (b), (exact) ? 0 : 1)
 
#define near_match(a, b)   match_off_by_n((a), (b), 6)
 
#define expect(expected, got)   ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 
#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_CMAP_TAG   MS_MAKE_TAG('c','m','a','p')
 
#define MS_NAME_TAG   MS_MAKE_TAG('n','a','m','e')
 
#define FH_SCALE   0x80000000
 
#define TT_OS2_V0_SIZE   (FIELD_OFFSET(TT_OS2_V4, ulCodePageRange1))
 
#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_MS_LANGID_ENGLISH_UNITED_STATES   0x0409
 
#define TT_NAME_ID_FONT_FAMILY   1
 
#define TT_NAME_ID_FONT_SUBFAMILY   2
 
#define TT_NAME_ID_UNIQUE_ID   3
 
#define TT_NAME_ID_FULL_NAME   4
 
#define TT_MAC_ID_SIMPLIFIED_CHINESE   25
 

Typedefs

typedef struct sfnt_name sfnt_name
 

Enumerations

enum  cmap_type { cmap_none , cmap_ms_unicode , cmap_ms_symbol }
 

Functions

static BOOL match_off_by_n (int a, int b, unsigned int n)
 
static LONG (WINAPI *pGdiGetCharDimensions)(HDC hdc
 
static DWORD (WINAPI *pGdiGetCodePage)(HDC hdc)
 
static BOOL (WINAPI *pGetCharABCWidthsI)(HDC hdc
 
static DWORD *static HFONT (WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
 
static HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID
 
static INT (WINAPI *pAddFontResourceExA)(LPCSTR
 
static void init (void)
 
static INT CALLBACK is_truetype_font_installed_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static BOOL is_truetype_font_installed (const char *name)
 
static INT CALLBACK is_font_installed_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static BOOL is_font_installed (const char *name)
 
static voidget_res_data (const char *fontname, DWORD *rsrc_size)
 
static BOOL write_tmp_file (const void *data, DWORD *size, char *tmp_name)
 
static BOOL write_ttf_file (const char *fontname, char *tmp_name)
 
static void check_font (const char *test, const LOGFONTA *lf, HFONT hfont)
 
static HFONT create_font (const char *test, const LOGFONTA *lf)
 
static void test_logfont (void)
 
static INT CALLBACK font_enum_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static void compare_tm (const TEXTMETRICA *tm, const TEXTMETRICA *otm)
 
static void test_font_metrics (HDC hdc, HFONT hfont, LONG lfHeight, LONG lfWidth, const char *test_str, INT test_str_len, const TEXTMETRICA *tm_orig, const SIZE *size_orig, INT width_of_A_orig, INT scale_x, INT scale_y)
 
static void test_bitmap_font (void)
 
static void test_outline_font (void)
 
static INT CALLBACK find_font_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static BOOL is_CJK (void)
 
static void test_bitmap_font_metrics (void)
 
static void test_GdiGetCharDimensions (void)
 
static int CALLBACK create_font_proc (const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam)
 
static void ABCWidths_helper (const char *description, HDC hdc, WORD *glyphs, const ABC *base_abci, const ABC *base_abcw, const ABCFLOAT *base_abcf)
 
static void test_GetCharABCWidths (void)
 
static void test_text_extents (void)
 
static void test_GetGlyphIndices (void)
 
static void test_GetKerningPairs (void)
 
static void test_height (HDC hdc, const struct font_data *fd)
 
static voidfind_ttf_table (void *ttf, DWORD size, DWORD tag)
 
static void test_height_selection_vdmx (HDC hdc)
 
static void test_height_selection (void)
 
static UINT get_font_fsselection (LOGFONTA *lf)
 
static void test_GetOutlineTextMetrics (void)
 
static void testJustification (HDC hdc, PCSTR str, RECT *clientArea)
 
static void test_SetTextJustification (void)
 
static BOOL get_glyph_indices (INT charset, UINT code_page, WORD *idx, UINT count, BOOL unicode)
 
static void test_font_charset (void)
 
static void test_GdiGetCodePage (void)
 
static void test_GetFontUnicodeRanges (void)
 
static INT CALLBACK arial_enum_proc (const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lParam)
 
static INT CALLBACK arial_enum_procw (const LOGFONTW *lf, const TEXTMETRICW *tm, DWORD type, LPARAM lParam)
 
static void get_charset_stats (struct enum_font_data *efd, int *ansi_charset, int *symbol_charset, int *russian_charset)
 
static void get_charset_statsW (struct enum_font_dataW *efd, int *ansi_charset, int *symbol_charset, int *russian_charset)
 
static void test_EnumFontFamilies (const char *font_name, INT font_charset)
 
static INT CALLBACK enum_multi_charset_font_proc (const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lParam)
 
static INT CALLBACK enum_font_data_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static INT CALLBACK enum_fullname_data_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static void test_EnumFontFamiliesEx_default_charset (void)
 
static void test_negative_width (HDC hdc, const LOGFONTA *lf)
 
static void expect_ff (const TEXTMETRICA *tmA, const TT_OS2_V4 *os2, WORD family, const char *name)
 
static BOOL get_first_last_from_cmap0 (void *ptr, DWORD *first, DWORD *last)
 
static void get_seg4 (cmap_format_4 *cmap, USHORT seg_num, cmap_format_4_seg *seg)
 
static BOOL get_first_last_from_cmap4 (void *ptr, DWORD *first, DWORD *last, DWORD limit)
 
static voidget_cmap (cmap_header *header, USHORT plat_id, USHORT enc_id)
 
static BOOL get_first_last_from_cmap (HDC hdc, DWORD *first, DWORD *last, cmap_type *cmap_type)
 
static WORD get_mac_code_page (const sfnt_name *name)
 
static int match_name_table_language (const sfnt_name *name, LANGID lang)
 
static BOOL get_ttf_nametable_entry (HDC hdc, WORD name_id, WCHAR *out_buf, SIZE_T out_size, LCID language_id)
 
static void test_text_metrics (const LOGFONTA *lf, const NEWTEXTMETRICA *ntm)
 
static INT CALLBACK enum_truetype_font_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static void test_GetTextMetrics (void)
 
static void test_nonexistent_font (void)
 
static void test_RealizationInfo (void)
 
static void test_GetTextFace (void)
 
static void test_orientation (void)
 
static void test_oemcharset (void)
 
static int CALLBACK create_fixed_pitch_font_proc (const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam)
 
static void test_GetGlyphOutline (void)
 
static void test_GetTextMetrics2 (const char *fontname, int font_height)
 
static void test_GetCharacterPlacement (void)
 
static void test_CreateFontIndirect (void)
 
static void test_CreateFontIndirectEx (void)
 
static void free_font (void *font)
 
static voidload_font (const char *font_name, DWORD *font_size)
 
static void test_AddFontMemResource (void)
 
static INT CALLBACK enum_fonts_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam)
 
static INT CALLBACK enum_all_fonts_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam)
 
static INT CALLBACK enum_with_magic_retval_proc (const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam)
 
static void test_EnumFonts (void)
 
static INT CALLBACK enum_ms_shell_dlg_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static INT CALLBACK enum_ms_shell_dlg2_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static void test_EnumFonts_subst (void)
 
static INT CALLBACK is_font_installed_fullname_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static BOOL is_font_installed_fullname (const char *family, const char *fullname)
 
static void test_fullname (void)
 
static WCHARprepend_at (WCHAR *family)
 
static void test_fullname2_helper (const char *Family)
 
static void test_fullname2 (void)
 
static void test_GetGlyphOutline_empty_contour (void)
 
static void test_GetGlyphOutline_metric_clipping (void)
 
static void test_fstype_fixup (void)
 
static void test_CreateScalableFontResource (void)
 
static void check_vertical_font (const char *name, BOOL *installed, BOOL *selected, GLYPHMETRICS *gm, WORD *gi)
 
static void check_vertical_metrics (const char *face)
 
static void test_vertical_font (void)
 
static INT CALLBACK has_vertical_font_proc (const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
 
static void test_east_asian_font_selection (void)
 
static int get_font_dpi (const LOGFONTA *lf, int *height)
 
static void test_stock_fonts (void)
 
static void test_max_height (void)
 
static void test_vertical_order (void)
 
static void test_GetCharWidth32 (void)
 
static void test_fake_bold_font (void)
 
static void test_bitmap_font_glyph_index (void)
 
static void test_GetCharWidthI (void)
 
static INT CALLBACK long_enum_proc (const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lparam)
 
static void test_long_names (void)
 
 START_TEST (font)
 

Variables

static LPTEXTMETRICW lptm
 
static LPTEXTMETRICW LONGheight
 
static UINT first
 
static UINT UINT count
 
static UINT UINT LPWORD glyphs
 
static UINT UINT LPWORD LPABC abc
 
static UINT UINT last
 
static UINT UINT LPINT buffer
 
static LPGLYPHSET lpgs
 
static LPCSTR lpstr
 
static LPCSTR INT LPWORD pgi
 
static LPCSTR INT LPWORD DWORD flags
 
static const WORDindices
 
static const WORD INT INT max_ext
 
static const WORD INT INT LPINT nfit
 
static const WORD INT INT LPINT LPINT dxs
 
static const WORD INT INT LPINT LPINT LPSIZE size
 
static DWORD
 
static PVOID
 
static DWORD *static void DWORD *static ULONGLONG
 
static HMODULE hgdi32 = 0
 
static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} }
 
static WORD system_lang_id
 
static const LANGID mac_langid_table []
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)

Definition at line 40 of file font.c.

◆ FH_SCALE

#define FH_SCALE   0x80000000

Definition at line 756 of file font.c.

◆ GET_BE_DWORD

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

Definition at line 74 of file font.c.

◆ GET_BE_WORD

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

Definition at line 73 of file font.c.

◆ match_off_by_1

#define match_off_by_1 (   a,
  b,
  exact 
)    match_off_by_n((a), (b), (exact) ? 0 : 1)

Definition at line 38 of file font.c.

◆ MS_CMAP_TAG

#define MS_CMAP_TAG   MS_MAKE_TAG('c','m','a','p')

Definition at line 81 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 77 of file font.c.

◆ MS_NAME_TAG

#define MS_NAME_TAG   MS_MAKE_TAG('n','a','m','e')

Definition at line 82 of file font.c.

◆ MS_OS2_TAG

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

Definition at line 80 of file font.c.

◆ near_match

#define near_match (   a,
  b 
)    match_off_by_n((a), (b), 6)

Definition at line 39 of file font.c.

◆ TT_APPLE_ID_DEFAULT

#define TT_APPLE_ID_DEFAULT   0

Definition at line 3530 of file font.c.

◆ TT_APPLE_ID_ISO_10646

#define TT_APPLE_ID_ISO_10646   2

Definition at line 3531 of file font.c.

◆ TT_APPLE_ID_UNICODE_2_0

#define TT_APPLE_ID_UNICODE_2_0   3

Definition at line 3532 of file font.c.

◆ TT_MAC_ID_SIMPLIFIED_CHINESE

#define TT_MAC_ID_SIMPLIFIED_CHINESE   25

Definition at line 3540 of file font.c.

◆ TT_MS_ID_SYMBOL_CS

#define TT_MS_ID_SYMBOL_CS   0

Definition at line 3533 of file font.c.

◆ TT_MS_ID_UNICODE_CS

#define TT_MS_ID_UNICODE_CS   1

Definition at line 3534 of file font.c.

◆ TT_MS_LANGID_ENGLISH_UNITED_STATES

#define TT_MS_LANGID_ENGLISH_UNITED_STATES   0x0409

Definition at line 3535 of file font.c.

◆ TT_NAME_ID_FONT_FAMILY

#define TT_NAME_ID_FONT_FAMILY   1

Definition at line 3536 of file font.c.

◆ TT_NAME_ID_FONT_SUBFAMILY

#define TT_NAME_ID_FONT_SUBFAMILY   2

Definition at line 3537 of file font.c.

◆ TT_NAME_ID_FULL_NAME

#define TT_NAME_ID_FULL_NAME   4

Definition at line 3539 of file font.c.

◆ TT_NAME_ID_UNIQUE_ID

#define TT_NAME_ID_UNIQUE_ID   3

Definition at line 3538 of file font.c.

◆ TT_OS2_V0_SIZE

#define TT_OS2_V0_SIZE   (FIELD_OFFSET(TT_OS2_V4, ulCodePageRange1))

Definition at line 3343 of file font.c.

◆ TT_PLATFORM_APPLE_UNICODE

#define TT_PLATFORM_APPLE_UNICODE   0

Definition at line 3527 of file font.c.

◆ TT_PLATFORM_MACINTOSH

#define TT_PLATFORM_MACINTOSH   1

Definition at line 3528 of file font.c.

◆ TT_PLATFORM_MICROSOFT

#define TT_PLATFORM_MICROSOFT   3

Definition at line 3529 of file font.c.

Typedef Documentation

◆ sfnt_name

Enumeration Type Documentation

◆ cmap_type

Enumerator
cmap_none 
cmap_ms_unicode 
cmap_ms_symbol 

Definition at line 3470 of file font.c.

3471{
3472 cmap_none,
3475} cmap_type;
cmap_type
Definition: font.c:3471
@ cmap_ms_unicode
Definition: font.c:3473
@ cmap_none
Definition: font.c:3472
@ cmap_ms_symbol
Definition: font.c:3474

Function Documentation

◆ ABCWidths_helper()

static void ABCWidths_helper ( const char description,
HDC  hdc,
WORD glyphs,
const ABC base_abci,
const ABC base_abcw,
const ABCFLOAT base_abcf 
)
static

Definition at line 1131 of file font.c.

1132{
1133 ABC abc[1];
1134 ABCFLOAT abcf[1];
1135 BOOL ret = FALSE;
1136
1137 ret = pGetCharABCWidthsI(hdc, 0, 1, glyphs, abc);
1138 ok(ret, "%s: GetCharABCWidthsI should have succeeded\n", description);
1139 ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
1140 ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
1141 ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
1142
1143 ret = pGetCharABCWidthsW(hdc, 'i', 'i', abc);
1144 ok(ret, "%s: GetCharABCWidthsW should have succeeded\n", description);
1145 ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
1146 ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
1147 ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
1148
1149 ret = pGetCharABCWidthsFloatW(hdc, 'i', 'i', abcf);
1150 ok(ret, "%s: GetCharABCWidthsFloatW should have succeeded\n", description);
1151 ok (abcf->abcfB > 0.0, "%s: abcfB should be positive\n", description);
1152 ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's sign should be unchanged\n", description);
1153 ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
1154}
#define ok(value,...)
Definition: atltest.h:57
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HDC hdc
Definition: main.c:9
static UINT UINT LPWORD LPABC abc
Definition: font.c:44
static UINT UINT LPWORD glyphs
Definition: font.c:44
FLOAT abcfA
Definition: wingdi.h:1416
FLOAT abcfC
Definition: wingdi.h:1418
FLOAT abcfB
Definition: wingdi.h:1417
Definition: wingdi.h:1410
int abcA
Definition: wingdi.h:1411
UINT abcB
Definition: wingdi.h:1412
int abcC
Definition: wingdi.h:1413
int32_t INT
Definition: typedefs.h:58
int ret
const char * description
Definition: directx.c:2497

Referenced by test_GetCharABCWidths().

◆ arial_enum_proc()

static INT CALLBACK arial_enum_proc ( const LOGFONTA lf,
const TEXTMETRICA tm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 2804 of file font.c.

2805{
2806 struct enum_font_data *efd = (struct enum_font_data *)lParam;
2807 const NEWTEXTMETRICA *ntm = (const NEWTEXTMETRICA *)tm;
2808
2809 ok(lf->lfHeight == tm->tmHeight, "lfHeight %d != tmHeight %d\n", lf->lfHeight, tm->tmHeight);
2810 ok(lf->lfHeight > 0 && lf->lfHeight < 200, "enumerated font height %d\n", lf->lfHeight);
2811
2812 if (type != TRUETYPE_FONTTYPE) return 1;
2813
2814 ok(ntm->ntmCellHeight + ntm->ntmCellHeight/5 >= ntm->ntmSizeEM, "ntmCellHeight %d should be close to ntmSizeEM %d\n", ntm->ntmCellHeight, ntm->ntmSizeEM);
2815
2816 if (0) /* Disabled to limit console spam */
2817 trace("enumed font \"%s\", charset %d, height %d, weight %d, italic %d\n",
2819 if (efd->total >= efd->size)
2820 {
2821 efd->size = max( (efd->total + 1) * 2, 256 );
2822 efd->lf = heap_realloc( efd->lf, efd->size * sizeof(*efd->lf) );
2823 if (!efd->lf) return 0;
2824 }
2825 efd->lf[efd->total++] = *lf;
2826
2827 return 1;
2828}
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define trace
Definition: atltest.h:70
LPARAM lParam
Definition: combotst.c:139
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BYTE lfItalic
Definition: dimm.idl:47
LONG lfHeight
Definition: dimm.idl:42
BYTE lfCharSet
Definition: dimm.idl:50
LONG lfWeight
Definition: dimm.idl:46
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
LOGFONTA * lf
Definition: font.c:2789
UINT ntmCellHeight
Definition: wingdi.h:2640
Definition: time.h:68
#define max(a, b)
Definition: svc.c:63
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109

Referenced by test_EnumFontFamilies().

◆ arial_enum_procw()

static INT CALLBACK arial_enum_procw ( const LOGFONTW lf,
const TEXTMETRICW tm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 2830 of file font.c.

2831{
2832 struct enum_font_dataW *efd = (struct enum_font_dataW *)lParam;
2833 const NEWTEXTMETRICW *ntm = (const NEWTEXTMETRICW *)tm;
2834
2835 ok(lf->lfHeight == tm->tmHeight, "lfHeight %d != tmHeight %d\n", lf->lfHeight, tm->tmHeight);
2836 ok(lf->lfHeight > 0 && lf->lfHeight < 200, "enumerated font height %d\n", lf->lfHeight);
2837
2838 if (type != TRUETYPE_FONTTYPE) return 1;
2839
2840 ok(ntm->ntmCellHeight + ntm->ntmCellHeight/5 >= ntm->ntmSizeEM, "ntmCellHeight %d should be close to ntmSizeEM %d\n", ntm->ntmCellHeight, ntm->ntmSizeEM);
2841
2842 if (0) /* Disabled to limit console spam */
2843 trace("enumed font %s, charset %d, height %d, weight %d, italic %d\n",
2845 if (efd->total >= efd->size)
2846 {
2847 efd->size = max( (efd->total + 1) * 2, 256 );
2848 efd->lf = heap_realloc( efd->lf, efd->size * sizeof(*efd->lf) );
2849 if (!efd->lf) return 0;
2850 }
2851 efd->lf[efd->total++] = *lf;
2852
2853 return 1;
2854}
#define wine_dbgstr_w
Definition: kernel32.h:34
BYTE lfItalic
Definition: dimm.idl:64
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfCharSet
Definition: dimm.idl:67
LOGFONTW * lf
Definition: font.c:2801
UINT ntmCellHeight
Definition: wingdi.h:2666

Referenced by test_EnumFontFamilies().

◆ BOOL()

static BOOL ( WINAPI pGetCharABCWidthsI)
static

◆ check_font()

static void check_font ( const char test,
const LOGFONTA lf,
HFONT  hfont 
)
static

Definition at line 195 of file font.c.

196{
197 LOGFONTA getobj_lf;
198 int ret, minlen = 0;
199
200 if (!hfont)
201 return;
202
203 ret = GetObjectA(hfont, sizeof(getobj_lf), &getobj_lf);
204 /* NT4 tries to be clever and only returns the minimum length */
205 while (lf->lfFaceName[minlen] && minlen < LF_FACESIZE-1)
206 minlen++;
207 minlen += FIELD_OFFSET(LOGFONTA, lfFaceName) + 1;
208 ok(ret == sizeof(LOGFONTA) || ret == minlen, "%s: GetObject returned %d\n", test, ret);
209 ok(lf->lfHeight == getobj_lf.lfHeight ||
210 broken((SHORT)lf->lfHeight == getobj_lf.lfHeight), /* win9x */
211 "lfHeight: expect %08x got %08x\n", lf->lfHeight, getobj_lf.lfHeight);
212 ok(lf->lfWidth == getobj_lf.lfWidth ||
213 broken((SHORT)lf->lfWidth == getobj_lf.lfWidth), /* win9x */
214 "lfWidth: expect %08x got %08x\n", lf->lfWidth, getobj_lf.lfWidth);
215 ok(lf->lfEscapement == getobj_lf.lfEscapement ||
216 broken((SHORT)lf->lfEscapement == getobj_lf.lfEscapement), /* win9x */
217 "lfEscapement: expect %08x got %08x\n", lf->lfEscapement, getobj_lf.lfEscapement);
218 ok(lf->lfOrientation == getobj_lf.lfOrientation ||
219 broken((SHORT)lf->lfOrientation == getobj_lf.lfOrientation), /* win9x */
220 "lfOrientation: expect %08x got %08x\n", lf->lfOrientation, getobj_lf.lfOrientation);
221 ok(lf->lfWeight == getobj_lf.lfWeight ||
222 broken((SHORT)lf->lfWeight == getobj_lf.lfWeight), /* win9x */
223 "lfWeight: expect %08x got %08x\n", lf->lfWeight, getobj_lf.lfWeight);
224 ok(lf->lfItalic == getobj_lf.lfItalic, "lfItalic: expect %02x got %02x\n", lf->lfItalic, getobj_lf.lfItalic);
225 ok(lf->lfUnderline == getobj_lf.lfUnderline, "lfUnderline: expect %02x got %02x\n", lf->lfUnderline, getobj_lf.lfUnderline);
226 ok(lf->lfStrikeOut == getobj_lf.lfStrikeOut, "lfStrikeOut: expect %02x got %02x\n", lf->lfStrikeOut, getobj_lf.lfStrikeOut);
227 ok(lf->lfCharSet == getobj_lf.lfCharSet, "lfCharSet: expect %02x got %02x\n", lf->lfCharSet, getobj_lf.lfCharSet);
228 ok(lf->lfOutPrecision == getobj_lf.lfOutPrecision, "lfOutPrecision: expect %02x got %02x\n", lf->lfOutPrecision, getobj_lf.lfOutPrecision);
229 ok(lf->lfClipPrecision == getobj_lf.lfClipPrecision, "lfClipPrecision: expect %02x got %02x\n", lf->lfClipPrecision, getobj_lf.lfClipPrecision);
230 ok(lf->lfQuality == getobj_lf.lfQuality, "lfQuality: expect %02x got %02x\n", lf->lfQuality, getobj_lf.lfQuality);
231 ok(lf->lfPitchAndFamily == getobj_lf.lfPitchAndFamily, "lfPitchAndFamily: expect %02x got %02x\n", lf->lfPitchAndFamily, getobj_lf.lfPitchAndFamily);
232 ok(!lstrcmpA(lf->lfFaceName, getobj_lf.lfFaceName) ||
233 broken(!memcmp(lf->lfFaceName, getobj_lf.lfFaceName, LF_FACESIZE-1)), /* win9x doesn't ensure '\0' termination */
234 "%s: font names don't match: %s != %s\n", test, lf->lfFaceName, getobj_lf.lfFaceName);
235}
static HFONT hfont
#define broken(x)
Definition: _sntprintf.h:21
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define LF_FACESIZE
Definition: dimm.idl:39
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
short SHORT
Definition: pedump.c:59
#define test
Definition: rosglue.h:37
BYTE lfStrikeOut
Definition: dimm.idl:49
BYTE lfClipPrecision
Definition: dimm.idl:52
BYTE lfUnderline
Definition: dimm.idl:48
BYTE lfQuality
Definition: dimm.idl:53
BYTE lfOutPrecision
Definition: dimm.idl:51
LONG lfOrientation
Definition: dimm.idl:45
BYTE lfPitchAndFamily
Definition: dimm.idl:54
LONG lfEscapement
Definition: dimm.idl:44
LONG lfWidth
Definition: dimm.idl:43
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)

Referenced by create_font(), test_CreateFontIndirectEx(), test_logfont(), and test_negative_width().

◆ check_vertical_font()

static void check_vertical_font ( const char name,
BOOL installed,
BOOL selected,
GLYPHMETRICS gm,
WORD gi 
)
static

Definition at line 5902 of file font.c.

5903{
5904 LOGFONTA lf;
5905 HFONT hfont, hfont_prev;
5906 HDC hdc;
5907 char facename[100];
5908 DWORD ret;
5909 static const WCHAR str[] = { 0x2025 };
5910
5911 *installed = is_truetype_font_installed(name);
5912
5913 lf.lfHeight = -18;
5914 lf.lfWidth = 0;
5915 lf.lfEscapement = 0;
5916 lf.lfOrientation = 0;
5917 lf.lfWeight = FW_DONTCARE;
5918 lf.lfItalic = 0;
5919 lf.lfUnderline = 0;
5920 lf.lfStrikeOut = 0;
5926 strcpy(lf.lfFaceName, name);
5927
5929 ok(hfont != NULL, "CreateFontIndirectA failed\n");
5930
5931 hdc = GetDC(NULL);
5932
5933 hfont_prev = SelectObject(hdc, hfont);
5934 ok(hfont_prev != NULL, "SelectObject failed\n");
5935
5936 ret = GetTextFaceA(hdc, sizeof facename, facename);
5937 ok(ret, "GetTextFaceA failed\n");
5938 *selected = !strcmp(facename, name);
5939
5940 ret = GetGlyphOutlineW(hdc, 0x2025, GGO_METRICS, gm, 0, NULL, &mat);
5941 ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
5942 if (!*selected)
5943 memset(gm, 0, sizeof *gm);
5944
5945 ret = pGetGlyphIndicesW(hdc, str, 1, gi, 0);
5946 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed\n");
5947
5948 SelectObject(hdc, hfont_prev);
5950 ReleaseDC(NULL, hdc);
5951}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define NULL
Definition: types.h:112
pKey DeleteObject()
static HDC
Definition: imagelist.c:92
static const MAT2 mat
Definition: font.c:66
static BOOL is_truetype_font_installed(const char *name)
Definition: font.c:120
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
Definition: name.c:39
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define FW_DONTCARE
Definition: wingdi.h:368
#define OUT_TT_ONLY_PRECIS
Definition: wingdi.h:422
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
int WINAPI GetTextFaceA(_In_ HDC hdc, _In_ int c, _Out_writes_to_opt_(c, return) LPSTR lpName)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define GDI_ERROR
Definition: wingdi.h:1309
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define GGO_METRICS
Definition: wingdi.h:848
DWORD WINAPI GetGlyphOutlineW(_In_ HDC hdc, _In_ UINT uChar, _In_ UINT fuFormat, _Out_ LPGLYPHMETRICS lpgm, _In_ DWORD cjBuffer, _Out_writes_bytes_opt_(cjBuffer) LPVOID pvBuffer, _In_ CONST MAT2 *lpmat2)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_vertical_font().

◆ check_vertical_metrics()

static void check_vertical_metrics ( const char face)
static

Definition at line 5953 of file font.c.

5954{
5955 LOGFONTA lf;
5956 HFONT hfont, hfont_prev;
5957 HDC hdc;
5958 DWORD ret;
5959 GLYPHMETRICS rgm, vgm;
5960 const UINT code = 0x5EAD, height = 1000;
5961 WORD idx;
5962 ABC abc, vabc;
5964 USHORT numOfLongVerMetrics;
5965
5966 hdc = GetDC(NULL);
5967
5968 memset(&lf, 0, sizeof(lf));
5969 strcpy(lf.lfFaceName, face);
5970 lf.lfHeight = -height;
5972 lf.lfEscapement = lf.lfOrientation = 900;
5974 hfont_prev = SelectObject(hdc, hfont);
5975 ret = GetGlyphOutlineW(hdc, code, GGO_METRICS, &rgm, 0, NULL, &mat);
5976 ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
5978 ok(ret, "GetCharABCWidthsW failed\n");
5979 DeleteObject(SelectObject(hdc, hfont_prev));
5980
5981 memset(&lf, 0, sizeof(lf));
5982 strcpy(lf.lfFaceName, "@");
5983 strcat(lf.lfFaceName, face);
5984 lf.lfHeight = -height;
5987 hfont_prev = SelectObject(hdc, hfont);
5988 ret = GetGlyphOutlineW(hdc, code, GGO_METRICS, &vgm, 0, NULL, &mat);
5989 ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
5990 ret = GetCharABCWidthsW(hdc, code, code, &vabc);
5991 ok(ret, "GetCharABCWidthsW failed\n");
5992 ok(vabc.abcA == vgm.gmptGlyphOrigin.x, "expected %d, got %d\n",
5993 vabc.abcA, vgm.gmptGlyphOrigin.x);
5994 ok(vabc.abcB == vgm.gmBlackBoxX, "expected %d, got %d\n",
5995 vabc.abcB, vgm.gmBlackBoxX);
5996 ok(vabc.abcA + vabc.abcB + vabc.abcC == vgm.gmCellIncX,
5997 "expected %d, got %d\n",
5998 vabc.abcA + vabc.abcB + vabc.abcC, vgm.gmCellIncX);
5999
6000 memset(&otm, 0, sizeof(otm));
6001 otm.otmSize = sizeof(otm);
6002 ret = GetOutlineTextMetricsA(hdc, sizeof(otm), &otm);
6003 ok(ret != 0, "GetOutlineTextMetricsA failed\n");
6004
6005 if (GetFontData(hdc, MS_MAKE_TAG('v','h','e','a'), sizeof(SHORT) * 17,
6006 &numOfLongVerMetrics, sizeof(numOfLongVerMetrics)) != GDI_ERROR) {
6007 int offset;
6008 SHORT topSideBearing;
6009
6010 if (!pGetGlyphIndicesW) {
6011 win_skip("GetGlyphIndices is not available on this platform\n");
6012 }
6013 else {
6014 ret = pGetGlyphIndicesW(hdc, (LPCWSTR)&code, 1, &idx, 0);
6015 ok(ret != 0, "GetGlyphIndicesW failed\n");
6016 numOfLongVerMetrics = GET_BE_WORD(numOfLongVerMetrics);
6017 if (numOfLongVerMetrics > idx)
6018 offset = idx * 2 + 1;
6019 else
6020 offset = numOfLongVerMetrics * 2 + (idx - numOfLongVerMetrics);
6021 ret = GetFontData(hdc, MS_MAKE_TAG('v','m','t','x'), offset * sizeof(SHORT),
6022 &topSideBearing, sizeof(SHORT));
6023 ok(ret != GDI_ERROR, "GetFontData(vmtx) failed\n");
6024 topSideBearing = GET_BE_WORD(topSideBearing);
6026 MulDiv(topSideBearing, height, otm.otmEMSquare), FALSE),
6027 "expected %d, got %d\n",
6028 MulDiv(topSideBearing, height, otm.otmEMSquare), vgm.gmptGlyphOrigin.x);
6029 }
6030 }
6031 else
6032 {
6033 ok(vgm.gmptGlyphOrigin.x == rgm.gmptGlyphOrigin.x + vgm.gmCellIncX + otm.otmDescent,
6034 "got %d, expected rgm.origin.x(%d) + vgm.cellIncX(%d) + descent(%d)\n",
6036 }
6037
6038 ok(vgm.gmptGlyphOrigin.y == abc.abcA + abc.abcB + otm.otmDescent ||
6039 broken(vgm.gmptGlyphOrigin.y == abc.abcA + abc.abcB - otm.otmTextMetrics.tmDescent) /* win2k */,
6040 "got %d, expected abcA(%d) + abcB(%u) + descent(%d)\n",
6042
6043 DeleteObject(SelectObject(hdc, hfont_prev));
6044 ReleaseDC(NULL, hdc);
6045}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
unsigned int idx
Definition: utils.c:41
#define GET_BE_WORD(x)
Definition: font.c:109
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLintptr offset
Definition: glext.h:5920
#define match_off_by_1(a, b, exact)
Definition: font.c:38
#define MS_MAKE_TAG(ch0, ch1, ch2, ch3)
Definition: font.c:77
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
unsigned int UINT
Definition: ndis.h:50
unsigned short USHORT
Definition: pedump.c:61
#define win_skip
Definition: test.h:160
short gmCellIncX
Definition: wingdi.h:2445
UINT gmBlackBoxX
Definition: wingdi.h:2442
POINT gmptGlyphOrigin
Definition: wingdi.h:2444
TEXTMETRICA otmTextMetrics
Definition: wingdi.h:2480
Definition: inflate.c:139
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG tmDescent
Definition: wingdi.h:2363
DWORD WINAPI GetFontData(HDC hdc, DWORD dwTable, DWORD dwOffset, LPVOID lpvBuffer, DWORD cbData)
Definition: font.c:2654
UINT WINAPI GetOutlineTextMetricsA(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICA potm)
BOOL WINAPI GetCharABCWidthsW(_In_ HDC hdc, _In_ UINT wFirst, _In_ UINT wLast, _Out_writes_(wLast - wFirst+1) LPABC lpABC)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by test_vertical_font().

◆ compare_tm()

static void compare_tm ( const TEXTMETRICA tm,
const TEXTMETRICA otm 
)
static

Definition at line 285 of file font.c.

286{
287 ok(tm->tmHeight == otm->tmHeight, "tmHeight %d != %d\n", tm->tmHeight, otm->tmHeight);
288 ok(tm->tmAscent == otm->tmAscent, "tmAscent %d != %d\n", tm->tmAscent, otm->tmAscent);
289 ok(tm->tmDescent == otm->tmDescent, "tmDescent %d != %d\n", tm->tmDescent, otm->tmDescent);
290 ok(tm->tmInternalLeading == otm->tmInternalLeading, "tmInternalLeading %d != %d\n", tm->tmInternalLeading, otm->tmInternalLeading);
291 ok(tm->tmExternalLeading == otm->tmExternalLeading, "tmExternalLeading %d != %d\n", tm->tmExternalLeading, otm->tmExternalLeading);
292 ok(tm->tmAveCharWidth == otm->tmAveCharWidth, "tmAveCharWidth %d != %d\n", tm->tmAveCharWidth, otm->tmAveCharWidth);
293 ok(tm->tmMaxCharWidth == otm->tmMaxCharWidth, "tmMaxCharWidth %d != %d\n", tm->tmMaxCharWidth, otm->tmMaxCharWidth);
294 ok(tm->tmWeight == otm->tmWeight, "tmWeight %d != %d\n", tm->tmWeight, otm->tmWeight);
295 ok(tm->tmOverhang == otm->tmOverhang, "tmOverhang %d != %d\n", tm->tmOverhang, otm->tmOverhang);
296 ok(tm->tmDigitizedAspectX == otm->tmDigitizedAspectX, "tmDigitizedAspectX %d != %d\n", tm->tmDigitizedAspectX, otm->tmDigitizedAspectX);
297 ok(tm->tmDigitizedAspectY == otm->tmDigitizedAspectY, "tmDigitizedAspectY %d != %d\n", tm->tmDigitizedAspectY, otm->tmDigitizedAspectY);
298 ok(tm->tmFirstChar == otm->tmFirstChar, "tmFirstChar %d != %d\n", tm->tmFirstChar, otm->tmFirstChar);
299 ok(tm->tmLastChar == otm->tmLastChar, "tmLastChar %d != %d\n", tm->tmLastChar, otm->tmLastChar);
300 ok(tm->tmDefaultChar == otm->tmDefaultChar, "tmDefaultChar %d != %d\n", tm->tmDefaultChar, otm->tmDefaultChar);
301 ok(tm->tmBreakChar == otm->tmBreakChar, "tmBreakChar %d != %d\n", tm->tmBreakChar, otm->tmBreakChar);
302 ok(tm->tmItalic == otm->tmItalic, "tmItalic %d != %d\n", tm->tmItalic, otm->tmItalic);
303 ok(tm->tmUnderlined == otm->tmUnderlined, "tmUnderlined %d != %d\n", tm->tmUnderlined, otm->tmUnderlined);
304 ok(tm->tmStruckOut == otm->tmStruckOut, "tmStruckOut %d != %d\n", tm->tmStruckOut, otm->tmStruckOut);
305 ok(tm->tmPitchAndFamily == otm->tmPitchAndFamily, "tmPitchAndFamily %d != %d\n", tm->tmPitchAndFamily, otm->tmPitchAndFamily);
306 ok(tm->tmCharSet == otm->tmCharSet, "tmCharSet %d != %d\n", tm->tmCharSet, otm->tmCharSet);
307}
BYTE tmStruckOut
Definition: wingdi.h:2378
BYTE tmPitchAndFamily
Definition: wingdi.h:2379
BYTE tmCharSet
Definition: wingdi.h:2380
LONG tmDigitizedAspectX
Definition: wingdi.h:2370
BYTE tmFirstChar
Definition: wingdi.h:2372
LONG tmExternalLeading
Definition: wingdi.h:2365
LONG tmWeight
Definition: wingdi.h:2368
BYTE tmBreakChar
Definition: wingdi.h:2375
LONG tmInternalLeading
Definition: wingdi.h:2364
BYTE tmLastChar
Definition: wingdi.h:2373
BYTE tmUnderlined
Definition: wingdi.h:2377
LONG tmMaxCharWidth
Definition: wingdi.h:2367
LONG tmAveCharWidth
Definition: wingdi.h:2366
BYTE tmDefaultChar
Definition: wingdi.h:2374
LONG tmAscent
Definition: wingdi.h:2362
LONG tmOverhang
Definition: wingdi.h:2369
LONG tmHeight
Definition: wingdi.h:2361
BYTE tmItalic
Definition: wingdi.h:2376
LONG tmDigitizedAspectY
Definition: wingdi.h:2371

Referenced by test_font_metrics().

◆ create_fixed_pitch_font_proc()

static int CALLBACK create_fixed_pitch_font_proc ( const LOGFONTA lpelfe,
const TEXTMETRICA lpntme,
DWORD  FontType,
LPARAM  lParam 
)
static

Definition at line 4574 of file font.c.

4577{
4578 const NEWTEXTMETRICEXA *lpntmex = (const NEWTEXTMETRICEXA *)lpntme;
4579 CHARSETINFO csi;
4580 LOGFONTA lf = *lpelfe;
4581 HFONT hfont;
4582 DWORD found_subset;
4583
4584 /* skip bitmap, proportional or vertical font */
4585 if ((FontType & TRUETYPE_FONTTYPE) == 0 ||
4586 (lf.lfPitchAndFamily & 0xf) != FIXED_PITCH ||
4587 lf.lfFaceName[0] == '@')
4588 return 1;
4589
4590 /* skip linked font */
4591 if (!TranslateCharsetInfo((DWORD*)(INT_PTR)lpelfe->lfCharSet, &csi, TCI_SRCCHARSET) ||
4592 (lpntmex->ntmFontSig.fsCsb[0] & csi.fs.fsCsb[0]) == 0)
4593 return 1;
4594
4595 /* skip linked font, like SimSun-ExtB */
4596 switch (lpelfe->lfCharSet) {
4597 case SHIFTJIS_CHARSET:
4598 found_subset = lpntmex->ntmFontSig.fsUsb[1] & (1 << 17); /* Hiragana */
4599 break;
4600 case GB2312_CHARSET:
4602 found_subset = lpntmex->ntmFontSig.fsUsb[1] & (1 << 16); /* CJK Symbols And Punctuation */
4603 break;
4604 case HANGEUL_CHARSET:
4605 found_subset = lpntmex->ntmFontSig.fsUsb[1] & (1 << 24); /* Hangul Syllables */
4606 break;
4607 default:
4608 found_subset = lpntmex->ntmFontSig.fsUsb[0] & (1 << 0); /* Basic Latin */
4609 break;
4610 }
4611 if (!found_subset)
4612 return 1;
4613
4614 /* test with an odd height */
4615 lf.lfHeight = -19;
4616 lf.lfWidth = 0;
4618 if (hfont)
4619 {
4620 *(HFONT *)lParam = hfont;
4621 return 0;
4622 }
4623 return 1;
4624}
FONTSIGNATURE fs
Definition: wingdi.h:1548
DWORD fsUsb[4]
Definition: wingdi.h:1542
DWORD fsCsb[2]
Definition: wingdi.h:1543
FONTSIGNATURE ntmFontSig
Definition: wingdi.h:2672
int32_t INT_PTR
Definition: typedefs.h:64
#define FIXED_PITCH
Definition: wingdi.h:444
#define HANGEUL_CHARSET
Definition: wingdi.h:387
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:390
#define TCI_SRCCHARSET
Definition: wingdi.h:961
#define SHIFTJIS_CHARSET
Definition: wingdi.h:386
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define GB2312_CHARSET
Definition: wingdi.h:389

Referenced by test_GetGlyphOutline().

◆ create_font()

static HFONT create_font ( const char test,
const LOGFONTA lf 
)
static

Definition at line 237 of file font.c.

238{
240 ok(hfont != 0, "%s: CreateFontIndirect failed\n", test);
241 if (hfont)
242 check_font(test, lf, hfont);
243 return hfont;
244}
static void check_font(const char *test, const LOGFONTA *lf, HFONT hfont)
Definition: font.c:195

Referenced by test_bitmap_font(), test_bitmap_font_metrics(), test_GetFontUnicodeRanges(), test_logfont(), test_orientation(), test_outline_font(), and test_SetTextJustification().

◆ create_font_proc()

static int CALLBACK create_font_proc ( const LOGFONTA lpelfe,
const TEXTMETRICA lpntme,
DWORD  FontType,
LPARAM  lParam 
)
static

Definition at line 1112 of file font.c.

1115{
1116 if (FontType & TRUETYPE_FONTTYPE)
1117 {
1118 HFONT hfont;
1119
1120 hfont = CreateFontIndirectA(lpelfe);
1121 if (hfont)
1122 {
1123 *(HFONT *)lParam = hfont;
1124 return 0;
1125 }
1126 }
1127
1128 return 1;
1129}

Referenced by test_GetCharABCWidths(), and test_GetGlyphOutline().

◆ DWORD()

static DWORD ( WINAPI pGdiGetCodePage)
static

◆ enum_all_fonts_proc()

static INT CALLBACK enum_all_fonts_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lparam 
)
static

Definition at line 5203 of file font.c.

5204{
5205 int ret;
5206 LOGFONTA *lf;
5207
5208 if (type != TRUETYPE_FONTTYPE) return 1;
5209
5210 lf = (LOGFONTA *)lparam;
5211 ret = strcmp(lf->lfFaceName, elf->lfFaceName);
5212 if(ret == 0)
5213 {
5214 ok(ntm->tmWeight == elf->lfWeight, "expected %d got %d\n", ntm->tmWeight, elf->lfWeight);
5215 *lf = *elf;
5216 return 0;
5217 }
5218 return 1;
5219}
@ lparam
Definition: SystemMenu.c:31

Referenced by test_EnumFonts().

◆ enum_font_data_proc()

static INT CALLBACK enum_font_data_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 3141 of file font.c.

3142{
3143 struct enum_font_data *efd = (struct enum_font_data *)lParam;
3144
3145 if (type != TRUETYPE_FONTTYPE) return 1;
3146
3147 if (efd->total >= efd->size)
3148 {
3149 efd->size = max( (efd->total + 1) * 2, 256 );
3150 efd->lf = heap_realloc( efd->lf, efd->size * sizeof(*efd->lf) );
3151 if (!efd->lf) return 0;
3152 }
3153 efd->lf[efd->total++] = *lf;
3154
3155 return 1;
3156}

Referenced by test_EnumFontFamiliesEx_default_charset(), and test_vertical_order().

◆ enum_fonts_proc()

static INT CALLBACK enum_fonts_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lparam 
)
static

Definition at line 5190 of file font.c.

5191{
5192 LOGFONTA *lf;
5193
5194 if (type != TRUETYPE_FONTTYPE) return 1;
5195
5196 ok(ntm->tmWeight == elf->lfWeight, "expected %d got %d\n", ntm->tmWeight, elf->lfWeight);
5197
5198 lf = (LOGFONTA *)lparam;
5199 *lf = *elf;
5200 return 0;
5201}

Referenced by test_EnumFonts().

◆ enum_fullname_data_proc()

static INT CALLBACK enum_fullname_data_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 3158 of file font.c.

3159{
3160 struct enum_fullname_data *efnd = (struct enum_fullname_data *)lParam;
3161
3162 if (type != TRUETYPE_FONTTYPE) return 1;
3163
3164 if (efnd->total >= efnd->size)
3165 {
3166 efnd->size = max( (efnd->total + 1) * 2, 256 );
3167 efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
3168 if (!efnd->elf) return 0;
3169 }
3170 efnd->elf[efnd->total++] = *(ENUMLOGFONTA *)lf;
3171
3172 return 1;
3173}
ENUMLOGFONTA * elf
Definition: font.c:2795

Referenced by test_fullname2_helper().

◆ enum_ms_shell_dlg2_proc()

static INT CALLBACK enum_ms_shell_dlg2_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 5315 of file font.c.

5316{
5317 struct enum_fullname_data *efnd = (struct enum_fullname_data *)lParam;
5318
5319if (0) /* Disabled to limit console spam */
5320 trace("enumed font \"%s\", charset %d, height %d, weight %d, italic %d\n",
5321 lf->lfFaceName, lf->lfCharSet, lf->lfHeight, lf->lfWeight, lf->lfItalic);
5322
5323 if (type != TRUETYPE_FONTTYPE) return 1;
5324 if (strcmp(lf->lfFaceName, "MS Shell Dlg 2") != 0) return 1;
5325
5326 if (efnd->total >= efnd->size)
5327 {
5328 efnd->size = max( (efnd->total + 1) * 2, 256 );
5329 efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
5330 if (!efnd->elf) return 0;
5331 }
5332 efnd->elf[efnd->total++] = *(ENUMLOGFONTA *)lf;
5333 return 0;
5334}

Referenced by test_EnumFonts_subst().

◆ enum_ms_shell_dlg_proc()

static INT CALLBACK enum_ms_shell_dlg_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 5294 of file font.c.

5295{
5296 struct enum_fullname_data *efnd = (struct enum_fullname_data *)lParam;
5297
5298if (0) /* Disabled to limit console spam */
5299 trace("enumed font \"%s\", charset %d, height %d, weight %d, italic %d\n",
5300 lf->lfFaceName, lf->lfCharSet, lf->lfHeight, lf->lfWeight, lf->lfItalic);
5301
5302 if (type != TRUETYPE_FONTTYPE) return 1;
5303 if (strcmp(lf->lfFaceName, "MS Shell Dlg") != 0) return 1;
5304
5305 if (efnd->total >= efnd->size)
5306 {
5307 efnd->size = max( (efnd->total + 1) * 2, 256 );
5308 efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
5309 if (!efnd->elf) return 0;
5310 }
5311 efnd->elf[efnd->total++] = *(ENUMLOGFONTA *)lf;
5312 return 0;
5313}

Referenced by test_EnumFonts_subst().

◆ enum_multi_charset_font_proc()

static INT CALLBACK enum_multi_charset_font_proc ( const LOGFONTA lf,
const TEXTMETRICA tm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 3120 of file font.c.

3121{
3122 const NEWTEXTMETRICEXA *ntm = (const NEWTEXTMETRICEXA *)tm;
3124 const DWORD valid_bits = 0x003f01ff;
3125 CHARSETINFO csi;
3126 DWORD fs;
3127
3128 if (type != TRUETYPE_FONTTYPE) return TRUE;
3129
3130 if (TranslateCharsetInfo(ULongToPtr(target->lfCharSet), &csi, TCI_SRCCHARSET)) {
3131 fs = ntm->ntmFontSig.fsCsb[0] & valid_bits;
3132 if ((fs & csi.fs.fsCsb[0]) && (fs & ~csi.fs.fsCsb[0]) && (fs & FS_LATIN1)) {
3133 *target = *lf;
3134 return FALSE;
3135 }
3136 }
3137
3138 return TRUE;
3139}
#define ULongToPtr(ul)
Definition: basetsd.h:92
#define TRUE
Definition: types.h:120
GLenum target
Definition: glext.h:7315
#define fs
Definition: i386-dis.c:444
Definition: ffs.h:70
#define FS_LATIN1
Definition: wingdi.h:560

Referenced by test_EnumFontFamiliesEx_default_charset().

◆ enum_truetype_font_proc()

static INT CALLBACK enum_truetype_font_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 4031 of file font.c.

4032{
4033 INT *enumed = (INT *)lParam;
4034
4035 if (type == TRUETYPE_FONTTYPE)
4036 {
4037 (*enumed)++;
4038 test_text_metrics(lf, (const NEWTEXTMETRICA *)ntm);
4039 }
4040 return 1;
4041}
static void test_text_metrics(const LOGFONTA *lf, const NEWTEXTMETRICA *ntm)
Definition: font.c:3811

Referenced by test_GetTextMetrics().

◆ enum_with_magic_retval_proc()

static INT CALLBACK enum_with_magic_retval_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lparam 
)
static

Definition at line 5221 of file font.c.

5222{
5223 return lparam;
5224}

Referenced by test_EnumFonts().

◆ expect_ff()

static void expect_ff ( const TEXTMETRICA tmA,
const TT_OS2_V4 os2,
WORD  family,
const char name 
)
static

Definition at line 3396 of file font.c.

3397{
3398 ok((tmA->tmPitchAndFamily & 0xf0) == family ||
3400 "%s: expected family %02x got %02x. panose %d-%d-%d-%d-...\n",
3401 name, family, tmA->tmPitchAndFamily, os2->panose.bFamilyType, os2->panose.bSerifStyle,
3402 os2->panose.bWeight, os2->panose.bProportion);
3403}
LANGID WINAPI GetSystemDefaultLangID(void)
Definition: lang.c:761
#define LANG_ENGLISH
Definition: nls.h:52
#define PRIMARYLANGID(l)
Definition: nls.h:16
PANOSE panose
Definition: font.c:3310
BYTE bSerifStyle
Definition: wingdi.h:1870
BYTE bProportion
Definition: wingdi.h:1872
BYTE bWeight
Definition: wingdi.h:1871
BYTE bFamilyType
Definition: wingdi.h:1869

Referenced by test_text_metrics().

◆ find_font_proc()

static INT CALLBACK find_font_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 739 of file font.c.

740{
741 LOGFONTA *lf = (LOGFONTA *)lParam;
742
743 if (elf->lfHeight == lf->lfHeight && !strcmp(elf->lfFaceName, lf->lfFaceName))
744 {
745 *lf = *elf;
746 return 0; /* stop enumeration */
747 }
748 return 1; /* continue enumeration */
749}

Referenced by test_bitmap_font_metrics().

◆ find_ttf_table()

static void * find_ttf_table ( void ttf,
DWORD  size,
DWORD  tag 
)
static

Definition at line 1942 of file font.c.

1943{
1944 WORD i, num_tables = GET_BE_WORD(*((WORD *)ttf + 2));
1945 DWORD *table = (DWORD *)ttf + 3;
1946
1947 for (i = 0; i < num_tables; i++)
1948 {
1949 if (table[0] == tag)
1950 return (BYTE *)ttf + GET_BE_DWORD(table[2]);
1951 table += 4;
1952 }
1953 return NULL;
1954}
#define GET_BE_DWORD(x)
Definition: font.c:110
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
Definition: ecma_167.h:138

Referenced by test_height_selection_vdmx().

◆ font_enum_proc()

static INT CALLBACK font_enum_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 273 of file font.c.

274{
275 if (type & RASTER_FONTTYPE)
276 {
277 LOGFONTA *lf = (LOGFONTA *)lParam;
278 *lf = *elf;
279 return 0; /* stop enumeration */
280 }
281
282 return 1; /* continue enumeration */
283}
#define RASTER_FONTTYPE
Definition: wingdi.h:1107

Referenced by gdi_get_font_metrics(), and test_bitmap_font().

◆ free_font()

static void free_font ( void font)
static

Definition at line 5039 of file font.c.

5040{
5042}
#define UnmapViewOfFile
Definition: compat.h:746
Definition: mk_font.cpp:20

Referenced by test_AddFontMemResource().

◆ get_charset_stats()

static void get_charset_stats ( struct enum_font_data efd,
int ansi_charset,
int symbol_charset,
int russian_charset 
)
static

Definition at line 2856 of file font.c.

2859{
2860 int i;
2861
2862 *ansi_charset = 0;
2863 *symbol_charset = 0;
2864 *russian_charset = 0;
2865
2866 for (i = 0; i < efd->total; i++)
2867 {
2868 switch (efd->lf[i].lfCharSet)
2869 {
2870 case ANSI_CHARSET:
2871 (*ansi_charset)++;
2872 break;
2873 case SYMBOL_CHARSET:
2874 (*symbol_charset)++;
2875 break;
2876 case RUSSIAN_CHARSET:
2877 (*russian_charset)++;
2878 break;
2879 }
2880 }
2881}
#define RUSSIAN_CHARSET
Definition: wingdi.h:396
#define ANSI_CHARSET
Definition: wingdi.h:383
#define SYMBOL_CHARSET
Definition: wingdi.h:385

Referenced by test_EnumFontFamilies().

◆ get_charset_statsW()

static void get_charset_statsW ( struct enum_font_dataW efd,
int ansi_charset,
int symbol_charset,
int russian_charset 
)
static

Definition at line 2883 of file font.c.

2886{
2887 int i;
2888
2889 *ansi_charset = 0;
2890 *symbol_charset = 0;
2891 *russian_charset = 0;
2892
2893 for (i = 0; i < efd->total; i++)
2894 {
2895 switch (efd->lf[i].lfCharSet)
2896 {
2897 case ANSI_CHARSET:
2898 (*ansi_charset)++;
2899 break;
2900 case SYMBOL_CHARSET:
2901 (*symbol_charset)++;
2902 break;
2903 case RUSSIAN_CHARSET:
2904 (*russian_charset)++;
2905 break;
2906 }
2907 }
2908}

Referenced by test_EnumFontFamilies().

◆ get_cmap()

static void * get_cmap ( cmap_header header,
USHORT  plat_id,
USHORT  enc_id 
)
static

Definition at line 3456 of file font.c.

3457{
3458 USHORT i;
3460
3461 for(i = 0; i < GET_BE_WORD(header->num_tables); i++)
3462 {
3463 if(GET_BE_WORD(record->plat_id) == plat_id && GET_BE_WORD(record->enc_id) == enc_id)
3464 return (BYTE *)header + GET_BE_DWORD(record->offset);
3465 record++;
3466 }
3467 return NULL;
3468}

Referenced by get_first_last_from_cmap().

◆ get_first_last_from_cmap()

static BOOL get_first_last_from_cmap ( HDC  hdc,
DWORD first,
DWORD last,
cmap_type cmap_type 
)
static

Definition at line 3477 of file font.c.

3478{
3479 LONG size, ret;
3481 void *cmap;
3482 BOOL r = FALSE;
3483 WORD format;
3484
3485 size = GetFontData(hdc, MS_CMAP_TAG, 0, NULL, 0);
3486 ok(size != GDI_ERROR, "no cmap table found\n");
3487 if(size == GDI_ERROR) return FALSE;
3488
3491 ok(ret == size, "GetFontData should return %u not %u\n", size, ret);
3492 ok(GET_BE_WORD(header->version) == 0, "got cmap version %d\n", GET_BE_WORD(header->version));
3493
3494 cmap = get_cmap(header, 3, 1);
3495 if(cmap)
3497 else
3498 {
3499 cmap = get_cmap(header, 3, 0);
3500 if(cmap) *cmap_type = cmap_ms_symbol;
3501 }
3502 if(!cmap)
3503 {
3505 goto end;
3506 }
3507
3508 format = GET_BE_WORD(*(WORD *)cmap);
3509 switch(format)
3510 {
3511 case 0:
3513 break;
3514 case 4:
3516 break;
3517 default:
3518 trace("unhandled cmap format %d\n", format);
3519 break;
3520 }
3521
3522end:
3524 return r;
3525}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
const GLint * first
Definition: glext.h:5794
#define MS_CMAP_TAG
Definition: font.c:81
static void * get_cmap(cmap_header *header, USHORT plat_id, USHORT enc_id)
Definition: font.c:3456
static BOOL get_first_last_from_cmap4(void *ptr, DWORD *first, DWORD *last, DWORD limit)
Definition: font.c:3431
static UINT UINT last
Definition: font.c:45
static BOOL get_first_last_from_cmap0(void *ptr, DWORD *first, DWORD *last)
Definition: font.c:3405
long LONG
Definition: pedump.c:60

Referenced by test_text_metrics().

◆ get_first_last_from_cmap0()

static BOOL get_first_last_from_cmap0 ( void ptr,
DWORD first,
DWORD last 
)
static

Definition at line 3405 of file font.c.

3406{
3407 int i;
3409
3410 *first = 256;
3411
3412 for(i = 0; i < 256; i++)
3413 {
3414 if(cmap->glyph_ids[i] == 0) continue;
3415 *last = i;
3416 if(*first == 256) *first = i;
3417 }
3418 if(*first == 256) return FALSE;
3419 return TRUE;
3420}
static PVOID ptr
Definition: dispmode.c:27
BYTE glyph_ids[256]
Definition: font.c:3364

Referenced by get_first_last_from_cmap().

◆ get_first_last_from_cmap4()

static BOOL get_first_last_from_cmap4 ( void ptr,
DWORD first,
DWORD last,
DWORD  limit 
)
static

Definition at line 3431 of file font.c.

3432{
3433 int i;
3435 USHORT seg_count = GET_BE_WORD(cmap->seg_countx2) / 2;
3436
3437 *first = 0x10000;
3438
3439 for(i = 0; i < seg_count; i++)
3440 {
3442
3443 get_seg4(cmap, i, &seg);
3444
3445 if(seg.start_count > 0xfffe) break;
3446
3447 if(*first == 0x10000) *first = seg.start_count;
3448
3449 *last = min(seg.end_count, 0xfffe);
3450 }
3451
3452 if(*first == 0x10000) return FALSE;
3453 return TRUE;
3454}
static void get_seg4(cmap_format_4 *cmap, USHORT seg_num, cmap_format_4_seg *seg)
Definition: font.c:3422
#define min(a, b)
Definition: monoChain.cc:55
USHORT start_count
Definition: font.c:3391
USHORT end_count
Definition: font.c:3390
USHORT seg_countx2
Definition: font.c:3373

Referenced by get_first_last_from_cmap().

◆ get_font_dpi()

static int get_font_dpi ( const LOGFONTA lf,
int height 
)
static

Definition at line 6164 of file font.c.

6165{
6167 HFONT hfont;
6169 int ret;
6170
6172 ok(hfont != 0, "CreateFontIndirect failed\n");
6173
6176 ok(ret, "GetTextMetrics failed\n");
6177 ret = tm.tmDigitizedAspectX;
6178 if (height) *height = tm.tmHeight;
6179
6180 DeleteDC(hdc);
6182
6183 return ret;
6184}
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by test_stock_fonts().

◆ get_font_fsselection()

static UINT get_font_fsselection ( LOGFONTA lf)
static

Definition at line 2154 of file font.c.

2155{
2156 OUTLINETEXTMETRICA *otm;
2157 HFONT hfont, hfont_old;
2158 DWORD ret, otm_size;
2159 UINT fsSelection;
2160 HDC hdc;
2161
2162 hdc = GetDC(0);
2164 ok(hfont != NULL, "failed to create a font\n");
2165
2166 hfont_old = SelectObject(hdc, hfont);
2167
2168 otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
2169 otm = HeapAlloc(GetProcessHeap(), 0, otm_size);
2170 otm->otmSize = sizeof(*otm);
2171 ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
2172 ok(ret == otm->otmSize, "expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
2173 fsSelection = otm->otmfsSelection;
2174 HeapFree(GetProcessHeap(), 0, otm);
2175 SelectObject(hdc, hfont_old);
2177 ReleaseDC(0, hdc);
2178
2179 return fsSelection;
2180}
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_GetOutlineTextMetrics().

◆ get_glyph_indices()

static BOOL get_glyph_indices ( INT  charset,
UINT  code_page,
WORD idx,
UINT  count,
BOOL  unicode 
)
static

Definition at line 2496 of file font.c.

2497{
2498 HDC hdc;
2499 LOGFONTA lf;
2500 HFONT hfont, hfont_old;
2501 CHARSETINFO csi;
2503 INT cs;
2504 DWORD i, ret;
2505 char name[64];
2506
2507 assert(count <= 128);
2508
2509 memset(&lf, 0, sizeof(lf));
2510
2511 lf.lfCharSet = charset;
2512 lf.lfHeight = 10;
2513 lstrcpyA(lf.lfFaceName, "Arial");
2514 SetLastError(0xdeadbeef);
2516 ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
2517
2518 hdc = GetDC(0);
2519 hfont_old = SelectObject(hdc, hfont);
2520
2521 cs = GetTextCharsetInfo(hdc, &fs, 0);
2522 ok(cs == charset, "expected %d, got %d\n", charset, cs);
2523
2524 SetLastError(0xdeadbeef);
2525 ret = GetTextFaceA(hdc, sizeof(name), name);
2526 ok(ret, "GetTextFaceA error %u\n", GetLastError());
2527
2528 if (charset == SYMBOL_CHARSET)
2529 {
2530 ok(strcmp("Arial", name), "face name should NOT be Arial\n");
2531 ok(fs.fsCsb[0] & (1u << 31), "symbol encoding should be available\n");
2532 }
2533 else
2534 {
2535 ok(!strcmp("Arial", name), "face name should be Arial, not %s\n", name);
2536 ok(!(fs.fsCsb[0] & (1u << 31)), "symbol encoding should NOT be available\n");
2537 }
2538
2540 {
2541 trace("Can't find codepage for charset %d\n", cs);
2542 ReleaseDC(0, hdc);
2543 return FALSE;
2544 }
2545 ok(csi.ciACP == code_page, "expected %d, got %d\n", code_page, csi.ciACP);
2546
2547 if (pGdiGetCodePage != NULL && pGdiGetCodePage(hdc) != code_page)
2548 {
2549 skip("Font code page %d, looking for code page %d\n",
2550 pGdiGetCodePage(hdc), code_page);
2551 ReleaseDC(0, hdc);
2552 return FALSE;
2553 }
2554
2555 if (unicode)
2556 {
2557 char ansi_buf[128];
2558 WCHAR unicode_buf[128];
2559
2560 for (i = 0; i < count; i++) ansi_buf[i] = (BYTE)(i + 128);
2561
2562 MultiByteToWideChar(code_page, 0, ansi_buf, count, unicode_buf, count);
2563
2564 SetLastError(0xdeadbeef);
2565 ret = pGetGlyphIndicesW(hdc, unicode_buf, count, idx, 0);
2566 ok(ret == count, "GetGlyphIndicesW expected %d got %d, error %u\n",
2567 count, ret, GetLastError());
2568 }
2569 else
2570 {
2571 char ansi_buf[128];
2572
2573 for (i = 0; i < count; i++) ansi_buf[i] = (BYTE)(i + 128);
2574
2575 SetLastError(0xdeadbeef);
2576 ret = pGetGlyphIndicesA(hdc, ansi_buf, count, idx, 0);
2577 ok(ret == count, "GetGlyphIndicesA expected %d got %d, error %u\n",
2578 count, ret, GetLastError());
2579 }
2580
2581 SelectObject(hdc, hfont_old);
2583
2584 ReleaseDC(0, hdc);
2585
2586 return TRUE;
2587}
#define skip(...)
Definition: atltest.h:64
CFF_Charset charset
Definition: cffcmap.c:138
#define SetLastError(x)
Definition: compat.h:752
#define MultiByteToWideChar
Definition: compat.h:110
#define assert(x)
Definition: debug.h:53
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define cs
Definition: i386-dis.c:442
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI GetTextCharsetInfo(_In_ HDC, _Out_opt_ LPFONTSIGNATURE, _In_ DWORD)

Referenced by test_font_charset().

◆ get_mac_code_page()

static WORD get_mac_code_page ( const sfnt_name name)
inlinestatic

Definition at line 3676 of file font.c.

3677{
3678 if (GET_BE_WORD(name->encoding_id) == TT_MAC_ID_SIMPLIFIED_CHINESE) return 10008; /* special case */
3679 return 10000 + GET_BE_WORD(name->encoding_id);
3680}
#define TT_MAC_ID_SIMPLIFIED_CHINESE
Definition: font.c:1183

◆ get_res_data()

static void * get_res_data ( const char fontname,
DWORD rsrc_size 
)
static

Definition at line 149 of file font.c.

150{
151 HRSRC rsrc;
152 void *rsrc_data;
153
155 if (!rsrc) return NULL;
156
157 rsrc_data = LockResource(LoadResource(GetModuleHandleA(NULL), rsrc));
158 if (!rsrc_data) return NULL;
159
160 *rsrc_size = SizeofResource(GetModuleHandleA(NULL), rsrc);
161 if (!*rsrc_size) return NULL;
162
163 return rsrc_data;
164}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define RT_RCDATA
Definition: pedump.c:372
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by test_height_selection_vdmx(), and write_ttf_file().

◆ get_seg4()

static void get_seg4 ( cmap_format_4 cmap,
USHORT  seg_num,
cmap_format_4_seg seg 
)
static

Definition at line 3422 of file font.c.

3423{
3424 USHORT segs = GET_BE_WORD(cmap->seg_countx2) / 2;
3425 seg->end_count = GET_BE_WORD(cmap->end_count[seg_num]);
3426 seg->start_count = GET_BE_WORD(cmap->end_count[segs + 1 + seg_num]);
3427 seg->id_delta = GET_BE_WORD(cmap->end_count[2 * segs + 1 + seg_num]);
3428 seg->id_range_offset = GET_BE_WORD(cmap->end_count[3 * segs + 1 + seg_num]);
3429}
USHORT id_delta
Definition: font.c:3392
USHORT id_range_offset
Definition: font.c:3393
USHORT end_count[1]
Definition: font.c:3378

Referenced by get_first_last_from_cmap4().

◆ get_ttf_nametable_entry()

static BOOL get_ttf_nametable_entry ( HDC  hdc,
WORD  name_id,
WCHAR out_buf,
SIZE_T  out_size,
LCID  language_id 
)
static

Definition at line 3729 of file font.c.

3730{
3731 struct sfnt_name_header
3732 {
3733 USHORT format;
3734 USHORT number_of_record;
3735 USHORT storage_offset;
3736 } *header;
3738 BOOL r = FALSE;
3740 LONG c, ret;
3741 WCHAR *name;
3742 BYTE *data;
3743 USHORT i;
3744 int res, best_lang = 0, best_index = -1;
3745
3746 size = GetFontData(hdc, MS_NAME_TAG, 0, NULL, 0);
3747 ok(size != GDI_ERROR, "no name table found\n");
3748 if(size == GDI_ERROR) return FALSE;
3749
3752 ok(ret == size, "GetFontData should return %u not %u\n", size, ret);
3753
3754 header = (void *)data;
3755 header->format = GET_BE_WORD(header->format);
3756 header->number_of_record = GET_BE_WORD(header->number_of_record);
3757 header->storage_offset = GET_BE_WORD(header->storage_offset);
3758 if (header->format != 0)
3759 {
3760 trace("got format %u\n", header->format);
3761 goto out;
3762 }
3763 if (header->number_of_record == 0 || sizeof(*header) + header->number_of_record * sizeof(*entry) > size)
3764 {
3765 trace("number records out of range: %d\n", header->number_of_record);
3766 goto out;
3767 }
3768 if (header->storage_offset >= size)
3769 {
3770 trace("storage_offset %u > size %u\n", header->storage_offset, size);
3771 goto out;
3772 }
3773
3774 entry = (void *)&header[1];
3775 for (i = 0; i < header->number_of_record; i++)
3776 {
3777 if (GET_BE_WORD(entry[i].name_id) != name_id) continue;
3778 res = match_name_table_language( &entry[i], language_id);
3779 if (res > best_lang)
3780 {
3781 best_lang = res;
3782 best_index = i;
3783 }
3784 }
3785
3786 offset = header->storage_offset + GET_BE_WORD(entry[best_index].offset);
3787 length = GET_BE_WORD(entry[best_index].length);
3788 if (offset + length > size)
3789 {
3790 trace("entry %d is out of range\n", best_index);
3791 goto out;
3792 }
3793 if (length >= out_size)
3794 {
3795 trace("buffer too small for entry %d\n", best_index);
3796 goto out;
3797 }
3798
3799 name = (WCHAR *)(data + offset);
3800 for (c = 0; c < length / 2; c++)
3801 out_buf[c] = GET_BE_WORD(name[c]);
3802 out_buf[c] = 0;
3803
3804 r = TRUE;
3805
3806out:
3808 return r;
3809}
static int match_name_table_language(const tt_name_record *name, LANGID lang)
Definition: font.c:1351
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
const GLubyte * c
Definition: glext.h:8905
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
uint32_t entry
Definition: isohybrid.c:63
#define c
Definition: ke_i.h:80
#define MS_NAME_TAG
Definition: font.c:82
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
static FILE * out
Definition: regtests2xml.c:44

Referenced by test_fullname(), and test_fullname2_helper().

◆ HANDLE()

static HANDLE ( WINAPI pAddFontMemResourceEx)
static

◆ has_vertical_font_proc()

static INT CALLBACK has_vertical_font_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 6107 of file font.c.

6109{
6110 if (lf->lfFaceName[0] == '@') {
6111 return 0;
6112 }
6113 return 1;
6114}

Referenced by test_east_asian_font_selection().

◆ HFONT()

static DWORD *static HFONT ( WINAPI pCreateFontIndirectExA) const
static

Referenced by _Success_(), add_ruler_units(), AddCharToSelection(), AdvAppearanceDlg_Init(), BuildFont(), BUTTON_CalcLabelRect(), BUTTON_WindowProc(), ButtonWndProc_common(), C1_SetData(), Pane::calc_single_width(), Pane::calc_widths(), ProgressDlg::CalcTextRect(), CB_Paint(), CB_ThemedPaint(), CBGetTextAreaHeight(), CBPaintText(), CFn_WMMeasureItem(), CFn_WMPaint(), check_height_font_enumproc(), check_item_height(), check_vertical_font(), check_vertical_metrics(), CheckListWndProc(), ChildWndProc(), COMBO_WindowProc(), COMBOEX_Create(), COMBOEX_WindowProc(), ComboWndProc_common(), COMCTL32_GetFontMetrics(), ConfirmMsgBox_Init(), ConfirmMsgBox_Paint(), create_fixed_pitch_font_proc(), create_font(), create_font_proc(), CreateBoldFont(), CreateConsoleFont2(), CreateConsoleFontEx(), CreateFontA(), CCharMapWindow::CreateFontComboBox(), CreateFontset(), CreateLayoutIcon(), CreateMonospaceFont(), CreateStockFonts(), CreateTitleFont(), CreateTrayIcon(), ctrl_container_reparent(), ctrl_resize(), CUIFObject::CUIFObject(), CUIFToolbarMenuButton::CUIFToolbarMenuButton(), D3DXCreateTextTest(), D3DXCreateTextW(), DATETIME_GetIdealSize(), DATETIME_Refresh(), DATETIME_WindowProc(), DC_hSelectFont(), default_page_paint_hook(), DIALOG_CreateIndirect(), DIALOG_SelectFont(), Display_DrawText(), DlgProc(), DoEntry(), DoPrintDocument(), DoPrintPage(), DoTestEntry(), draw_text_2(), CGridView::DrawGrid(), DrawNCPreview(), DrawProc(), DrawShadowText(), DrawThemeText(), DumpFont(), EDIT_EM_SetMargins(), EDIT_PaintText(), EDIT_UpdateUniscribeData(), EDIT_UpdateUniscribeData_linedef(), EDIT_WindowProc(), EDIT_WM_Paint(), EDIT_WM_SetFont(), EditTypeDlg_OnDrawItem(), EnumEnhMetaFile(), EnumMetaFile(), FILEDLG95_LOOKIN_Init(), FillFontStyleComboList(), FillGrid(), find_installed_font(), fnIMLangFontLink2_GetFontCodePages(), fnIMLangFontLink2_MapFont(), font_height(), FontSizeChange(), ftGdiGetGlyphOutline(), ftGdiGetTextCharsetInfo(), GB_Paint(), GB_ThemedPaint(), GDI32_GdipDrawDriverString(), gdi_get_font_metrics(), GdiFlushUserBatch(), GdipCreateFont(), GdipCreateFontFromDC(), GdipCreateFontFromLogfontW(), GdipDrawString(), GdipMeasureCharacterRanges(), GdipMeasureDriverString(), GdipMeasureString(), GdiRealizationInfo(), GdiSelectFont(), get_button_font(), get_current_font_height(), get_font_dpi(), get_font_fsselection(), get_font_hfont(), get_glyph_indices(), get_text_metr_size(), get_tmheight(), get_tmheightW(), GetButtonHeight(), GetDialogFont(), ATL::CWindow::GetFont(), CTipbarThread::GetTextSize(), GetThemeTextExtent(), GetThemeTextMetrics(), Graph_DrawCpuUsageGraph(), Graph_DrawMemUsageGraph(), GuiPaintTextModeBuffer(), HEADER_Create(), HEADER_CreateDragImage(), HEADER_Refresh(), HEADER_SetFont(), HEADER_WindowProc(), HEXEDIT_WM_PAINT(), HEXEDIT_WM_SETFONT(), HexEditWndProc(), HfontCreate(), HOTKEY_DrawHotKey(), HOTKEY_SetFont(), HOTKEY_WindowProc(), ICONTITLE_Paint(), ICONTITLE_SetTitlePos(), init(), init_texthost(), InitEditWnd(), InitFonts(), IntDrawMenuBarTemp(), IntDrawState(), IntGrayString(), IntPaintDesktop(), IntTMWFixUp(), IPADDRESS_Create(), is_font_available(), LISTBOX_DrawFocusRect(), LISTBOX_Paint(), LISTBOX_RepaintItem(), LISTBOX_SetFont(), LISTBOX_WindowProc(), ListBoxWndProc_common(), LISTVIEW_Command(), LISTVIEW_CreateDragImage(), LISTVIEW_EditLabelT(), LISTVIEW_GetItemMetrics(), LISTVIEW_GetStringWidthT(), LISTVIEW_Refresh(), LISTVIEW_SaveTextMetrics(), LISTVIEW_SetColumnWidth(), LISTVIEW_SetFont(), LISTVIEW_ShowFocusRect(), LISTVIEW_WindowProc(), LoadDialog(), LoadIniFile(), LrgCellWndProc(), MainFrameBase::MainFrameBase(), MainWndProc(), font::MakeFont(), map_font(), MDIChildWndProc(), ME_MakeFirstParagraph(), CTrayClockWnd::MeasureLines(), MENU_CalcItemSize(), MENU_DrawMenuBar(), MENU_DrawMenuItem(), MENU_DrawPopupGlyph(), METADC_SelectFont(), MonitorSelWndProc(), MonSelChangeFont(), MonSelGetMonitorFont(), MonSelPaintMonitor(), MONTHCAL_PaintTodayTitle(), MONTHCAL_UpdateSize(), MONTHCAL_WindowProc(), MonthCalChangeFont(), MonthCalPaint(), MonthCalWndProc(), msi_dialog_get_sans_serif_height(), MyDrawFrameCaption(), MyDrawFrameScroll(), MyEnumFontFamExProc(), NOTEPAD_LoadSettingsFromRegistry(), NT5_DrawLogoffCaptionText(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), NtGdiGetFontData(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphIndicesW(), NtGdiGetOutlineTextMetricsInternalW(), NtGdiGetTextFaceW(), NtGdiSelectFont(), OB_Paint(), OleCreatePropertyFrameIndirect(), OLEFontImpl_QueryTextMetrics(), OleMetafilePictFromIconAndLabel(), on_wm_initdialog(), OnCreate(), CAutoComplete::OnCreate(), CBaseBarSite::OnCustomDraw(), OnMeasureItem(), OnPaint(), CTrayClockWnd::OnPaint(), CTrayClockWnd::OnSetFont(), CTrayClockWnd::OnThemeChanged(), OSK_ChooseFont(), OSK_Paint(), PaintControl(), PaintText(), PB_Paint(), PB_ThemedPaint(), PlotCharacter(), PreviewWndProc(), ProgressDlg::ProcessWindowMessage(), PROGRESS_SetFont(), ProgressWindowProc(), PROPSHEET_Paint(), realize_font(), REBAR_DrawBand(), REBAR_NCCreate(), REBAR_ValidateBand(), REBAR_WindowProc(), RefreshFontPreview(), RetChangeControlFont(), RosImageProc(), ScriptStringAnalyse(), select_style(), CGridView::SetFont(), SetFontStylesToCombo2(), SetLrgFont(), CUIFMenu::SetMenuFont(), SetMessageFont(), SetupControls(), SoftModalMessageBox(), SOFTWARE_GdipDrawDriverString(), SS_ItemOut(), START_TEST(), STATIC_PaintOwnerDrawfn(), STATIC_PaintTextfn(), STATUSBAR_Refresh(), StatusWindowProc(), SYSLINK_Draw(), SYSLINK_SetFont(), SysLinkWindowProc(), T1_GetTextMetric(), T1_SetData(), TAB_Create(), TAB_DrawItemInterior(), TAB_Refresh(), TAB_SetItemBounds(), TAB_WindowProc(), taskdialog_get_text_extent(), test_AddRefHfont(), test_bcm_get_ideal_size(), test_bitmap_font(), test_bitmap_font_glyph_index(), test_bitmap_font_metrics(), test_button_messages(), test_combo_setfont(), Test_CreateFontA(), test_CreateFontIndirect(), Test_CreateFontIndirectA(), test_CreateFontIndirectEx(), Test_CreateFontIndirectExA(), Test_CreateFontIndirectExW(), Test_CreateFontIndirectW(), test_createtext(), test_DrawTextCalcRect(), test_dtm_get_ideal_size(), test_dtm_set_and_get_mcfont(), test_east_asian_font_selection(), test_EM_GETMODIFY(), test_emf_ExtTextOut_on_path(), test_ExtTextOut(), test_fake_bold_font(), Test_Font(), test_font_caps(), test_font_substitution(), Test_FontSelectionEntry(), test_fontsize(), test_fstype_fixup(), test_fullname(), test_fullname2_helper(), Test_GdiConvertFont(), Test_GdiGetCharDimensions(), test_GdiGetCodePage(), test_GetCharABCWidths(), test_GetCharWidth32(), test_GetCharWidthI(), test_GetCurrentObject(), test_GetFontUnicodeRanges(), test_GetGlyphIndices(), test_GetGlyphOutline(), test_GetGlyphOutline_empty_contour(), test_GetGlyphOutline_metric_clipping(), Test_GetIdealSizeNoThemes(), test_GetKerningPairs(), test_GetOutlineTextMetrics(), test_GetTextFace(), Test_GetTextFaceAliasW(), test_GetTextMetrics2(), test_height(), test_hfont_lifetime(), test_ifont_size(), test_item_count(), test_item_height(), test_logfont(), test_long_names(), test_MapFont(), test_margins_default(), test_margins_font_change(), test_margins_usefontinfo(), test_max_height(), test_MessageBoxFontTest(), test_mf_SaveDC(), test_negative_width(), test_nonexistent_font(), test_oemcharset(), test_orientation(), test_outline_font(), test_RealizationInfo(), test_ReleaseHfont(), test_SaveDC(), test_script_cache_reuse(), test_ScriptCacheGetHeight(), test_ScriptGetFontProperties(), test_ScriptGetGlyphABCWidth(), test_ScriptPlace(), test_ScriptShape(), test_ScriptShapeOpenType(), test_setfont(), test_SetTextJustification(), test_size(), test_stock_fonts(), test_tab(), test_text_extents(), test_text_metrics(), test_text_position_style(), test_TxGetNaturalSize(), test_WM_SETFONT(), TextProc(), ThemeDrawCaptionText(), TOOLBAR_CalcStrings(), TOOLBAR_DrawString(), TOOLBAR_LayoutToolbar(), ToolbarWindowProc(), ToolTipProc(), TOOLTIPS_CalcTipSize(), TOOLTIPS_Refresh(), TOOLTIPS_WindowProc(), TreeListEditLabel(), TreeListProc(), TREEVIEW_Command(), TREEVIEW_ComputeTextWidth(), TREEVIEW_CreateDragImage(), TREEVIEW_DrawItem(), TREEVIEW_EditLabel(), TREEVIEW_NaturalHeight(), TREEVIEW_UpdateSubTree(), TREEVIEW_WindowProc(), UB_Paint(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), UITOOLS95_DrawFrameScroll(), UserDrawCaptionText(), VfdToolTip(), wglUseFontOutlines_common(), WINHELP_InitFonts(), WndProc(), and HyperlinkCtrl::WndProc().

◆ init()

static void init ( void  )
static

Definition at line 84 of file font.c.

85{
86 hgdi32 = GetModuleHandleA("gdi32.dll");
87
88 pGdiGetCharDimensions = (void *)GetProcAddress(hgdi32, "GdiGetCharDimensions");
89 pGdiGetCodePage = (void *) GetProcAddress(hgdi32,"GdiGetCodePage");
90 pGetCharABCWidthsI = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsI");
91 pGetCharABCWidthsA = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsA");
92 pGetCharABCWidthsW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsW");
93 pGetCharABCWidthsFloatW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsFloatW");
94 pGetCharWidth32A = (void *)GetProcAddress(hgdi32, "GetCharWidth32A");
95 pGetCharWidth32W = (void *)GetProcAddress(hgdi32, "GetCharWidth32W");
96 pGetFontUnicodeRanges = (void *)GetProcAddress(hgdi32, "GetFontUnicodeRanges");
97 pGetGlyphIndicesA = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesA");
98 pGetGlyphIndicesW = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesW");
99 pGetTextExtentExPointI = (void *)GetProcAddress(hgdi32, "GetTextExtentExPointI");
100 pGdiRealizationInfo = (void *)GetProcAddress(hgdi32, "GdiRealizationInfo");
101 pCreateFontIndirectExA = (void *)GetProcAddress(hgdi32, "CreateFontIndirectExA");
102 pAddFontMemResourceEx = (void *)GetProcAddress(hgdi32, "AddFontMemResourceEx");
103 pRemoveFontMemResourceEx = (void *)GetProcAddress(hgdi32, "RemoveFontMemResourceEx");
104 pAddFontResourceExA = (void *)GetProcAddress(hgdi32, "AddFontResourceExA");
105 pRemoveFontResourceExA = (void *)GetProcAddress(hgdi32, "RemoveFontResourceExA");
106 pGetFontRealizationInfo = (void *)GetProcAddress(hgdi32, "GetFontRealizationInfo");
107 pGetFontFileInfo = (void *)GetProcAddress(hgdi32, "GetFontFileInfo");
108 pGetFontFileData = (void *)GetProcAddress(hgdi32, "GetFontFileData");
109
111}
#define GetProcAddress(x, y)
Definition: compat.h:753
static HMODULE hgdi32
Definition: font.c:65
static WORD system_lang_id
Definition: font.c:67

Referenced by START_TEST().

◆ INT()

static INT ( WINAPI pAddFontResourceExA)
static

◆ is_CJK()

static BOOL is_CJK ( void  )
static

Definition at line 751 of file font.c.

752{
754}
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_JAPANESE
Definition: nls.h:76
#define LANG_KOREAN
Definition: nls.h:84

Referenced by test_bitmap_font_metrics().

◆ is_font_installed()

static BOOL is_font_installed ( const char name)
static

Definition at line 137 of file font.c.

138{
139 HDC hdc = GetDC(0);
140 BOOL ret = FALSE;
141
143 ret = TRUE;
144
145 ReleaseDC(0, hdc);
146 return ret;
147}
static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
Definition: font.c:632
int WINAPI EnumFontFamiliesA(_In_ HDC, _In_opt_ LPCSTR, _In_ FONTENUMPROCA, _In_ LPARAM)

Referenced by test_EnumFonts_subst(), test_font_charset(), test_GdiGetCodePage(), test_GetGlyphIndices(), test_GetKerningPairs(), test_GetOutlineTextMetrics(), test_GetTextFace(), test_nonexistent_font(), and test_SetTextJustification().

◆ is_font_installed_fullname()

static BOOL is_font_installed_fullname ( const char family,
const char fullname 
)
static

Definition at line 5408 of file font.c.

5409{
5410 HDC hdc = GetDC(0);
5411 BOOL ret = FALSE;
5412
5414 ret = TRUE;
5415
5416 ReleaseDC(0, hdc);
5417 return ret;
5418}
const char * fullname
Definition: shader.c:1766
static INT CALLBACK is_font_installed_fullname_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
Definition: font.c:5398
LONG_PTR LPARAM
Definition: windef.h:208

Referenced by test_fullname().

◆ is_font_installed_fullname_proc()

static INT CALLBACK is_font_installed_fullname_proc ( const LOGFONTA lf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 5398 of file font.c.

5399{
5400 const ENUMLOGFONTA *elf = (const ENUMLOGFONTA *)lf;
5401 const char *fullname = (const char *)lParam;
5402
5403 if (!strcmp((const char *)elf->elfFullName, fullname)) return 0;
5404
5405 return 1;
5406}
BYTE elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2687

Referenced by is_font_installed_fullname().

◆ is_font_installed_proc()

static INT CALLBACK is_font_installed_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 132 of file font.c.

133{
134 return 0;
135}

◆ is_truetype_font_installed()

static BOOL is_truetype_font_installed ( const char name)
static

◆ is_truetype_font_installed_proc()

static INT CALLBACK is_truetype_font_installed_proc ( const LOGFONTA elf,
const TEXTMETRICA ntm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 113 of file font.c.

114{
115 if (type != TRUETYPE_FONTTYPE) return 1;
116
117 return 0;
118}

Referenced by is_truetype_font_installed().

◆ load_font()

static void * load_font ( const char font_name,
DWORD font_size 
)
static

Definition at line 5044 of file font.c.

5045{
5046 char file_name[MAX_PATH];
5048 void *font;
5049
5050 if (!GetWindowsDirectoryA(file_name, sizeof(file_name))) return NULL;
5051 strcat(file_name, "\\fonts\\");
5052 strcat(file_name, font_name);
5053
5055 if (file == INVALID_HANDLE_VALUE) return NULL;
5056
5058
5060 if (!mapping)
5061 {
5063 return NULL;
5064 }
5065
5067
5070 return font;
5071}
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
static FT_F26Dot6 font_size
Definition: ftrandom.c:89
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static LPCWSTR file_name
Definition: protocol.c:147
Definition: fci.c:127

Referenced by test_AddFontMemResource().

◆ LONG()

static LONG ( WINAPI pGdiGetCharDimensions)
static

◆ long_enum_proc()

static INT CALLBACK long_enum_proc ( const LOGFONTA lf,
const TEXTMETRICA tm,
DWORD  type,
LPARAM  lparam 
)
static

Definition at line 6804 of file font.c.

6805{
6806 BOOL *found_font = (BOOL *)lparam;
6807 *found_font = TRUE;
6808 return 1;
6809}

Referenced by test_long_names().

◆ match_name_table_language()

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

Definition at line 3682 of file font.c.

3683{
3684 LANGID name_lang;
3685 int res = 0;
3686
3687 switch (GET_BE_WORD(name->platform_id))
3688 {
3690 res += 5; /* prefer the Microsoft name */
3691 switch (GET_BE_WORD(name->encoding_id))
3692 {
3694 case TT_MS_ID_SYMBOL_CS:
3695 name_lang = GET_BE_WORD(name->language_id);
3696 break;
3697 default:
3698 return 0;
3699 }
3700 break;
3702 if (!IsValidCodePage( get_mac_code_page( name ))) return 0;
3703 if (GET_BE_WORD(name->language_id) >= sizeof(mac_langid_table)/sizeof(mac_langid_table[0])) return 0;
3704 name_lang = mac_langid_table[GET_BE_WORD(name->language_id)];
3705 break;
3707 res += 2; /* prefer Unicode encodings */
3708 switch (GET_BE_WORD(name->encoding_id))
3709 {
3713 if (GET_BE_WORD(name->language_id) >= sizeof(mac_langid_table)/sizeof(mac_langid_table[0])) return 0;
3714 name_lang = mac_langid_table[GET_BE_WORD(name->language_id)];
3715 break;
3716 default:
3717 return 0;
3718 }
3719 break;
3720 default:
3721 return 0;
3722 }
3723 if (name_lang == lang) res += 30;
3724 else if (PRIMARYLANGID( name_lang ) == PRIMARYLANGID( lang )) res += 20;
3725 else if (name_lang == MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT )) res += 10;
3726 return res;
3727}
#define TT_APPLE_ID_ISO_10646
Definition: font.c:1177
static WORD get_mac_code_page(const tt_name_record *name)
Definition: font.c:1344
#define TT_MS_ID_UNICODE_CS
Definition: font.c:1181
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
#define TT_APPLE_ID_DEFAULT
Definition: font.c:1176
#define TT_APPLE_ID_UNICODE_2_0
Definition: font.c:1178
#define TT_PLATFORM_MACINTOSH
Definition: font.c:1173
#define TT_MS_ID_SYMBOL_CS
Definition: font.c:1180
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1172
static const LANGID mac_langid_table[]
Definition: font.c:1220
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1604
USHORT LANGID
Definition: mui.h:9
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
static const WCHAR lang[]
Definition: wbemdisp.c:287

◆ match_off_by_n()

static BOOL match_off_by_n ( int  a,
int  b,
unsigned int  n 
)
inlinestatic

Definition at line 34 of file font.c.

35{
36 return abs(a - b) <= n;
37}
#define abs(i)
Definition: fconv.c:206
GLdouble n
Definition: glext.h:7729
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ prepend_at()

static WCHAR * prepend_at ( WCHAR family)
static

Definition at line 5468 of file font.c.

5469{
5470 if (!family)
5471 return NULL;
5472
5473 memmove(family + 1, family, (lstrlenW(family) + 1) * sizeof(WCHAR));
5474 family[0] = '@';
5475 return family;
5476}
#define lstrlenW
Definition: compat.h:750
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by test_fullname2_helper().

◆ START_TEST()

START_TEST ( font  )

Definition at line 6857 of file font.c.

6858{
6859 init();
6860
6862 test_logfont();
6882
6883 /* On Windows Arial has a lot of default charset aliases such as Arial Cyr,
6884 * I'd like to avoid them in this test.
6885 */
6886 test_EnumFontFamilies("Arial Black", ANSI_CHARSET);
6888 if (is_truetype_font_installed("Arial Black") &&
6889 (is_truetype_font_installed("Symbol") || is_truetype_font_installed("Wingdings")))
6890 {
6894 }
6895 else
6896 skip("Arial Black or Symbol/Wingdings is not installed\n");
6902 test_GetTextMetrics2("Tahoma", -11);
6903 test_GetTextMetrics2("Tahoma", -55);
6904 test_GetTextMetrics2("Tahoma", -110);
6905 test_GetTextMetrics2("Arial", -11);
6906 test_GetTextMetrics2("Arial", -55);
6907 test_GetTextMetrics2("Arial", -110);
6912 test_fullname();
6922
6923 /* These tests should be last test until RemoveFontResource
6924 * is properly implemented.
6925 */
6928}
static void test_GetGlyphOutline(void)
Definition: font.c:4626
static void test_nonexistent_font(void)
Definition: font.c:4064
static void test_GetTextFace(void)
Definition: font.c:4424
static void test_east_asian_font_selection(void)
Definition: font.c:6116
static void init(void)
Definition: font.c:84
static void test_GdiGetCharDimensions(void)
Definition: font.c:1074
static void test_GetTextMetrics(void)
Definition: font.c:4043
static void test_GetGlyphIndices(void)
Definition: font.c:1611
static void test_GetCharacterPlacement(void)
Definition: font.c:4942
static void test_font_charset(void)
Definition: font.c:2589
static void test_EnumFontFamilies(const char *font_name, INT font_charset)
Definition: font.c:2910
static void test_logfont(void)
Definition: font.c:246
static void test_orientation(void)
Definition: font.c:4517
static void test_max_height(void)
Definition: font.c:6307
static void test_fake_bold_font(void)
Definition: font.c:6505
static void test_CreateFontIndirect(void)
Definition: font.c:4973
static void test_GdiGetCodePage(void)
Definition: font.c:2641
static void test_GetFontUnicodeRanges(void)
Definition: font.c:2741
static void test_EnumFonts_subst(void)
Definition: font.c:5336
static void test_RealizationInfo(void)
Definition: font.c:4257
static void test_EnumFonts(void)
Definition: font.c:5226
static void test_AddFontMemResource(void)
Definition: font.c:5073
static void test_outline_font(void)
Definition: font.c:489
static void test_height_selection(void)
Definition: font.c:2129
static void test_CreateFontIndirectEx(void)
Definition: font.c:5008
static void test_GetCharWidthI(void)
Definition: font.c:6762
static void test_oemcharset(void)
Definition: font.c:4546
static void test_fullname2(void)
Definition: font.c:5590
static void test_GetOutlineTextMetrics(void)
Definition: font.c:2182
static void test_bitmap_font_metrics(void)
Definition: font.c:757
static void test_SetTextJustification(void)
Definition: font.c:2382
static void test_text_extents(void)
Definition: font.c:1455
static void test_stock_fonts(void)
Definition: font.c:6186
static void test_long_names(void)
Definition: font.c:6811
static void test_bitmap_font(void)
Definition: font.c:401
static void test_GetTextMetrics2(const char *fontname, int font_height)
Definition: font.c:4885
static void test_EnumFontFamiliesEx_default_charset(void)
Definition: font.c:3175
static void test_GetCharABCWidths(void)
Definition: font.c:1156
static void test_bitmap_font_glyph_index(void)
Definition: font.c:6629
static void test_vertical_order(void)
Definition: font.c:6365
static void test_fullname(void)
Definition: font.c:5420
static void test_CreateScalableFontResource(void)
Definition: font.c:5755
static void test_GetCharWidth32(void)
Definition: font.c:6401
static void test_vertical_font(void)
Definition: font.c:6047
static void test_GetKerningPairs(void)
Definition: font.c:1679

◆ test_AddFontMemResource()

static void test_AddFontMemResource ( void  )
static

Definition at line 5073 of file font.c.

5074{
5075 void *font;
5076 DWORD font_size, num_fonts;
5077 HANDLE ret;
5078 BOOL bRet;
5079
5080 if (!pAddFontMemResourceEx || !pRemoveFontMemResourceEx)
5081 {
5082 win_skip("AddFontMemResourceEx is not available on this platform\n");
5083 return;
5084 }
5085
5086 font = load_font("sserife.fon", &font_size);
5087 if (!font)
5088 {
5089 skip("Unable to locate and load font sserife.fon\n");
5090 return;
5091 }
5092
5093 SetLastError(0xdeadbeef);
5094 ret = pAddFontMemResourceEx(NULL, 0, NULL, NULL);
5095 ok(!ret, "AddFontMemResourceEx should fail\n");
5097 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5098 GetLastError());
5099
5100 SetLastError(0xdeadbeef);
5101 ret = pAddFontMemResourceEx(NULL, 10, NULL, NULL);
5102 ok(!ret, "AddFontMemResourceEx should fail\n");
5104 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5105 GetLastError());
5106
5107 SetLastError(0xdeadbeef);
5108 ret = pAddFontMemResourceEx(NULL, 0, NULL, &num_fonts);
5109 ok(!ret, "AddFontMemResourceEx should fail\n");
5111 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5112 GetLastError());
5113
5114 SetLastError(0xdeadbeef);
5115 ret = pAddFontMemResourceEx(NULL, 10, NULL, &num_fonts);
5116 ok(!ret, "AddFontMemResourceEx should fail\n");
5118 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5119 GetLastError());
5120
5121 SetLastError(0xdeadbeef);
5122 ret = pAddFontMemResourceEx(font, 0, NULL, NULL);
5123 ok(!ret, "AddFontMemResourceEx should fail\n");
5125 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5126 GetLastError());
5127
5128 SetLastError(0xdeadbeef);
5129 ret = pAddFontMemResourceEx(font, 10, NULL, NULL);
5130 ok(!ret, "AddFontMemResourceEx should fail\n");
5132 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5133 GetLastError());
5134
5135 num_fonts = 0xdeadbeef;
5136 SetLastError(0xdeadbeef);
5137 ret = pAddFontMemResourceEx(font, 0, NULL, &num_fonts);
5138 ok(!ret, "AddFontMemResourceEx should fail\n");
5140 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5141 GetLastError());
5142 ok(num_fonts == 0xdeadbeef, "number of loaded fonts should be 0xdeadbeef\n");
5143
5144 if (0) /* hangs under windows 2000 */
5145 {
5146 num_fonts = 0xdeadbeef;
5147 SetLastError(0xdeadbeef);
5148 ret = pAddFontMemResourceEx(font, 10, NULL, &num_fonts);
5149 ok(!ret, "AddFontMemResourceEx should fail\n");
5150 ok(GetLastError() == 0xdeadbeef,
5151 "Expected GetLastError() to return 0xdeadbeef, got %u\n",
5152 GetLastError());
5153 ok(num_fonts == 0xdeadbeef, "number of loaded fonts should be 0xdeadbeef\n");
5154 }
5155
5156 num_fonts = 0xdeadbeef;
5157 SetLastError(0xdeadbeef);
5158 ret = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
5159 ok(ret != 0, "AddFontMemResourceEx error %d\n", GetLastError());
5160 ok(num_fonts != 0xdeadbeef, "number of loaded fonts should not be 0xdeadbeef\n");
5161 ok(num_fonts != 0, "number of loaded fonts should not be 0\n");
5162
5163 free_font(font);
5164
5165 SetLastError(0xdeadbeef);
5166 bRet = pRemoveFontMemResourceEx(ret);
5167 ok(bRet, "RemoveFontMemResourceEx error %d\n", GetLastError());
5168
5169 /* test invalid pointer to number of loaded fonts */
5170 font = load_font("sserife.fon", &font_size);
5171 ok(font != NULL, "Unable to locate and load font sserife.fon\n");
5172
5173 SetLastError(0xdeadbeef);
5174 ret = pAddFontMemResourceEx(font, font_size, NULL, (void *)0xdeadbeef);
5175 ok(!ret, "AddFontMemResourceEx should fail\n");
5176 ok(GetLastError() == 0xdeadbeef,
5177 "Expected GetLastError() to return 0xdeadbeef, got %u\n",
5178 GetLastError());
5179
5180 SetLastError(0xdeadbeef);
5181 ret = pAddFontMemResourceEx(font, font_size, NULL, NULL);
5182 ok(!ret, "AddFontMemResourceEx should fail\n");
5184 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
5185 GetLastError());
5186
5187 free_font(font);
5188}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static void * load_font(const char *font_name, DWORD *font_size)
Definition: font.c:5044
static void free_font(void *font)
Definition: font.c:5039

Referenced by START_TEST().

◆ test_bitmap_font()

static void test_bitmap_font ( void  )
static

Definition at line 401 of file font.c.

402{
403 static const char test_str[11] = "Test String";
404 HDC hdc;
405 LOGFONTA bitmap_lf;
406 HFONT hfont, old_hfont;
407 TEXTMETRICA tm_orig;
408 SIZE size_orig;
409 INT ret, i, width_orig, height_orig, scale, lfWidth;
410
412
413 /* "System" has only 1 pixel size defined, otherwise the test breaks */
414 ret = EnumFontFamiliesA(hdc, "System", font_enum_proc, (LPARAM)&bitmap_lf);
415 if (ret)
416 {
417 ReleaseDC(0, hdc);
418 trace("no bitmap fonts were found, skipping the test\n");
419 return;
420 }
421
422 trace("found bitmap font %s, height %d\n", bitmap_lf.lfFaceName, bitmap_lf.lfHeight);
423
424 height_orig = bitmap_lf.lfHeight;
425 lfWidth = bitmap_lf.lfWidth;
426
427 hfont = create_font("bitmap", &bitmap_lf);
428 old_hfont = SelectObject(hdc, hfont);
429 ok(GetTextMetricsA(hdc, &tm_orig), "GetTextMetricsA failed\n");
430 ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
431 ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
432 SelectObject(hdc, old_hfont);
434
435 bitmap_lf.lfHeight = 0;
436 bitmap_lf.lfWidth = 4;
437 hfont = create_font("bitmap", &bitmap_lf);
438 old_hfont = SelectObject(hdc, hfont);
439 test_font_metrics(hdc, hfont, 0, 4, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, 1);
440 SelectObject(hdc, old_hfont);
442
443 bitmap_lf.lfHeight = height_orig;
444 bitmap_lf.lfWidth = lfWidth;
445
446 /* test fractional scaling */
447 for (i = 1; i <= height_orig * 6; i++)
448 {
449 INT nearest_height;
450
451 bitmap_lf.lfHeight = i;
452 hfont = create_font("fractional", &bitmap_lf);
453 scale = (i + height_orig - 1) / height_orig;
454 nearest_height = scale * height_orig;
455 /* Only jump to the next height if the difference <= 25% original height */
456 if (scale > 2 && nearest_height - i > height_orig / 4) scale--;
457 /* The jump between unscaled and doubled is delayed by 1 in winnt+ but not in win9x,
458 so we'll not test this particular height. */
459 else if(scale == 2 && nearest_height - i == (height_orig / 4)) continue;
460 else if(scale == 2 && nearest_height - i > (height_orig / 4 - 1)) scale--;
461 old_hfont = SelectObject(hdc, hfont);
462 test_font_metrics(hdc, hfont, bitmap_lf.lfHeight, 0, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, scale);
463 SelectObject(hdc, old_hfont);
465 }
466
467 /* test integer scaling 3x2 */
468 bitmap_lf.lfHeight = height_orig * 2;
469 bitmap_lf.lfWidth *= 3;
470 hfont = create_font("3x2", &bitmap_lf);
471 old_hfont = SelectObject(hdc, hfont);
472 test_font_metrics(hdc, hfont, bitmap_lf.lfHeight, 0, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 2);
473 SelectObject(hdc, old_hfont);
475
476 /* test integer scaling 3x3 */
477 bitmap_lf.lfHeight = height_orig * 3;
478 bitmap_lf.lfWidth = 0;
479 hfont = create_font("3x3", &bitmap_lf);
480 old_hfont = SelectObject(hdc, hfont);
481 test_font_metrics(hdc, hfont, bitmap_lf.lfHeight, 0, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 3);
482 SelectObject(hdc, old_hfont);
484
485 DeleteDC(hdc);
486}
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
static HFONT create_font(const char *test, const LOGFONTA *lf)
Definition: font.c:237
static INT CALLBACK font_enum_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
Definition: font.c:273
static void test_font_metrics(void)
Definition: font.c:667
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
BOOL WINAPI GetCharWidthA(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)

Referenced by START_TEST().

◆ test_bitmap_font_glyph_index()

static void test_bitmap_font_glyph_index ( void  )
static

Definition at line 6629 of file font.c.

6630{
6631 const WCHAR text[] = {'#','!','/','b','i','n','/','s','h',0};
6632 const struct {
6633 LPCSTR face;
6634 BYTE charset;
6635 } bitmap_font_list[] = {
6636 { "Courier", ANSI_CHARSET },
6637 { "Small Fonts", ANSI_CHARSET },
6638 { "Fixedsys", DEFAULT_CHARSET },
6639 { "System", DEFAULT_CHARSET }
6640 };
6641 HDC hdc;
6642 LOGFONTA lf;
6643 HFONT hFont;
6644 CHAR facename[LF_FACESIZE];
6645 BITMAPINFO bmi;
6646 HBITMAP hBmp[2];
6647 void *pixels[2];
6648 int i, j;
6649 DWORD ret;
6650 BITMAP bmp;
6652 CHARSETINFO ci;
6653 BYTE chr = '\xA9';
6654
6655 if (!pGetGlyphIndicesW || !pGetGlyphIndicesA) {
6656 win_skip("GetGlyphIndices is unavailable\n");
6657 return;
6658 }
6659
6661 ok(hdc != NULL, "CreateCompatibleDC failed\n");
6662
6663 memset(&bmi, 0, sizeof(bmi));
6664 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
6665 bmi.bmiHeader.biBitCount = 32;
6666 bmi.bmiHeader.biPlanes = 1;
6667 bmi.bmiHeader.biWidth = 128;
6668 bmi.bmiHeader.biHeight = 32;
6670
6671 for (i = 0; i < sizeof(bitmap_font_list)/sizeof(bitmap_font_list[0]); i++) {
6672 memset(&lf, 0, sizeof(lf));
6673 lf.lfCharSet = bitmap_font_list[i].charset;
6674 strcpy(lf.lfFaceName, bitmap_font_list[i].face);
6676 ok(hFont != NULL, "Can't create font (%s:%d)\n", lf.lfFaceName, lf.lfCharSet);
6679 ok(ret, "GetTextMetric failed\n");
6680 ret = GetTextFaceA(hdc, sizeof(facename), facename);
6681 ok(ret, "GetTextFace failed\n");
6682 if (tm.tmPitchAndFamily & TMPF_TRUETYPE) {
6683 skip("TrueType font (%s) was selected for \"%s\"\n", facename, bitmap_font_list[i].face);
6684 continue;
6685 }
6686 if (lstrcmpiA(facename, lf.lfFaceName) != 0) {
6687 skip("expected %s, got %s\n", lf.lfFaceName, facename);
6688 continue;
6689 }
6690
6691 for (j = 0; j < 2; j++) {
6692 HBITMAP hBmpPrev;
6693 hBmp[j] = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &pixels[j], NULL, 0);
6694 ok(hBmp[j] != NULL, "Can't create DIB\n");
6695 hBmpPrev = SelectObject(hdc, hBmp[j]);
6696 switch (j) {
6697 case 0:
6698 ret = ExtTextOutW(hdc, 0, 0, 0, NULL, text, lstrlenW(text), NULL);
6699 break;
6700 case 1:
6701 {
6702 int len = lstrlenW(text);
6703 LPWORD indices = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WORD));
6704 ret = pGetGlyphIndicesW(hdc, text, len, indices, 0);
6705 ok(ret, "GetGlyphIndices failed\n");
6706 ok(memcmp(indices, text, sizeof(WORD) * len) == 0,
6707 "Glyph indices and text are different for %s:%d\n", lf.lfFaceName, tm.tmCharSet);
6708 ret = ExtTextOutW(hdc, 0, 0, ETO_GLYPH_INDEX, NULL, indices, len, NULL);
6710 break;
6711 }
6712 }
6713 ok(ret, "ExtTextOutW failed\n");
6714 SelectObject(hdc, hBmpPrev);
6715 }
6716
6717 GetObjectA(hBmp[0], sizeof(bmp), &bmp);
6718 ok(memcmp(pixels[0], pixels[1], bmp.bmHeight * bmp.bmWidthBytes) == 0,
6719 "Images are different (%s:%d)\n", lf.lfFaceName, tm.tmCharSet);
6720
6722 if (!ret) {
6723 skip("Can't get charset info for (%s:%d)\n", lf.lfFaceName, tm.tmCharSet);
6724 goto next;
6725 }
6726 if (IsDBCSLeadByteEx(ci.ciACP, chr)) {
6727 skip("High-ascii character is not defined in codepage %d\n", ci.ciACP);
6728 goto next;
6729 }
6730
6731 for (j = 0; j < 2; j++) {
6732 HBITMAP hBmpPrev;
6733 WORD code;
6734 hBmpPrev = SelectObject(hdc, hBmp[j]);
6735 switch (j) {
6736 case 0:
6737 ret = ExtTextOutA(hdc, 100, 0, 0, NULL, (LPCSTR)&chr, 1, NULL);
6738 break;
6739 case 1:
6740 ret = pGetGlyphIndicesA(hdc, (LPCSTR)&chr, 1, &code, 0);
6741 ok(ret, "GetGlyphIndices failed\n");
6742 ok(code == chr, "expected %02x, got %02x (%s:%d)\n", chr, code, lf.lfFaceName, tm.tmCharSet);
6743 ret = ExtTextOutA(hdc, 100, 0, ETO_GLYPH_INDEX, NULL, (LPCSTR)&code, 1, NULL);
6744 break;
6745 }
6746 ok(ret, "ExtTextOutA failed\n");
6747 SelectObject(hdc, hBmpPrev);
6748 }
6749
6750 ok(memcmp(pixels[0], pixels[1], bmp.bmHeight * bmp.bmWidthBytes) == 0,
6751 "Images are different (%s:%d)\n", lf.lfFaceName, tm.tmCharSet);
6752 next:
6753 for (j = 0; j < 2; j++)
6754 DeleteObject(hBmp[j]);
6757 }
6758
6759 DeleteDC(hdc);
6760}
HFONT hFont
Definition: main.c:53
WORD face[3]
Definition: mesh.c:4747
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2337
const WCHAR * text
Definition: package.c:1799
#define BI_RGB
Definition: precomp.h:47
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
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 GLint GLint j
Definition: glfuncs.h:250
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
BITMAP bmp
Definition: alphablend.c:62
static HBITMAP
Definition: button.c:44
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: bl.h:1331
USHORT biBitCount
Definition: precomp.h:37
ULONG biCompression
Definition: precomp.h:38
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint16_t * LPWORD
Definition: typedefs.h:56
uint32_t * LPDWORD
Definition: typedefs.h:59
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
BOOL WINAPI ExtTextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_bitmap_font_metrics()

static void test_bitmap_font_metrics ( void  )
static

Definition at line 757 of file font.c.

758{
759 static const WORD skip_rtl[] = {LANG_ARABIC, LANG_HEBREW, 0};
760 static const struct font_data
761 {
762 const char face_name[LF_FACESIZE];
764 int ave_char_width, max_char_width, dpi;
765 BYTE first_char, last_char, def_char, break_char;
766 DWORD ansi_bitfield;
767 const WORD *skip_lang_id;
768 int scaled_height;
769 } fd[] =
770 {
771 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
772 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
773 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
774 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
775 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
776 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
777 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
778 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
779 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 16 },
780 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
781
782 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
783 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
784 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
785 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
786 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
787 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
788 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
789 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
790 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
791 { "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
792
793 { "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
794 { "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
795 { "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
796 { "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
797 { "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 16, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
798 { "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN2 },
799 { "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 16, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
800 { "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 19, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
801 { "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 24, 96, 0x20, 0xff, 0x81, 0x40, FS_LATIN2 },
802 { "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 20, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
803 { "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 24, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
804 { "MS Sans Serif", FW_NORMAL, 29, 23, 6, 6, 0, 12, 24, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN2 },
805 { "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 25, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
806 { "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
807 { "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32, 96, 0x20, 0xff, 0x81, 0x40, FS_LATIN2 },
808 { "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
809
810 { "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
811 { "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
812 { "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
813 { "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 17, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
814 { "MS Sans Serif", FW_NORMAL, 25, 20, 5, 5, 0, 10, 21, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
815 { "MS Sans Serif", FW_NORMAL, 25, 20, 5, 5, 0, 10, 21, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
816 { "MS Sans Serif", FW_NORMAL, 29, 23, 6, 6, 0, 12, 24, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
817 { "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 24, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
818 { "MS Sans Serif", FW_NORMAL, 36, 29, 7, 6, 0, 15, 30, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
819 { "MS Sans Serif", FW_NORMAL, 36, 29, 7, 6, 0, 15, 30, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
820 { "MS Sans Serif", FW_NORMAL, 46, 37, 9, 6, 0, 20, 40, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
821 { "MS Sans Serif", FW_NORMAL, 46, 37, 9, 6, 0, 20, 40, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
822
823 { "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
824 { "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
825 { "MS Serif", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
826 { "MS Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
827 { "MS Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 12, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
828 { "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 14, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
829 { "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 16, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
830 { "MS Serif", FW_NORMAL, 19, 15, 4, 3, 0, 8, 18, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
831 { "MS Serif", FW_NORMAL, 19, 15, 4, 3, 0, 8, 19, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
832 { "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 17, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
833 { "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 22, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
834 { "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 23, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
835 { "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 23, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
836 { "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 26, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
837 { "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 27, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
838 { "MS Serif", FW_NORMAL, 35, 27, 8, 3, 0, 16, 33, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
839 { "MS Serif", FW_NORMAL, 35, 27, 8, 3, 0, 16, 34, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
840
841 { "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 14, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_CYRILLIC },
842 { "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 13, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
843 { "MS Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_CYRILLIC },
844 { "MS Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 15, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
845 { "MS Serif", FW_NORMAL, 23, 18, 5, 3, 0, 10, 21, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_CYRILLIC },
846 { "MS Serif", FW_NORMAL, 23, 18, 5, 3, 0, 10, 19, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
847 { "MS Serif", FW_NORMAL, 27, 21, 6, 4, 0, 12, 23, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
848 { "MS Serif", FW_MEDIUM, 27, 22, 5, 2, 0, 12, 30, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
849 { "MS Serif", FW_NORMAL, 33, 26, 7, 3, 0, 14, 30, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
850 { "MS Serif", FW_MEDIUM, 32, 25, 7, 2, 0, 14, 32, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
851 { "MS Serif", FW_NORMAL, 43, 34, 9, 3, 0, 19, 39, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
852
853 { "Courier", FW_NORMAL, 13, 11, 2, 0, 0, 8, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
854 { "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
855 { "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
856
857 { "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
858 { "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
859 { "Courier", FW_NORMAL, 25, 20, 5, 0, 0, 15, 15, 120, 0x20, 0xff, 0x40, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
860
861 { "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
862 { "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 15, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
863 { "System", FW_NORMAL, 18, 16, 2, 0, 2, 8, 16, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
864
865 { "System", FW_BOLD, 20, 16, 4, 4, 0, 9, 14, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
866 { "System", FW_BOLD, 20, 16, 4, 4, 0, 9, 17, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
867
868 { "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 2, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
869 { "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
870 { "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 2, 4, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
871 { "Small Fonts", FW_NORMAL, 5, 4, 1, 1, 0, 3, 4, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1, skip_rtl},
872 { "Small Fonts", FW_NORMAL, 5, 4, 1, 1, 0, 2, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
873 { "Small Fonts", FW_NORMAL, 5, 4, 1, 0, 0, 3, 6, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
874 { "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 13, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1, skip_rtl},
875 { "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
876 { "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 8, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
877 { "Small Fonts", FW_NORMAL, 6, 5, 1, 0, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
878 { "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 7, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1, skip_rtl},
879 { "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
880 { "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 8, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
881 { "Small Fonts", FW_NORMAL, 8, 7, 1, 0, 0, 5, 10, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
882 { "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl},
883 { "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
884 { "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 4, 9, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
885 { "Small Fonts", FW_NORMAL, 10, 8, 2, 0, 0, 6, 12, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
886 { "Small Fonts", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC, skip_rtl},
887 { "Small Fonts", FW_NORMAL, 11, 9, 2, 2, 0, 4, 10, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
888 { "Small Fonts", FW_NORMAL, 11, 9, 2, 0, 0, 7, 14, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
889
890 { "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 2, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_JISJAPAN },
891 { "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
892 { "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 5, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_JISJAPAN },
893 { "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
894 { "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 7, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_JISJAPAN },
895 { "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
896 { "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 5, 9, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_JISJAPAN },
897 { "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
898 { "Small Fonts", FW_NORMAL, 12, 10, 2, 2, 0, 5, 10, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_JISJAPAN },
899 { "Small Fonts", FW_NORMAL, 12, 10, 2, 2, 0, 6, 10, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
900 { "Small Fonts", FW_NORMAL, 13, 11, 2, 2, 0, 6, 12, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_JISJAPAN },
901 { "Small Fonts", FW_NORMAL, 13, 11, 2, 2, 0, 6, 11, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
902
903 { "Fixedsys", FW_NORMAL, 15, 12, 3, 3, 0, 8, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
904 { "Fixedsys", FW_NORMAL, 16, 12, 4, 3, 0, 8, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
905 { "FixedSys", FW_NORMAL, 18, 16, 2, 0, 0, 8, 16, 96, 0x20, 0xff, 0xa0, 0x20, FS_JISJAPAN },
906
907 { "Fixedsys", FW_NORMAL, 20, 16, 4, 2, 0, 10, 10, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC }
908
909 /* FIXME: add "Terminal" */
910 };
911 static const int font_log_pixels[] = { 96, 120 };
912 HDC hdc;
913 LOGFONTA lf;
914 HFONT hfont, old_hfont;
916 INT ret, i, expected_cs, screen_log_pixels, diff, font_res;
917 char face_name[LF_FACESIZE];
918 CHARSETINFO csi;
919
920 trace("system language id %04x\n", system_lang_id);
921
922 expected_cs = GetACP();
923 if (!TranslateCharsetInfo(ULongToPtr(expected_cs), &csi, TCI_SRCCODEPAGE))
924 {
925 skip("TranslateCharsetInfo failed for code page %d\n", expected_cs);
926 return;
927 }
928 expected_cs = csi.ciCharset;
929 trace("ACP %d -> charset %d\n", GetACP(), expected_cs);
930
932 ok(hdc != NULL, "failed to create hdc\n");
933
934 trace("logpixelsX %d, logpixelsY %d\n", GetDeviceCaps(hdc, LOGPIXELSX),
936
937 screen_log_pixels = GetDeviceCaps(hdc, LOGPIXELSY);
938 diff = 32768;
939 font_res = 0;
940 for (i = 0; i < sizeof(font_log_pixels)/sizeof(font_log_pixels[0]); i++)
941 {
942 int new_diff = abs(font_log_pixels[i] - screen_log_pixels);
943 if (new_diff < diff)
944 {
945 diff = new_diff;
946 font_res = font_log_pixels[i];
947 }
948 }
949 trace("best font resolution is %d\n", font_res);
950
951 for (i = 0; i < sizeof(fd)/sizeof(fd[0]); i++)
952 {
953 int bit, height;
954
955 memset(&lf, 0, sizeof(lf));
956
957 height = fd[i].height & ~FH_SCALE;
958 lf.lfHeight = height;
959 strcpy(lf.lfFaceName, fd[i].face_name);
960
961 for(bit = 0; bit < 32; bit++)
962 {
963 GLYPHMETRICS gm;
964 DWORD fs[2];
965 BOOL bRet;
966
967 fs[0] = 1L << bit;
968 fs[1] = 0;
969 if((fd[i].ansi_bitfield & fs[0]) == 0) continue;
970 if(!TranslateCharsetInfo( fs, &csi, TCI_SRCFONTSIG )) continue;
971
972 lf.lfCharSet = csi.ciCharset;
974 if (fd[i].height & FH_SCALE)
975 ok(ret, "scaled font height %d should not be enumerated\n", height);
976 else
977 {
978 if (font_res == fd[i].dpi && lf.lfCharSet == expected_cs)
979 {
980 todo_wine_if (ret) /* FIXME: Remove once Wine is fixed */
981 ok(!ret, "%s height %d charset %d dpi %d should be enumerated\n", lf.lfFaceName, lf.lfHeight, lf.lfCharSet, fd[i].dpi);
982 }
983 }
984 if (ret && !(fd[i].height & FH_SCALE))
985 continue;
986
987 hfont = create_font(lf.lfFaceName, &lf);
988 old_hfont = SelectObject(hdc, hfont);
989
990 SetLastError(0xdeadbeef);
991 ret = GetTextFaceA(hdc, sizeof(face_name), face_name);
992 ok(ret, "GetTextFace error %u\n", GetLastError());
993
994 if (strcmp(face_name, fd[i].face_name) != 0)
995 {
996 ok(ret != ANSI_CHARSET, "font charset should not be ANSI_CHARSET\n");
997 ok(ret != expected_cs, "font charset %d should not be %d\n", ret, expected_cs);
998 SelectObject(hdc, old_hfont);
1000 continue;
1001 }
1002
1003 memset(&gm, 0, sizeof(gm));
1004 SetLastError(0xdeadbeef);
1005 ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
1006 todo_wine {
1007 ok(ret == GDI_ERROR, "GetGlyphOutline should fail for a bitmap font\n");
1008 ok(GetLastError() == ERROR_CAN_NOT_COMPLETE, "expected ERROR_CAN_NOT_COMPLETE, got %u\n", GetLastError());
1009 }
1010
1011 bRet = GetTextMetricsA(hdc, &tm);
1012 ok(bRet, "GetTextMetrics error %d\n", GetLastError());
1013
1014 SetLastError(0xdeadbeef);
1016 if (is_CJK() && lf.lfCharSet == ANSI_CHARSET)
1017 ok(ret == ANSI_CHARSET, "got charset %d, expected ANSI_CHARSETd\n", ret);
1018 else
1019 ok(ret == expected_cs, "got charset %d, expected %d\n", ret, expected_cs);
1020
1021 trace("created %s, height %d charset %x dpi %d\n", face_name, tm.tmHeight, tm.tmCharSet, tm.tmDigitizedAspectX);
1022 trace("expected %s, height %d scaled_height %d, dpi %d\n", fd[i].face_name, height, fd[i].scaled_height, fd[i].dpi);
1023
1024 if(fd[i].dpi == tm.tmDigitizedAspectX)
1025 {
1026 int skipme = 0;
1027 trace("matched %s, height %d charset %x dpi %d\n", lf.lfFaceName, lf.lfHeight, lf.lfCharSet, fd[i].dpi);
1028 if (fd[i].skip_lang_id)
1029 {
1030 int si = 0;
1031 skipme = 0;
1032 while(!skipme && fd[i].skip_lang_id[si])
1033 if (fd[i].skip_lang_id[si++] == system_lang_id)
1034 skipme = 1;
1035 }
1036 if (!skipme)
1037 {
1038 ok(tm.tmWeight == fd[i].weight, "%s(%d): tm.tmWeight %d != %d\n", fd[i].face_name, height, tm.tmWeight, fd[i].weight);
1039 if (fd[i].height & FH_SCALE)
1040 ok(tm.tmHeight == fd[i].scaled_height, "%s(%d): tm.tmHeight %d != %d\n", fd[i].face_name, height, tm.tmHeight, fd[i].scaled_height);
1041 else
1042 ok(tm.tmHeight == fd[i].height, "%s(%d): tm.tmHeight %d != %d\n", fd[i].face_name, fd[i].height, tm.tmHeight, fd[i].height);
1043 ok(tm.tmAscent == fd[i].ascent, "%s(%d): tm.tmAscent %d != %d\n", fd[i].face_name, height, tm.tmAscent, fd[i].ascent);
1044 ok(tm.tmDescent == fd[i].descent, "%s(%d): tm.tmDescent %d != %d\n", fd[i].face_name, height, tm.tmDescent, fd[i].descent);
1045 ok(tm.tmInternalLeading == fd[i].int_leading, "%s(%d): tm.tmInternalLeading %d != %d\n", fd[i].face_name, height, tm.tmInternalLeading, fd[i].int_leading);
1046 ok(tm.tmExternalLeading == fd[i].ext_leading, "%s(%d): tm.tmExternalLeading %d != %d\n", fd[i].face_name, height, tm.tmExternalLeading, fd[i].ext_leading);
1047 ok(tm.tmAveCharWidth == fd[i].ave_char_width, "%s(%d): tm.tmAveCharWidth %d != %d\n", fd[i].face_name, height, tm.tmAveCharWidth, fd[i].ave_char_width);
1048 ok(tm.tmFirstChar == fd[i].first_char, "%s(%d): tm.tmFirstChar = %02x\n", fd[i].face_name, height, tm.tmFirstChar);
1049 ok(tm.tmLastChar == fd[i].last_char, "%s(%d): tm.tmLastChar = %02x\n", fd[i].face_name, height, tm.tmLastChar);
1050 /* Substitutions like MS Sans Serif,0=MS Sans Serif,204
1051 make default char test fail */
1052 if (tm.tmCharSet == lf.lfCharSet)
1053 ok(tm.tmDefaultChar == fd[i].def_char, "%s(%d): tm.tmDefaultChar = %02x\n", fd[i].face_name, height, tm.tmDefaultChar);
1054 ok(tm.tmBreakChar == fd[i].break_char, "%s(%d): tm.tmBreakChar = %02x\n", fd[i].face_name, height, tm.tmBreakChar);
1055 ok(tm.tmCharSet == expected_cs || tm.tmCharSet == ANSI_CHARSET, "%s(%d): tm.tmCharSet %d != %d\n", fd[i].face_name, height, tm.tmCharSet, expected_cs);
1056
1057 /* Don't run the max char width test on System/ANSI_CHARSET. We have extra characters in our font
1058 that make the max width bigger */
1059 if ((strcmp(lf.lfFaceName, "System") || lf.lfCharSet != ANSI_CHARSET) && tm.tmDigitizedAspectX == 96)
1060 ok(tm.tmMaxCharWidth == fd[i].max_char_width, "%s(%d): tm.tmMaxCharWidth %d != %d\n", fd[i].face_name, height, tm.tmMaxCharWidth, fd[i].max_char_width);
1061 }
1062 else
1063 skip("Skipping font metrics test for system langid 0x%x\n",
1065 }
1066 SelectObject(hdc, old_hfont);
1068 }
1069 }
1070
1071 DeleteDC(hdc);
1072}
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
Definition: font.c:739
#define FH_SCALE
Definition: font.c:756
static BOOL is_CJK(void)
Definition: font.c:751
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define todo_wine
Definition: custom.c:79
LONG last_char
Definition: input.c:71
#define LANG_HEBREW
Definition: nls.h:67
#define LANG_ARABIC
Definition: nls.h:29
static int fd
Definition: io.c:51
int weight
Definition: font.c:1895
int dpi
Definition: font.c:1895
int descent
Definition: font.c:1895
int int_leading
Definition: font.c:1895
int height
Definition: font.c:1895
int ext_leading
Definition: font.c:1895
const char face_name[LF_FACESIZE]
Definition: font.c:1893