mirror of
https://github.com/fltk/fltk.git
synced 2026-06-06 08:32:07 +08:00
Attempt to fix STR #2550 to make fl_text_extents work in Xlib-only
(i.e. non-XFT) X11 builds. This appears to be working now, though I can not test it fully, so we need more feedback. In particular the setting of the dx param is certainly wrong, but works fine in general cases. I think. Also, I suspect it may behave badly in the face of RtoL text rendering but I think we have other problems in that area anyway... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8399 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+36
-23
@@ -48,8 +48,8 @@ typedef struct {
|
||||
|
||||
XUtf8FontStruct *
|
||||
XCreateUtf8FontStruct (
|
||||
Display *dpy,
|
||||
const char *base_font_name_list);
|
||||
Display *dpy,
|
||||
const char *base_font_name_list);
|
||||
|
||||
void
|
||||
XUtf8DrawString(
|
||||
@@ -62,6 +62,19 @@ XUtf8DrawString(
|
||||
const char *string,
|
||||
int num_bytes);
|
||||
|
||||
void
|
||||
XUtf8_measure_extents(
|
||||
Display *display,
|
||||
Drawable d,
|
||||
XUtf8FontStruct *font_set,
|
||||
GC gc,
|
||||
int *xx,
|
||||
int *yy,
|
||||
int *ww,
|
||||
int *hh,
|
||||
const char *string,
|
||||
int num_bytes);
|
||||
|
||||
void
|
||||
XUtf8DrawRtlString(
|
||||
Display *display,
|
||||
@@ -89,7 +102,7 @@ XUtf8TextWidth(
|
||||
XUtf8FontStruct *font_set,
|
||||
const char *string,
|
||||
int num_bytes);
|
||||
int
|
||||
int
|
||||
XUtf8UcsWidth(
|
||||
XUtf8FontStruct *font_set,
|
||||
unsigned int ucs);
|
||||
@@ -100,41 +113,41 @@ XGetUtf8FontAndGlyph(
|
||||
unsigned int ucs,
|
||||
XFontStruct **fnt,
|
||||
unsigned short *id);
|
||||
|
||||
|
||||
void
|
||||
XFreeUtf8FontStruct(
|
||||
Display *dpy,
|
||||
XUtf8FontStruct *font_set);
|
||||
|
||||
|
||||
int
|
||||
XConvertUtf8ToUcs(
|
||||
const unsigned char *buf,
|
||||
int len,
|
||||
int
|
||||
XConvertUtf8ToUcs(
|
||||
const unsigned char *buf,
|
||||
int len,
|
||||
unsigned int *ucs);
|
||||
|
||||
int
|
||||
int
|
||||
XConvertUcsToUtf8(
|
||||
unsigned int ucs,
|
||||
unsigned int ucs,
|
||||
char *buf);
|
||||
|
||||
int
|
||||
int
|
||||
XUtf8CharByteLen(
|
||||
const unsigned char *buf,
|
||||
const unsigned char *buf,
|
||||
int len);
|
||||
|
||||
int
|
||||
int
|
||||
XCountUtf8Char(
|
||||
const unsigned char *buf,
|
||||
const unsigned char *buf,
|
||||
int len);
|
||||
|
||||
int
|
||||
XFastConvertUtf8ToUcs(
|
||||
const unsigned char *buf,
|
||||
int len,
|
||||
int
|
||||
XFastConvertUtf8ToUcs(
|
||||
const unsigned char *buf,
|
||||
int len,
|
||||
unsigned int *ucs);
|
||||
|
||||
long
|
||||
long
|
||||
XKeysymToUcs(
|
||||
KeySym keysym);
|
||||
|
||||
@@ -147,7 +160,7 @@ XUtf8LookupString(
|
||||
KeySym* keysym,
|
||||
Status* status_return);
|
||||
|
||||
unsigned short
|
||||
unsigned short
|
||||
XUtf8IsNonSpacing(
|
||||
unsigned int ucs);
|
||||
|
||||
@@ -156,11 +169,11 @@ XUtf8IsRightToLeft(
|
||||
unsigned int ucs);
|
||||
|
||||
|
||||
int
|
||||
int
|
||||
XUtf8Tolower(
|
||||
int ucs);
|
||||
|
||||
int
|
||||
int
|
||||
XUtf8Toupper(
|
||||
int ucs);
|
||||
|
||||
@@ -173,4 +186,4 @@ XUtf8Toupper(
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
*/
|
||||
|
||||
+13
-8
@@ -302,15 +302,20 @@ double fl_width(unsigned int c) {
|
||||
|
||||
|
||||
void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
|
||||
if (font_gc != fl_gc) {
|
||||
if (!current_font) fl_font(FL_HELVETICA, 14);
|
||||
font_gc = fl_gc;
|
||||
XSetFont(fl_display, fl_gc, current_font->fid);
|
||||
}
|
||||
int xx, yy, ww, hh;
|
||||
XUtf8_measure_extents(fl_display, fl_window, current_font, fl_gc, &xx, &yy, &ww, &hh, c, n);
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#warning fl_text_extents is only a test stub in Xlib build at present
|
||||
#endif /*__GNUC__*/
|
||||
|
||||
W = 0; H = 0;
|
||||
fl_measure(c, W, H, 0);
|
||||
dx = 0;
|
||||
dy = fl_descent() - H;
|
||||
W = ww; H = hh; dx = xx; dy = yy;
|
||||
// This is the safe but mostly wrong thing we used to do...
|
||||
// W = 0; H = 0;
|
||||
// fl_measure(c, W, H, 0);
|
||||
// dx = 0;
|
||||
// dy = fl_descent() - H;
|
||||
} // fl_text_extents
|
||||
|
||||
|
||||
|
||||
+221
-77
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user