summaryrefslogtreecommitdiff
path: root/app/xterm/fontutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/xterm/fontutils.c')
-rw-r--r--app/xterm/fontutils.c111
1 files changed, 84 insertions, 27 deletions
diff --git a/app/xterm/fontutils.c b/app/xterm/fontutils.c
index d7dec3a47..1c2e11917 100644
--- a/app/xterm/fontutils.c
+++ b/app/xterm/fontutils.c
@@ -1,4 +1,4 @@
-/* $XTermId: fontutils.c,v 1.272 2008/04/17 23:23:37 tom Exp $ */
+/* $XTermId: fontutils.c,v 1.275 2008/09/14 22:21:14 tom Exp $ */
/************************************************************
@@ -1335,12 +1335,16 @@ xtermSetCursorBox(TScreen * screen)
{
static XPoint VTbox[NBOX];
XPoint *vp;
+ int fw = FontWidth(screen) - 1;
+ int fh = FontHeight(screen) - 1;
+ int hh = screen->cursor_underline ? 1 : fh;
vp = &VTbox[1];
- (vp++)->x = FontWidth(screen) - 1;
- (vp++)->y = FontHeight(screen) - 1;
- (vp++)->x = -(FontWidth(screen) - 1);
- vp->y = -(FontHeight(screen) - 1);
+ (vp++)->x = fw;
+ (vp++)->y = hh;
+ (vp++)->x = -fw;
+ vp->y = -hh;
+
screen->box = VTbox;
}
@@ -1668,6 +1672,7 @@ xtermComputeFontInfo(XtermWidget xw,
#endif /* OPT_RENDERWIDE */
}
if (norm == 0) {
+ TRACE(("...no TrueType font found for number %d, disable menu entry\n", fontnum));
xw->misc.render_font = False;
update_font_renderfont();
/* now we will fall through into the bitmap fonts */
@@ -2325,6 +2330,27 @@ lookupFontSizes(XtermWidget xw)
}
}
+#if OPT_RENDERFONT
+#define NMENU_RENDERFONTS (NMENUFONTS - 2) /* no selection or escape */
+static Boolean
+useFaceSizes(XtermWidget xw)
+{
+ Boolean result = False;
+ int n;
+
+ if (UsingRenderFont(xw)) {
+ result = True;
+ for (n = 0; n < NMENU_RENDERFONTS; ++n) {
+ if (xw->misc.face_size[n] <= 0.0) {
+ result = False;
+ break;
+ }
+ }
+ }
+ return result;
+}
+#endif
+
/*
* Find the index of a larger/smaller font (according to the sign of 'relative'
* and its magnitude), starting from the 'old' index.
@@ -2335,34 +2361,65 @@ lookupRelativeFontSize(XtermWidget xw, int old, int relative)
TScreen *screen = TScreenOf(xw);
int n, m = -1;
+ TRACE(("lookupRelativeFontSize(old=%d, relative=%d)\n", old, relative));
if (!IsIcon(screen)) {
- lookupFontSizes(xw);
- if (relative != 0) {
- for (n = 0; n < NMENUFONTS; ++n) {
- if (screen->menu_font_sizes[n] > 0 &&
- screen->menu_font_sizes[n] != screen->menu_font_sizes[old]) {
- int cmp_0 = ((screen->menu_font_sizes[n] >
- screen->menu_font_sizes[old])
- ? relative
- : -relative);
- int cmp_m = ((m < 0)
- ? 1
- : ((screen->menu_font_sizes[n] <
- screen->menu_font_sizes[m])
- ? relative
- : -relative));
- if (cmp_0 > 0 && cmp_m > 0) {
- m = n;
+#if OPT_RENDERFONT
+ if (useFaceSizes(xw)) {
+ TRACE(("...using FaceSize\n"));
+ if (relative != 0) {
+ for (n = 0; n < NMENU_RENDERFONTS; ++n) {
+ if (xw->misc.face_size[n] > 0 &&
+ xw->misc.face_size[n] != xw->misc.face_size[old]) {
+ int cmp_0 = ((xw->misc.face_size[n] >
+ xw->misc.face_size[old])
+ ? relative
+ : -relative);
+ int cmp_m = ((m < 0)
+ ? 1
+ : ((xw->misc.face_size[n] <
+ xw->misc.face_size[m])
+ ? relative
+ : -relative));
+ if (cmp_0 > 0 && cmp_m > 0) {
+ m = n;
+ }
}
}
}
- if (m >= 0) {
- if (relative > 1)
- m = lookupRelativeFontSize(xw, m, relative - 1);
- else if (relative < -1)
- m = lookupRelativeFontSize(xw, m, relative + 1);
+ } else
+#endif
+ {
+ TRACE(("...using bitmap areas\n"));
+ lookupFontSizes(xw);
+ if (relative != 0) {
+ for (n = 0; n < NMENUFONTS; ++n) {
+ if (screen->menu_font_sizes[n] > 0 &&
+ screen->menu_font_sizes[n] !=
+ screen->menu_font_sizes[old]) {
+ int cmp_0 = ((screen->menu_font_sizes[n] >
+ screen->menu_font_sizes[old])
+ ? relative
+ : -relative);
+ int cmp_m = ((m < 0)
+ ? 1
+ : ((screen->menu_font_sizes[n] <
+ screen->menu_font_sizes[m])
+ ? relative
+ : -relative));
+ if (cmp_0 > 0 && cmp_m > 0) {
+ m = n;
+ }
+ }
+ }
}
}
+ TRACE(("...new index %d\n", m));
+ if (m >= 0) {
+ if (relative > 1)
+ m = lookupRelativeFontSize(xw, m, relative - 1);
+ else if (relative < -1)
+ m = lookupRelativeFontSize(xw, m, relative + 1);
+ }
}
return m;
}