aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/draw
diff options
context:
space:
mode:
authorXiao-Yong Jin <xjin@anl.gov>2018-03-22 23:16:53 -0500
committerDavid du Colombier <0intro@gmail.com>2018-03-27 15:16:10 +0200
commit96025b1ec8916c986fb691db79ae96d4f690c8f1 (patch)
tree7b2f25ed4dc37e6adfd5ef44e3b502fdd13658b7 /src/cmd/draw
parent75ea8515a5cd26817b4eb5de99eeb6934def9328 (diff)
downloadplan9port-96025b1ec8916c986fb691db79ae96d4f690c8f1.tar.gz
plan9port-96025b1ec8916c986fb691db79ae96d4f690c8f1.tar.bz2
plan9port-96025b1ec8916c986fb691db79ae96d4f690c8f1.zip
mc: fix crash in acme with hidpi display
Diffstat (limited to 'src/cmd/draw')
-rw-r--r--src/cmd/draw/mc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/cmd/draw/mc.c b/src/cmd/draw/mc.c
index c24d67b3..ea36e28d 100644
--- a/src/cmd/draw/mc.c
+++ b/src/cmd/draw/mc.c
@@ -268,8 +268,8 @@ void
getwidth(void)
{
CFsys *fs;
- char buf[500], *p, *q, *f[10];
- int fd, n, nf;
+ char buf[500], *p, *q, *f[10], *fname;
+ int fd, n, nf, scale;
struct winsize ws;
Font *f1;
@@ -285,15 +285,19 @@ getwidth(void)
buf[n] = 0;
if((nf=tokenize(buf, f, nelem(f))) < 7)
return;
+ // hidpi font in stringwidth(3) will call scalesubfont,
+ // which aborts in bytesperline, due to unknow depth,
+ // without initdraw. We scale by ourselves.
+ scale = parsefontscale(f[6], &fname);
tabwid = 0;
- if(nf >= 8 && (tabwid = atoi(f[7])) == 0)
+ if(nf >= 8 && (tabwid = atoi(f[7])/scale) == 0)
return;
- if((font = openfont(nil, f[6])) == nil)
+ if((font = openfont(nil, fname)) == nil)
return;
mintab = stringwidth(font, "0");
if(tabwid == 0)
tabwid = mintab*4;
- linewidth = atoi(f[5]);
+ linewidth = atoi(f[5]) / scale;
tabflag = 1;
return;
}