1 typedef struct HDC__
{ int unused
; } *HDC
;
2 typedef struct HFONT__
{ int unused
; } *HFONT
;
4 void* HeapAlloc(void*,unsigned int,unsigned long);
6 typedef struct tagLOGFONTW
9 unsigned short lfFaceName
[32];
10 } LOGFONTW
, *PLOGFONTW
, *LPLOGFONTW
;
12 typedef struct tagGdiFont GdiFont
;
13 typedef struct tagDC DC
;
15 extern unsigned int WineEngGetFontData(GdiFont
*, unsigned int, unsigned int, void*, unsigned int);
23 typedef struct FT_FaceRec_
25 signed long face_flags
;
26 } FT_FaceRec
, *FT_Face
;
28 typedef struct { } GM
;
30 typedef struct { } FMAT2
;
40 typedef struct tagHFONTLIST
{
55 struct list hfontlist
;
56 struct list child_fonts
;
65 static struct list gdi_font_list
= { &(gdi_font_list
), &(gdi_font_list
) };
70 static int get_glyph_index_linked(GdiFont
*font
, unsigned int c
, GdiFont
**linked_font
, unsigned int *glyph
);
71 static long load_VDMX(GdiFont
*, long);
73 extern int f1(void*,int);
75 static FT_Face
OpenFontFace(GdiFont
*font
, void *face
, long width
, long height
)
79 font
->ppem
= load_VDMX(font
, height
);
81 font
->ppem
= f1(ft_face
, height
);
86 static GdiFont
*alloc_font(void)
88 GdiFont
*ret
= HeapAlloc(0, 0x00000008, sizeof(*ret
));
89 ret
->gm
= HeapAlloc(0, 0x00000008, sizeof(GM
*));
94 static long load_VDMX(GdiFont
*font
,long height
)
96 unsigned short hdr
[3];
98 WineEngGetFontData(font
, 0x42424242, 0, hdr
, 6);
102 static int fontcmp(const GdiFont
*font
, FONT_DESC
*fd
)
104 if(font
->font_desc
.hash
!= fd
->hash
) return 1;
105 if(memcmp(&font
->font_desc
.lf
, &fd
->lf
, __builtin_offsetof (LOGFONTW
, lfFaceName
))) return 1;
106 if(!font
->font_desc
.can_use_bitmap
!= !fd
->can_use_bitmap
) return 1;
107 return strcmpiW(font
->font_desc
.lf
.lfFaceName
, fd
->lf
.lfFaceName
);
110 static GdiFont
*find_in_cache(HFONT hfont
, const LOGFONTW
*plf
, const FMAT2
*pmat
, int can_use_bitmap
)
115 struct list
*font_elem_ptr
, *hfontlist_elem_ptr
;
118 fd
.can_use_bitmap
= can_use_bitmap
;
121 for ((font_elem_ptr
) = (&gdi_font_list
)->next
; (font_elem_ptr
) != (&gdi_font_list
); (font_elem_ptr
) = (font_elem_ptr
)->next
) {
122 ret
= ((struct tagGdiFont
*)((char *)(font_elem_ptr
) - (unsigned long)(&((struct tagGdiFont
*)0)->entry
)));
123 if(!fontcmp(ret
, &fd
)) {
124 if(!can_use_bitmap
&& !( ret
->ft_face
->face_flags
& ( 1L << 0 ) )) continue;
125 for ((hfontlist_elem_ptr
) = (&ret
->hfontlist
)->next
; (hfontlist_elem_ptr
) != (&ret
->hfontlist
); (hfontlist_elem_ptr
) = (hfontlist_elem_ptr
)->next
) {
126 hflist
= ((struct tagHFONTLIST
*)((char *)(hfontlist_elem_ptr
) - (unsigned long)(&((struct tagHFONTLIST
*)0)->entry
)));
127 if(hflist
->hfont
== hfont
)
130 hflist
= HeapAlloc(0, 0, sizeof(*hflist
));
131 hflist
->hfont
= hfont
;
136 while(font_elem_ptr
) {
137 ret
= ((struct tagGdiFont
*)((char *)(font_elem_ptr
) - (unsigned long)(&((struct tagGdiFont
*)0)->entry
)));
138 if(!fontcmp(ret
, &fd
)) {
139 if(!can_use_bitmap
&& !( ret
->ft_face
->face_flags
& ( 1L << 0 ) )) continue;
140 hflist
= HeapAlloc(0, 0, sizeof(*hflist
));
141 hflist
->hfont
= hfont
;
151 GdiFont
*WineEngCreateFontInstance(DC
*dc
, HFONT hfont
)
158 if((ret
= find_in_cache(hfont
, &lf
, &dcmat
, can_use_bitmap
)) != ((void *)0))
163 extern unsigned int f(void*,unsigned int g
);
165 static unsigned int get_glyph_index(void*font
, unsigned int glyph
)
167 return f(font
, glyph
);
170 unsigned int WineEngGetGlyphOutline(GdiFont
*incoming_font
, unsigned int glyph
, unsigned int format
,
171 void* lpgm
, unsigned int buflen
, void* buf
,
174 unsigned int glyph_index
;
176 get_glyph_index_linked(incoming_font
, glyph
, &incoming_font
, &glyph_index
);
180 static int load_child_font(GdiFont
*font
, CHILD_FONT
*child
)
182 child
->font
= alloc_font();
183 child
->font
->ft_face
= OpenFontFace(child
->font
, child
->face
, 0, -font
->ppem
);
184 if(!child
->font
->ft_face
)
189 static int get_glyph_index_linked(GdiFont
*font
, unsigned int c
, GdiFont
**linked_font
, unsigned int *glyph
)
192 CHILD_FONT
*child_font
;
194 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
))))
196 if(!load_child_font(font
, child_font
))
199 g
= get_glyph_index(child_font
->font
, c
);
202 *linked_font
= child_font
->font
;
209 unsigned int WineEngGetFontData(GdiFont
*font
, unsigned int table
, unsigned int offset
, void* buf
,
213 load_sfnt_table(font
->ft_face
, table
, offset
, buf
, &len
);
217 int WineEngGetLinkedHFont(DC
*dc
, unsigned short c
, HFONT
*new_hfont
, unsigned int *glyph
) {
218 return get_glyph_index_linked(0, 0, 0, 0);