4 * Copyright 2009 Massimo Del Fedele
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv
);
31 /* prints out some info about face */
32 void PrintFaceInfo(FT_Face face
)
36 fprintf(stderr
, "----------------------------------------------------------\n");
37 fprintf(stderr
, "Family name :%s\n", face
->family_name
);
38 fprintf(stderr
, "Style name :%s\n", face
->style_name
);
39 fprintf(stderr
, "Num fixed sizes : %d\n", face
->num_fixed_sizes
);
40 if(face
->num_fixed_sizes
)
42 fprintf(stderr
, "Fixed sizes :");
43 for(i
= 0; i
< face
->num_fixed_sizes
; i
++)
44 fprintf(stderr
, " (%d, %d)", face
->available_sizes
[i
].width
, face
->available_sizes
[i
].height
);
45 fprintf(stderr
, "\n");
47 fprintf(stderr
, "Face flags: ");
48 if(face
->face_flags
& FT_FACE_FLAG_SCALABLE
) fprintf(stderr
, "FT_FACE_FLAG_SCALABLE ");
49 if(face
->face_flags
& FT_FACE_FLAG_FIXED_SIZES
) fprintf(stderr
, "FT_FACE_FLAG_FIXED_SIZES ");
50 if(face
->face_flags
& FT_FACE_FLAG_FIXED_WIDTH
) fprintf(stderr
, "FT_FACE_FLAG_FIXED_WIDTH ");
51 if(face
->face_flags
& FT_FACE_FLAG_SFNT
) fprintf(stderr
, "FT_FACE_FLAG_SFNT ");
52 if(face
->face_flags
& FT_FACE_FLAG_HORIZONTAL
) fprintf(stderr
, "FT_FACE_FLAG_HORIZONTAL ");
53 if(face
->face_flags
& FT_FACE_FLAG_VERTICAL
) fprintf(stderr
, "FT_FACE_FLAG_VERTICAL ");
54 if(face
->face_flags
& FT_FACE_FLAG_KERNING
) fprintf(stderr
, "FT_FACE_FLAG_KERNING ");
55 if(face
->face_flags
& FT_FACE_FLAG_FAST_GLYPHS
) fprintf(stderr
, "FT_FACE_FLAG_FAST_GLYPHS ");
56 if(face
->face_flags
& FT_FACE_FLAG_MULTIPLE_MASTERS
) fprintf(stderr
, "FT_FACE_FLAG_MULTIPLE_MASTERS ");
57 if(face
->face_flags
& FT_FACE_FLAG_GLYPH_NAMES
) fprintf(stderr
, "FT_FACE_FLAG_GLYPH_NAMES ");
58 if(face
->face_flags
& FT_FACE_FLAG_EXTERNAL_STREAM
) fprintf(stderr
, "FT_FACE_FLAG_EXTERNAL_STREAM ");
59 if(face
->face_flags
& FT_FACE_FLAG_HINTER
) fprintf(stderr
, "FT_FACE_FLAG_HINTER ");
60 if(face
->face_flags
& FT_FACE_FLAG_CID_KEYED
) fprintf(stderr
, "FT_FACE_FLAG_CID_KEYED ");
61 if(face
->face_flags
& FT_FACE_FLAG_TRICKY
) fprintf(stderr
, "FT_FACE_FLAG_TRICKY ");
62 fprintf(stderr
, "\n");
64 fprintf(stderr
, "Style flags: ");
65 if(face
->style_flags
& FT_STYLE_FLAG_ITALIC
) fprintf(stderr
, "FT_STYLE_FLAG_ITALIC ");
66 if(face
->style_flags
& FT_STYLE_FLAG_BOLD
) fprintf(stderr
, "FT_STYLE_FLAG_BOLD ");
67 fprintf(stderr
, "\n");
68 fprintf(stderr
, "----------------------------------------------------------\n");
73 /**********************************************************************
76 COLORREF
DIBDRV_SetTextColor( DIBDRVPHYSDEV
*physDev
, COLORREF color
)
80 MAYBE(TRACE("physDev:%p, color:%08x\n", physDev
, color
));
84 /* DIB section selected in, use DIB Engine */
86 /* do nothing if color is the same as actual one */
87 if(color
== physDev
->textColor
)
90 /* stores old color and sets new one */
91 res
= physDev
->textColor
;
92 physDev
->textColor
= color
;
94 #ifdef DIBDRV_ANTIALIASED_FONTS
95 /* fills the text color table used on antialiased font display */
96 if(physDev
->physBitmap
->funcs
)
101 r
= GetRValue(color
);
102 g
= GetGValue(color
);
103 b
= GetBValue(color
);
104 for(i
= 0; i
< 256; i
++)
106 physDev
->textColorTable
[i
] = physDev
->physBitmap
->funcs
->ColorToPixel(physDev
->physBitmap
, RGB(
115 /* returns previous text color */
120 /* DDB selected in, use X11 driver */
121 res
= _DIBDRV_GetDisplayDriver()->pSetTextColor(physDev
->X11PhysDev
, color
);
126 /***********************************************************************
129 HFONT
DIBDRV_SelectFont( DIBDRVPHYSDEV
*physDev
, HFONT hfont
, GdiFont
*gdiFont
)
134 FT_CharMap charmap
= NULL
;
137 MAYBE(TRACE("physDev:%p, hfont:%p, gdiFont:%p\n", physDev
, hfont
, gdiFont
));
141 /* DIB section selected in, use DIB Engine */
143 /* gets font information */
144 GetObjectW(hfont
, sizeof(lf
), &lf
);
145 MAYBE(TRACE("Font is : '%s'\n", debugstr_w(lf
.lfFaceName
)));
147 /* FIXME: just handles gdifont, don't know if it needs to handle hfont too
148 BTW, still don't know how to get FT_Face from non-gdi font here
152 FIXME("No gdi font - unhandled by now.\n");
156 physDev
->face
= gdiFont
->ft_face
;
159 FIXME("Error, null Ft_Face\n");
164 /* prints out some info about face */
165 if(TRACE_ON(dibdrv
)) MAYBE(PrintFaceInfo(physDev
->face
));
167 /* setup the correct charmap.... maybe */
168 for (i
= 0; i
< physDev
->face
->num_charmaps
; ++i
)
170 if (physDev
->face
->charmaps
[i
]->platform_id
!= TT_PLATFORM_MICROSOFT
)
173 if (physDev
->face
->charmaps
[i
]->encoding_id
== TT_MS_ID_UNICODE_CS
)
175 charmap
= physDev
->face
->charmaps
[i
];
181 WARN("Selected fallout charmap #%d\n", i
);
182 charmap
= physDev
->face
->charmaps
[i
];
187 WARN("No Windows character map found\n");
188 charmap
= physDev
->face
->charmaps
[0];
192 error
= pFT_Set_Charmap(physDev
->face
, charmap
);
193 if (error
!= FT_Err_Ok
)
195 ERR("%s returned %i\n", "FT_Set_Charmap", error
);
199 /* we use GDI fonts, so just return false */
205 /* DDB selected in, use X11 driver */
206 res
= _DIBDRV_GetDisplayDriver()->pSelectFont(physDev
->X11PhysDev
, hfont
, gdiFont
);
211 /***********************************************************************
212 * DIBDRV_EnumDeviceFonts
214 BOOL
DIBDRV_EnumDeviceFonts( DIBDRVPHYSDEV
*physDev
, LPLOGFONTW plf
,
215 FONTENUMPROCW proc
, LPARAM lp
)
219 MAYBE(TRACE("physDev:%p, plf:%p, proc:%p, lp:%lx\n", physDev
, plf
, proc
, lp
));
223 /* DIB section selected in, use DIB Engine */
224 ONCE(FIXME("STUB\n"));
229 /* DDB selected in, use X11 driver */
230 res
= _DIBDRV_GetDisplayDriver()->pEnumDeviceFonts(physDev
->X11PhysDev
, plf
, proc
, lp
);
235 /***********************************************************************
236 * DIBDRV_GetTextMetrics
238 BOOL
DIBDRV_GetTextMetrics( DIBDRVPHYSDEV
*physDev
, TEXTMETRICW
*metrics
)
242 MAYBE(TRACE("physDev:%p, metrics:%p\n", physDev
, metrics
));
246 /* DIB section selected in, use DIB Engine */
247 ONCE(FIXME("STUB\n"));
252 /* DDB selected in, use X11 driver */
253 res
= _DIBDRV_GetDisplayDriver()->pGetTextMetrics(physDev
->X11PhysDev
, metrics
);
258 /***********************************************************************
259 * DIBDRV_GetCharWidth
261 BOOL
DIBDRV_GetCharWidth( DIBDRVPHYSDEV
*physDev
, UINT firstChar
, UINT lastChar
,
266 MAYBE(TRACE("physDev:%p, firstChar:%d, lastChar:%d, buffer:%pn", physDev
, firstChar
, lastChar
, buffer
));
270 /* DIB section selected in, use DIB Engine */
271 ONCE(FIXME("STUB\n"));
276 /* DDB selected in, use X11 driver */
277 res
= _DIBDRV_GetDisplayDriver()->pGetCharWidth(physDev
->X11PhysDev
, firstChar
, lastChar
, buffer
);