mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
71d802bdb6
explicitly deals with GdkFont out into a new module, behind a polymorphic interface (done by ad-hoc explicit vtable management in C). This should allow me to drop in a Pango font handling module in parallel with the existing one, meaning that GTK2 PuTTY will be able to seamlessly switch between X11 server-side fonts and Pango client- side ones as the user chooses, or even use a mixture of the two (e.g. an X11 font for narrow characters and a Pango one for wide characters, or vice versa). In the process, incidentally, I got to the bottom of the `weird bug' mentioned in the old do_text_internal(). It's not a bug in gdk_draw_text_wc() as I had thought: it's simply that GdkWChar is a 32-bit type rather than a 16-bit one, so no wonder you have to specify twice the length to find all the characters in the string! However, there _is_ a bug in GTK2's gdk_draw_text_wc(), which causes it to strip off everything above the low byte of each GdkWChar, sigh. Solution to both problems is to use an array of the underlying Xlib type XChar2b instead, and pass it to gdk_draw_text() cast to gchar *. Grotty, but it works. (And it'll become significantly less grotty if and when we have to stop using the GDK font handling wrappers in favour of going direct to Xlib.) [originally from svn r7933]
47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
/*
|
|
* Header file for gtkfont.c. Has to be separate from unix.h
|
|
* because it depends on GTK data types, hence can't be included
|
|
* from cross-platform code (which doesn't go near GTK).
|
|
*/
|
|
|
|
#ifndef PUTTY_GTKFONT_H
|
|
#define PUTTY_GTKFONT_H
|
|
|
|
/*
|
|
* Exports from gtkfont.c.
|
|
*/
|
|
struct unifont_vtable; /* contents internal to gtkfont.c */
|
|
typedef struct unifont {
|
|
const struct unifont_vtable *vt;
|
|
/*
|
|
* `Non-static data members' of the `class', accessible to
|
|
* external code.
|
|
*/
|
|
|
|
/*
|
|
* public_charset is the charset used when the user asks for
|
|
* `Use font encoding'.
|
|
*
|
|
* real_charset is the charset used when translating text into
|
|
* a form suitable for sending to unifont_draw_text().
|
|
*
|
|
* They can differ. For example, public_charset might be
|
|
* CS_ISO8859_1 while real_charset is CS_ISO8859_1_X11.
|
|
*/
|
|
int public_charset, real_charset;
|
|
|
|
/*
|
|
* Font dimensions needed by clients.
|
|
*/
|
|
int width, height, ascent, descent;
|
|
} unifont;
|
|
|
|
unifont *unifont_create(char *name, int wide, int bold,
|
|
int shadowoffset, int shadowalways);
|
|
void unifont_destroy(unifont *font);
|
|
void unifont_draw_text(GdkDrawable *target, GdkGC *gc, unifont *font,
|
|
int x, int y, const char *string, int len,
|
|
int wide, int bold);
|
|
|
|
#endif /* PUTTY_GTKFONT_H */
|