edox: Deactivate use of XFontStruct (use XFontSet).

SVN revision: 33208
This commit is contained in:
Kim Woelders 2007-12-22 11:46:39 +00:00
parent 5b5b014b85
commit ed03edf14f
3 changed files with 53 additions and 45 deletions

View File

@ -56,8 +56,6 @@
#define EAllocColor(pxc) \
XAllocColor(disp, VRoot.cmap, pxc)
#define FILEPATH_LEN_MAX 4096
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
@ -66,6 +64,8 @@
#define USE_WORD_MB
#endif
#define USE_XFONT 0
typedef struct _efont Efont;
typedef struct _root
@ -85,7 +85,9 @@ typedef struct _textstate
XColor bg_col;
int effect;
Efont *efont;
#if USE_XFONT
XFontStruct *xfont;
#endif
XFontSet xfontset;
int xfontset_ascent;
int height;

View File

@ -569,15 +569,7 @@ RenderPage(Window win, int page_num, int w, int h)
Imlib_Image im;
int wastext = 0;
ts.fontname = NULL;
ESetColor(&ts.fg_col, 0, 0, 0);
ESetColor(&ts.bg_col, 0, 0, 0);
ts.effect = 0;
ts.efont = NULL;
ts.xfont = NULL;
ts.xfontset = 0;
ts.xfontset_ascent = 0;
ts.height = 0;
memset(&ts, 0, sizeof(ts));
pg = &(page[page_num]);
x = pg->padding;
y = pg->padding;
@ -649,9 +641,11 @@ RenderPage(Window win, int page_num, int w, int h)
if (ts.efont)
Efont_free(ts.efont);
ts.efont = NULL;
#if USE_XFONT
if (ts.xfont)
XFreeFont(disp, ts.xfont);
ts.xfont = NULL;
#endif
if (ts.xfontset)
XFreeFontSet(disp, ts.xfontset);
ts.xfontset = NULL;
@ -1040,8 +1034,10 @@ RenderPage(Window win, int page_num, int w, int h)
if (ts.efont)
Efont_free(ts.efont);
#if USE_XFONT
if (ts.xfont)
XFreeFont(disp, ts.xfont);
#endif
if (ts.xfontset)
XFreeFontSet(disp, ts.xfontset);

View File

@ -57,7 +57,11 @@ TextGetLines(const char *text, int *count)
void
TextStateLoadFont(TextState * ts)
{
#if USE_XFONT
if ((ts->efont) || (ts->xfont) || (ts->xfontset))
#else
if ((ts->efont) || (ts->xfontset))
#endif
return;
if (!ts->fontname)
@ -89,46 +93,48 @@ TextStateLoadFont(TextState * ts)
}
if (s2)
free(s2);
if (ts->efont)
return;
}
if (!ts->efont)
#if USE_XFONT
if ((!ts->xfont) && (strchr(ts->fontname, ',') == NULL))
{
if ((!ts->xfont) && (strchr(ts->fontname, ',') == NULL))
ts->xfont = XLoadQueryFont(disp, ts->fontname);
if (ts->xfont)
{
ts->xfont = XLoadQueryFont(disp, ts->fontname);
if (ts->xfont)
{
ts->xfontset_ascent = ts->xfont->ascent;
ts->height = ts->xfont->ascent + ts->xfont->descent;
}
}
else if (!ts->xfontset)
{
int i, missing_cnt, font_cnt;
int descent;
char **missing_list, *def_str, **fn;
XFontStruct **fs;
ts->xfontset = XCreateFontSet(disp, ts->fontname, &missing_list,
&missing_cnt, &def_str);
if (missing_cnt)
{
XFreeStringList(missing_list);
return;
}
if (!ts->xfontset)
return;
font_cnt = XFontsOfFontSet(ts->xfontset, &fs, &fn);
ts->xfontset_ascent = 0;
for (i = 0; i < font_cnt; i++)
ts->xfontset_ascent = MAX(fs[i]->ascent, ts->xfontset_ascent);
descent = 0;
for (i = 0; i < font_cnt; i++)
descent = MAX(fs[i]->descent, descent);
ts->height = ts->xfontset_ascent + descent;
ts->xfontset_ascent = ts->xfont->ascent;
ts->height = ts->xfont->ascent + ts->xfont->descent;
return;
}
}
return;
#endif
if (!ts->xfontset)
{
int i, missing_cnt, font_cnt;
int descent;
char **missing_list, *def_str, **fn;
XFontStruct **fs;
ts->xfontset = XCreateFontSet(disp, ts->fontname, &missing_list,
&missing_cnt, &def_str);
if (missing_cnt)
{
XFreeStringList(missing_list);
return;
}
if (!ts->xfontset)
return;
font_cnt = XFontsOfFontSet(ts->xfontset, &fs, &fn);
ts->xfontset_ascent = 0;
for (i = 0; i < font_cnt; i++)
ts->xfontset_ascent = MAX(fs[i]->ascent, ts->xfontset_ascent);
descent = 0;
for (i = 0; i < font_cnt; i++)
descent = MAX(fs[i]->descent, descent);
ts->height = ts->xfontset_ascent + descent;
}
}
void
@ -175,6 +181,7 @@ TextSize(TextState * ts, const char *text, int *width, int *height, int fsize)
*width = ret2.width;
}
}
#if USE_XFONT
else if ((ts->xfont) && (ts->xfont->min_byte1 == 0) &&
(ts->xfont->max_byte1 == 0))
{
@ -201,6 +208,7 @@ TextSize(TextState * ts, const char *text, int *width, int *height, int fsize)
*width = wid;
}
}
#endif /* USE_XFONT */
freestrlist(lines, num_lines);
return;
fsize = 0;
@ -306,6 +314,7 @@ TextDraw(TextState * ts, Window win, char *text,
yy += ret2.height;
}
}
#if USE_XFONT
else if ((ts->xfont) && (ts->xfont->min_byte1 == 0) &&
(ts->xfont->max_byte1 == 0))
{
@ -383,6 +392,7 @@ TextDraw(TextState * ts, Window win, char *text,
yy += ts->xfont->ascent + ts->xfont->descent;
}
}
#endif /* USE_XFONT */
freestrlist(lines, num_lines);
return;
h = fsize = 0;