summaryrefslogtreecommitdiff
path: root/zwgc/xmark.c
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1989-11-16 11:01:45 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1989-11-16 11:01:45 +0000
commit8f584233fe214b869276652c50018c5f408e9c2d (patch)
tree0000aa5ee5aefd09e00eb460f99ee6d5288ec3a7 /zwgc/xmark.c
parent6cb5bbbf28a363b08dc30543c9603709708a5fc5 (diff)
fix bug with null derefs on font->per_char for fixed width fonts.
Diffstat (limited to 'zwgc/xmark.c')
-rw-r--r--zwgc/xmark.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/zwgc/xmark.c b/zwgc/xmark.c
index ab36923..e20586f 100644
--- a/zwgc/xmark.c
+++ b/zwgc/xmark.c
@@ -114,13 +114,15 @@ void xmarkSetBound(gram,x,y,which)
font=get_fontst_from_fid(xb->fid);
for (i=0,s=((gram->text)+(xb->strindex));
xofs<x && i<xb->strlen;
- i++,s++)
- if (x<=(xofs+=font->per_char[*s - font->min_char_or_byte2].width)) {
+ i++,s++) {
+ /* if font->per_char is NULL, then we should use min_bounds */
+ short usewidth = font->per_char ? font->per_char[*s - font->min_char_or_byte2].width : font->min_bounds.width;
+ if (x <= (xofs+=usewidth)) {
markchar[which]=i;
- markpixel[which]=xofs-xb->x1-
- font->per_char[*s - font->min_char_or_byte2].width;
+ markpixel[which]=xofs - xb->x1 - usewidth;
RETURN;
}
+ }
}
}