2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 #ifdef VERBOSE_REV_INFO
25 static char rcs_id[] = "$XConsortium: TermPrimRenderFont.c /main/1 1996/04/21 19:18:47 drk $";
26 #endif /* VERBOSE_REV_INFO */
30 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
31 * (c) Copyright 1993, 1994 International Business Machines Corp. *
32 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
33 * (c) Copyright 1993, 1994 Novell, Inc. *
36 #include "TermHeader.h"
37 #include "TermPrimP.h"
38 #include "TermPrimDebug.h"
39 #include "TermPrimRenderP.h"
40 #include "TermPrimRenderFont.h"
51 unsigned char *string,
55 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
56 struct termData *tpd = tw->term.tpd;
58 unsigned long valueMask;
59 XFontStruct *fontStruct = (XFontStruct *) font->fontInfo;
61 /* set the renderGC... */
62 valueMask = (unsigned long) 0;
64 /* set the foreground... */
65 if (TermIS_SECURE(flags)) {
66 if (tpd->renderGC.foreground != bg) {
67 tpd->renderGC.foreground = bg;
68 values.foreground = bg;
69 valueMask |= GCForeground;
72 if (tpd->renderGC.foreground != fg) {
73 tpd->renderGC.foreground = fg;
74 values.foreground = fg;
75 valueMask |= GCForeground;
79 /* set background... */
80 if (tpd->renderGC.background != bg) {
81 tpd->renderGC.background = bg;
82 values.background = bg;
83 valueMask |= GCBackground;
86 /* set the font for renderGC if necessary */
87 if (tpd->renderGC.fid != fontStruct->fid) {
88 tpd->renderGC.fid = fontStruct->fid;
89 values.font = fontStruct->fid;
94 (void) XChangeGC(XtDisplay(w), tpd->renderGC.gc, valueMask,
98 /* draw image string a line of text... */
99 if (isDebugFSet('t', 1)) {
103 /* Fill in the text area so we can see what is going to
106 (void) XFillRectangle(XtDisplay(w),
111 tpd->cellWidth * len,
113 (void) XSync(XtDisplay(w), False);
114 (void) shortSleep(100000);
117 (void) XDrawImageString(XtDisplay(w), /* Display */
118 XtWindow(w), /* Drawable */
119 tpd->renderGC.gc, /* GC */
121 y + fontStruct->ascent, /* y */
122 (char *) string, /* string */
125 /* handle overstrike... */
126 if (TermIS_OVERSTRIKE(flags)) {
127 (void) XDrawString(XtDisplay(w), /* Display */
128 XtWindow(w), /* Drawable */
129 tpd->renderGC.gc, /* GC */
131 y + fontStruct->ascent, /* y */
132 (char *) string, /* string */
136 /* handle the underline enhancement... */
137 /* draw the underline... */
138 if (TermIS_UNDERLINE(flags)) {
139 XDrawLine(XtDisplay(w), /* Display */
140 XtWindow(w), /* Window */
141 tpd->renderGC.gc, /* GC */
143 y + tpd->cellHeight - 1, /* Y1 */
144 x + len * tpd->cellWidth, /* X2 */
145 y + tpd->cellHeight - 1); /* Y2 */
155 (void) XtFree((char *) font);
162 unsigned char *string,
169 XFontStruct *fontStruct = (XFontStruct *) font->fontInfo;
172 *widthReturn = len * fontStruct->max_bounds.width;
175 *heightReturn = fontStruct->ascent + fontStruct->descent;
178 *ascentReturn = fontStruct->ascent;
184 _DtTermPrimRenderFontCreate(
186 XFontStruct *fontStruct
191 termFont = (TermFont) XtMalloc(sizeof(TermFontRec));
192 termFont->renderFunction = FontRenderFunction;
193 termFont->destroyFunction = FontDestroyFunction;
194 termFont->extentsFunction = FontExtentsFunction;
195 termFont->fontInfo = (XtPointer) fontStruct;