GtkBox *hbox;
GtkAdjustment *sbar_adjust;
GdkPixmap *pixmap;
- GdkFont *fonts[2]; /* normal and bold (for now!) */
+ GdkFont *fonts[4]; /* normal, bold, wide, widebold */
struct {
int charset;
int is_wide;
- } fontinfo[2];
+ } fontinfo[4];
GdkCursor *rawcursor, *textcursor, *blankcursor, *currcursor;
GdkColor cols[NCOLOURS];
GdkColormap *colmap;
struct gui_data *inst = dctx->inst;
GdkGC *gc = dctx->gc;
- int nfg, nbg, t, fontid, shadow, rlen;
-
- /*
- * NYI:
- * - Unicode, code pages, and ATTR_WIDE for CJK support.
- */
+ int nfg, nbg, t, fontid, shadow, rlen, widefactor;
nfg = 2 * ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nbg = 2 * ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
}
fontid = shadow = 0;
+
+ if (attr & ATTR_WIDE) {
+ widefactor = 2;
+ fontid |= 2;
+ } else {
+ widefactor = 1;
+ }
+
if ((attr & ATTR_BOLD) && !cfg.bold_colour) {
- if (inst->fonts[1])
- fontid = 1;
+ if (inst->fonts[fontid | 1])
+ fontid |= 1;
else
shadow = 1;
}
x *= 2;
if (x >= inst->term->cols)
return;
- if (x + len*2 > inst->term->cols)
- len = (inst->term->cols-x)/2; /* trim to LH half */
+ if (x + len*2*widefactor > inst->term->cols)
+ len = (inst->term->cols-x)/2/widefactor;/* trim to LH half */
rlen = len * 2;
} else
rlen = len;
r.x = x*inst->font_width+cfg.window_border;
r.y = y*inst->font_height+cfg.window_border;
- r.width = rlen*inst->font_width;
+ r.width = rlen*widefactor*inst->font_width;
r.height = inst->font_height;
gdk_gc_set_clip_rectangle(gc, &r);
}
gdk_draw_rectangle(inst->pixmap, gc, 1,
x*inst->font_width+cfg.window_border,
y*inst->font_height+cfg.window_border,
- rlen*inst->font_width, inst->font_height);
+ rlen*widefactor*inst->font_width, inst->font_height);
gdk_gc_set_foreground(gc, &inst->cols[nfg]);
{
wcs[i] = (wchar_t) ((attr & CSET_MASK) + (text[i] & CHAR_MASK));
}
- if (inst->fontinfo[fontid].is_wide) {
+ if (inst->fonts[fontid] == NULL) {
+ /*
+ * The font for this contingency does not exist.
+ * Typically this means we've been given ATTR_WIDE
+ * character and have no wide font. So we display
+ * nothing at all; such is life.
+ */
+ } else if (inst->fontinfo[fontid].is_wide) {
gwcs = smalloc(sizeof(GdkWChar) * (len+1));
/*
* FIXME: when we have a wide-char equivalent of
uheight = inst->font_height - 1;
gdk_draw_line(inst->pixmap, gc, x*inst->font_width+cfg.window_border,
y*inst->font_height + uheight + cfg.window_border,
- (x+len)*inst->font_width-1+cfg.window_border,
+ (x+len)*widefactor*inst->font_width-1+cfg.window_border,
y*inst->font_height + uheight + cfg.window_border);
}
* try thinking of a better way. :-(
*/
int i;
- for (i = 0; i < len * inst->font_width; i++) {
+ for (i = 0; i < len * widefactor * inst->font_width; i++) {
gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap,
x*inst->font_width+cfg.window_border + 2*i,
y*inst->font_height+cfg.window_border,
gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap,
x*inst->font_width+cfg.window_border,
y*inst->font_height+cfg.window_border+dt*i+db,
- x*inst->font_width+cfg.window_border,
+ x*widefactor*inst->font_width+cfg.window_border,
y*inst->font_height+cfg.window_border+dt*(i+1),
len * inst->font_width, inst->font_height-i-1);
}
struct draw_ctx *dctx = (struct draw_ctx *)ctx;
struct gui_data *inst = dctx->inst;
GdkGC *gc = dctx->gc;
+ int widefactor;
do_text_internal(ctx, x, y, text, len, attr, lattr);
+ if (attr & ATTR_WIDE) {
+ widefactor = 2;
+ } else {
+ widefactor = 1;
+ }
+
if (lattr != LATTR_NORM) {
x *= 2;
if (x >= inst->term->cols)
return;
- if (x + len*2 > inst->term->cols)
- len = (inst->term->cols-x)/2; /* trim to LH half */
+ if (x + len*2*widefactor > inst->term->cols)
+ len = (inst->term->cols-x)/2/widefactor;/* trim to LH half */
len *= 2;
}
y*inst->font_height+cfg.window_border,
x*inst->font_width+cfg.window_border,
y*inst->font_height+cfg.window_border,
- len*inst->font_width, inst->font_height);
+ len*widefactor*inst->font_width, inst->font_height);
}
void do_cursor(Context ctx, int x, int y, char *text, int len,
struct gui_data *inst = dctx->inst;
GdkGC *gc = dctx->gc;
- int passive;
+ int passive, widefactor;
if (attr & TATTR_PASCURS) {
attr &= ~TATTR_PASCURS;
}
do_text_internal(ctx, x, y, text, len, attr, lattr);
+ if (attr & ATTR_WIDE) {
+ widefactor = 2;
+ } else {
+ widefactor = 1;
+ }
+
if (lattr != LATTR_NORM) {
x *= 2;
if (x >= inst->term->cols)
return;
- if (x + len*2 > inst->term->cols)
- len = (inst->term->cols-x)/2; /* trim to LH half */
+ if (x + len*2*widefactor > inst->term->cols)
+ len = (inst->term->cols-x)/2/widefactor;/* trim to LH half */
len *= 2;
}
y*inst->font_height+cfg.window_border,
x*inst->font_width+cfg.window_border,
y*inst->font_height+cfg.window_border,
- len*inst->font_width, inst->font_height);
+ len*widefactor*inst->font_width, inst->font_height);
}
GdkCursor *make_mouse_ptr(struct gui_data *inst, int cursor_val)
strncpy(cfg.boldfont, val, sizeof(cfg.boldfont));
cfg.boldfont[sizeof(cfg.boldfont)-1] = '\0';
+ } else if (!strcmp(p, "-fw")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg.widefont, val, sizeof(cfg.widefont));
+ cfg.widefont[sizeof(cfg.widefont)-1] = '\0';
+
+ } else if (!strcmp(p, "-fwb")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg.wideboldfont, val, sizeof(cfg.wideboldfont));
+ cfg.wideboldfont[sizeof(cfg.wideboldfont)-1] = '\0';
+
} else if (!strcmp(p, "-cs")) {
EXPECTS_ARG;
SECOND_PASS_ONLY;
set_font_info(inst, 1);
} else
inst->fonts[1] = NULL;
+ if (cfg.widefont[0]) {
+ inst->fonts[2] = gdk_font_load(cfg.widefont);
+ if (!inst->fonts[2]) {
+ fprintf(stderr, "pterm: unable to load wide font \"%s\"\n",
+ cfg.boldfont);
+ exit(1);
+ }
+ set_font_info(inst, 2);
+ } else
+ inst->fonts[2] = NULL;
+ if (cfg.wideboldfont[0]) {
+ inst->fonts[3] = gdk_font_load(cfg.wideboldfont);
+ if (!inst->fonts[3]) {
+ fprintf(stderr, "pterm: unable to load wide/bold font \"%s\"\n",
+ cfg.boldfont);
+ exit(1);
+ }
+ set_font_info(inst, 3);
+ } else
+ inst->fonts[3] = NULL;
inst->font_width = gdk_char_width(inst->fonts[0], ' ');
inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent;