mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fixes the bug, which caused dtterm to show stripes of wrong color between text lines when using fontsets that include fonts of slightly different heights.
The cause of the bug was that X*DrawImageString draws background according to the extents of the given string, not to extents of the font set, which determine terminal line height. Now, when such a situation is detected, the background is cleared before drawing the characters.
This commit is contained in:
parent
a9dbe60805
commit
4e2adc1f8e
1 changed files with 77 additions and 50 deletions
|
@ -64,10 +64,57 @@ FontSetRenderFunction(
|
|||
XGCValues values;
|
||||
unsigned long valueMask;
|
||||
TermFontSet termFontSet = (TermFontSet) font->fontInfo;
|
||||
int escapement;
|
||||
XRectangle extents;
|
||||
Boolean fixExtents;
|
||||
|
||||
/* set the renderGC... */
|
||||
valueMask = (unsigned long) 0;
|
||||
|
||||
/* set background... */
|
||||
if (tpd->renderGC.background != bg) {
|
||||
tpd->renderGC.background = bg;
|
||||
values.background = bg;
|
||||
valueMask |= GCBackground;
|
||||
}
|
||||
|
||||
/* since Xlib will be mucking with the GC's font under us, we need to
|
||||
* make sure we trash the cached value...
|
||||
*/
|
||||
tpd->renderGC.fid = (Font) 0;
|
||||
|
||||
escapement = (tpd->mbCurMax == 1) ?
|
||||
XmbTextExtents(termFontSet->fontSet, (char *) string, len,
|
||||
NULL, &extents) :
|
||||
XwcTextExtents(termFontSet->fontSet, (wchar_t*) string, len,
|
||||
NULL, &extents);
|
||||
|
||||
/* Text height may be smaller than cellHeight (happens when using font sets).
|
||||
In this case we need to fill background manually and then use X*DrawString
|
||||
instead of X*DrawImageString */
|
||||
fixExtents = extents.height < tpd->cellHeight;
|
||||
|
||||
if (fixExtents) {
|
||||
/* set background color as foreground if needed*/
|
||||
if (tpd->renderGC.foreground != bg) {
|
||||
tpd->renderGC.foreground = bg;
|
||||
valueMask|= GCForeground ;
|
||||
values.foreground = bg;
|
||||
}
|
||||
if (valueMask) {
|
||||
(void) XChangeGC(XtDisplay(w), tpd->renderGC.gc, valueMask, &values);
|
||||
valueMask= (unsigned long) 0;
|
||||
}
|
||||
/* paint background manually */
|
||||
(void) XFillRectangle(XtDisplay(w),
|
||||
XtWindow(w),
|
||||
tpd->renderGC.gc,
|
||||
x,
|
||||
y,
|
||||
escapement,
|
||||
tpd->cellHeight);
|
||||
}
|
||||
|
||||
/* set the foreground... */
|
||||
if (TermIS_SECURE(flags)) {
|
||||
if (tpd->renderGC.foreground != bg) {
|
||||
|
@ -82,19 +129,6 @@ FontSetRenderFunction(
|
|||
valueMask |= GCForeground;
|
||||
}
|
||||
}
|
||||
|
||||
/* set background... */
|
||||
if (tpd->renderGC.background != bg) {
|
||||
tpd->renderGC.background = bg;
|
||||
values.background = bg;
|
||||
valueMask |= GCBackground;
|
||||
}
|
||||
|
||||
/* since Xlib will be mucking with the GC's font under us, we need to
|
||||
* make sure we trash the cached value...
|
||||
*/
|
||||
tpd->renderGC.fid = (Font) 0;
|
||||
|
||||
if (valueMask) {
|
||||
(void) XChangeGC(XtDisplay(w), tpd->renderGC.gc, valueMask,
|
||||
&values);
|
||||
|
@ -102,6 +136,10 @@ FontSetRenderFunction(
|
|||
|
||||
/* draw image string a line of text... */
|
||||
if (isDebugFSet('t', 1)) {
|
||||
/* we need to clear background after the debug draw and delay,
|
||||
so this will cause X*DrawImageString to be always used
|
||||
in debug mode */
|
||||
fixExtents = 0;
|
||||
#ifdef BBA
|
||||
#pragma BBA_IGNORE
|
||||
#endif /*BBA*/
|
||||
|
@ -113,18 +151,18 @@ FontSetRenderFunction(
|
|||
tpd->renderGC.gc,
|
||||
x,
|
||||
y,
|
||||
(tpd->mbCurMax == 1) ?
|
||||
XmbTextEscapement(termFontSet->fontSet, (char *) string, len) :
|
||||
XwcTextEscapement(termFontSet->fontSet, (wchar_t *) string,
|
||||
len),
|
||||
tpd->cellHeight);
|
||||
escapement,
|
||||
extents.height);
|
||||
(void) XSync(XtDisplay(w), False);
|
||||
(void) shortSleep(100000);
|
||||
}
|
||||
|
||||
|
||||
if (tpd->mbCurMax == 1)
|
||||
{
|
||||
(void) XmbDrawImageString(XtDisplay(w),/* Display */
|
||||
/* select right function, we do not want text background be drawn twice */
|
||||
(void) (fixExtents ? XmbDrawString: XmbDrawImageString)
|
||||
(XtDisplay(w), /* Display */
|
||||
XtWindow(w), /* Drawable */
|
||||
termFontSet->fontSet, /* XFontSet */
|
||||
tpd->renderGC.gc, /* GC */
|
||||
|
@ -144,22 +182,12 @@ FontSetRenderFunction(
|
|||
(char *)string, /* string */
|
||||
len); /* length */
|
||||
}
|
||||
/* handle the underline enhancement... */
|
||||
/* draw the underline... */
|
||||
if (TermIS_UNDERLINE(flags)) {
|
||||
XDrawLine(XtDisplay(w), /* Display */
|
||||
XtWindow(w), /* Window */
|
||||
tpd->renderGC.gc, /* GC */
|
||||
x, /* X1 */
|
||||
y + tpd->cellHeight - 1, /* Y1 */
|
||||
x - 1 + XmbTextEscapement(termFontSet->fontSet,
|
||||
(char *) string, len), /* X2 */
|
||||
y + tpd->cellHeight - 1);/* Y2 */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) XwcDrawImageString(XtDisplay(w), /* Display */
|
||||
/* select right function, we do not want text background be drawn twice */
|
||||
(void) (fixExtents ? XwcDrawString: XwcDrawImageString)
|
||||
(XtDisplay(w), /* Displa*/
|
||||
XtWindow(w), /* Drawable */
|
||||
termFontSet->fontSet, /* XFontSet */
|
||||
tpd->renderGC.gc, /* GC */
|
||||
|
@ -179,6 +207,7 @@ FontSetRenderFunction(
|
|||
(wchar_t *) string, /* string */
|
||||
len); /* length */
|
||||
}
|
||||
}
|
||||
/* handle the underline enhancement... */
|
||||
/* draw the underline... */
|
||||
if (TermIS_UNDERLINE(flags)) {
|
||||
|
@ -187,11 +216,9 @@ FontSetRenderFunction(
|
|||
tpd->renderGC.gc, /* GC */
|
||||
x, /* X1 */
|
||||
y + tpd->cellHeight - 1, /* Y1 */
|
||||
x - 1 + XwcTextEscapement(termFontSet->fontSet,
|
||||
(wchar_t *) string, len), /* X2 */
|
||||
x - 1 + escapement, /* X2 */
|
||||
y + tpd->cellHeight - 1); /* Y2 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue