1 /* { dg-xfail-if "cast to pointer of different size" { "avr-*-*" } { "*" } { "" } } */
2 typedef struct HDC__ { int unused; } *HDC;
3 typedef struct HFONT__ { int unused; } *HFONT;
5 void* HeapAlloc(void*,unsigned int,unsigned long);
7 typedef struct tagLOGFONTW
10 unsigned short lfFaceName[32];
11 } LOGFONTW, *PLOGFONTW, *LPLOGFONTW;
13 typedef struct tagGdiFont GdiFont;
14 typedef struct tagDC DC;
16 extern unsigned int WineEngGetFontData(GdiFont*, unsigned int, unsigned int, void*, unsigned int);
24 typedef struct FT_FaceRec_
26 signed long face_flags;
27 } FT_FaceRec, *FT_Face;
29 typedef struct { } GM;
31 typedef struct { } FMAT2;
41 typedef struct tagHFONTLIST {
56 struct list hfontlist;
57 struct list child_fonts;
66 static struct list gdi_font_list = { &(gdi_font_list), &(gdi_font_list) };
71 static int get_glyph_index_linked(GdiFont *font, unsigned int c, GdiFont **linked_font, unsigned int *glyph);
72 static long load_VDMX(GdiFont*, long);
74 extern int f1(void*,int);
76 static FT_Face OpenFontFace(GdiFont *font, void *face, long width, long height)
80 font->ppem = load_VDMX(font, height);
82 font->ppem = f1(ft_face, height);
87 static GdiFont *alloc_font(void)
89 GdiFont *ret = HeapAlloc(0, 0x00000008, sizeof(*ret));
90 ret->gm = HeapAlloc(0, 0x00000008, sizeof(GM*));
95 static long load_VDMX(GdiFont *font,long height)
97 unsigned short hdr[3];
99 WineEngGetFontData(font, 0x42424242, 0, hdr, 6);
103 static int fontcmp(const GdiFont *font, FONT_DESC *fd)
105 if(font->font_desc.hash != fd->hash) return 1;
106 if(memcmp(&font->font_desc.lf, &fd->lf, __builtin_offsetof (LOGFONTW, lfFaceName))) return 1;
107 if(!font->font_desc.can_use_bitmap != !fd->can_use_bitmap) return 1;
108 return strcmpiW(font->font_desc.lf.lfFaceName, fd->lf.lfFaceName);
111 static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pmat, int can_use_bitmap)
116 struct list *font_elem_ptr, *hfontlist_elem_ptr;
119 fd.can_use_bitmap = can_use_bitmap;
122 for ((font_elem_ptr) = (&gdi_font_list)->next; (font_elem_ptr) != (&gdi_font_list); (font_elem_ptr) = (font_elem_ptr)->next) {
123 ret = ((struct tagGdiFont *)((char *)(font_elem_ptr) - (unsigned long)(&((struct tagGdiFont *)0)->entry)));
124 if(!fontcmp(ret, &fd)) {
125 if(!can_use_bitmap && !( ret->ft_face->face_flags & ( 1L << 0 ) )) continue;
126 for ((hfontlist_elem_ptr) = (&ret->hfontlist)->next; (hfontlist_elem_ptr) != (&ret->hfontlist); (hfontlist_elem_ptr) = (hfontlist_elem_ptr)->next) {
127 hflist = ((struct tagHFONTLIST *)((char *)(hfontlist_elem_ptr) - (unsigned long)(&((struct tagHFONTLIST *)0)->entry)));
128 if(hflist->hfont == hfont)
131 hflist = HeapAlloc(0, 0, sizeof(*hflist));
132 hflist->hfont = hfont;
137 while(font_elem_ptr) {
138 ret = ((struct tagGdiFont *)((char *)(font_elem_ptr) - (unsigned long)(&((struct tagGdiFont *)0)->entry)));
139 if(!fontcmp(ret, &fd)) {
140 if(!can_use_bitmap && !( ret->ft_face->face_flags & ( 1L << 0 ) )) continue;
141 hflist = HeapAlloc(0, 0, sizeof(*hflist));
142 hflist->hfont = hfont;
152 GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
159 if((ret = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != ((void *)0))
164 extern unsigned int f(void*,unsigned int g);
166 static unsigned int get_glyph_index(void*font, unsigned int glyph)
168 return f(font, glyph);
171 unsigned int WineEngGetGlyphOutline(GdiFont *incoming_font, unsigned int glyph, unsigned int format,
172 void* lpgm, unsigned int buflen, void* buf,
175 unsigned int glyph_index;
177 get_glyph_index_linked(incoming_font, glyph, &incoming_font, &glyph_index);
181 static int load_child_font(GdiFont *font, CHILD_FONT *child)
183 child->font = alloc_font();
184 child->font->ft_face = OpenFontFace(child->font, child->face, 0, -font->ppem);
185 if(!child->font->ft_face)
190 static int get_glyph_index_linked(GdiFont *font, unsigned int c, GdiFont **linked_font, unsigned int *glyph)
193 CHILD_FONT *child_font;
195 for ((child_font) = ((CHILD_FONT *)((char *)((&font->child_fonts)->next) - (unsigned long)(&((CHILD_FONT *)0)->entry))); &(child_font)->entry != (&font->child_fonts); (child_font) = ((CHILD_FONT *)((char *)((child_font)->entry.next) - (unsigned long)(&((CHILD_FONT *)0)->entry))))
197 if(!load_child_font(font, child_font))
200 g = get_glyph_index(child_font->font, c);
203 *linked_font = child_font->font;
210 unsigned int WineEngGetFontData(GdiFont *font, unsigned int table, unsigned int offset, void* buf,
214 load_sfnt_table(font->ft_face, table, offset, buf, &len);
218 int WineEngGetLinkedHFont(DC *dc, unsigned short c, HFONT *new_hfont, unsigned int *glyph) {
219 return get_glyph_index_linked(0, 0, 0, 0);