Refactor the font handling code: I've moved all the code that
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]
2008-03-22 11:40:23 +00:00
|
|
|
/*
|
|
|
|
* 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'.
|
|
|
|
*/
|
2011-09-16 19:18:53 +00:00
|
|
|
int public_charset;
|
Refactor the font handling code: I've moved all the code that
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]
2008-03-22 11:40:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Font dimensions needed by clients.
|
|
|
|
*/
|
|
|
|
int width, height, ascent, descent;
|
2011-09-16 19:18:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Indicates whether this font is capable of handling all glyphs
|
|
|
|
* (Pango fonts can do this because Pango automatically supplies
|
|
|
|
* missing glyphs from other fonts), or whether it would like a
|
|
|
|
* fallback font to cope with missing glyphs.
|
|
|
|
*/
|
|
|
|
int want_fallback;
|
Refactor the font handling code: I've moved all the code that
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]
2008-03-22 11:40:23 +00:00
|
|
|
} unifont;
|
|
|
|
|
2008-03-25 21:49:14 +00:00
|
|
|
unifont *unifont_create(GtkWidget *widget, const char *name,
|
|
|
|
int wide, int bold,
|
Refactor the font handling code: I've moved all the code that
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]
2008-03-22 11:40:23 +00:00
|
|
|
int shadowoffset, int shadowalways);
|
|
|
|
void unifont_destroy(unifont *font);
|
|
|
|
void unifont_draw_text(GdkDrawable *target, GdkGC *gc, unifont *font,
|
2011-09-16 19:18:53 +00:00
|
|
|
int x, int y, const wchar_t *string, int len,
|
2008-03-22 18:11:17 +00:00
|
|
|
int wide, int bold, int cellwidth);
|
Refactor the font handling code: I've moved all the code that
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]
2008-03-22 11:40:23 +00:00
|
|
|
|
2011-09-16 19:18:54 +00:00
|
|
|
/*
|
|
|
|
* This function behaves exactly like the low-level unifont_create,
|
|
|
|
* except that as well as the requested font it also allocates (if
|
|
|
|
* necessary) a fallback font for filling in replacement glyphs.
|
|
|
|
*
|
|
|
|
* Return value is usable with unifont_destroy and unifont_draw_text
|
|
|
|
* as if it were an ordinary unifont.
|
|
|
|
*/
|
|
|
|
unifont *multifont_create(GtkWidget *widget, const char *name,
|
|
|
|
int wide, int bold,
|
|
|
|
int shadowoffset, int shadowalways);
|
|
|
|
|
2008-03-25 21:49:14 +00:00
|
|
|
/*
|
|
|
|
* Unified font selector dialog. I can't be bothered to do a
|
|
|
|
* proper GTK subclassing today, so this will just be an ordinary
|
|
|
|
* data structure with some useful members.
|
|
|
|
*
|
|
|
|
* (Of course, these aren't the only members; this structure is
|
|
|
|
* contained within a bigger one which holds data visible only to
|
|
|
|
* the implementation.)
|
|
|
|
*/
|
|
|
|
typedef struct unifontsel {
|
|
|
|
void *user_data; /* settable by the user */
|
|
|
|
GtkWindow *window;
|
|
|
|
GtkWidget *ok_button, *cancel_button;
|
|
|
|
} unifontsel;
|
|
|
|
|
|
|
|
unifontsel *unifontsel_new(const char *wintitle);
|
|
|
|
void unifontsel_destroy(unifontsel *fontsel);
|
|
|
|
void unifontsel_set_name(unifontsel *fontsel, const char *fontname);
|
|
|
|
char *unifontsel_get_name(unifontsel *fontsel);
|
|
|
|
|
Refactor the font handling code: I've moved all the code that
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]
2008-03-22 11:40:23 +00:00
|
|
|
#endif /* PUTTY_GTKFONT_H */
|