aboutsummaryrefslogtreecommitdiff
path: root/src/libmemdraw
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2018-11-15 23:52:05 -0500
committerRuss Cox <rsc@swtch.com>2018-11-16 00:03:24 -0500
commit16d00819899260085ee10949012b07bf1c203db6 (patch)
tree540151e0f43ef7e08255d31f5c68b4100c783b93 /src/libmemdraw
parent3ebbb99ce3b13357f4dfb0156877c6e5892de5aa (diff)
downloadplan9port-16d00819899260085ee10949012b07bf1c203db6.tar.gz
plan9port-16d00819899260085ee10949012b07bf1c203db6.tar.bz2
plan9port-16d00819899260085ee10949012b07bf1c203db6.zip
libdraw: redo default font construction to be hidpi-safe
If $font is not set, the default font is constructed from font data linked into every libdraw binary. That process was different from the usual openfont code, and so it was not hidpi-aware, resulting in very tiny fonts out of the box on hidpi systems, until users set $font. Fix this by using openfont to construct the default font, by recognizing the name *default* when looking for font and subfont file contents. Then all the hidpi scaling applies automatically. As a side effect, the concept of a 'default subfont' is gone, as are display->defaultsubfont, getdefont, and memgetdefont.
Diffstat (limited to 'src/libmemdraw')
-rw-r--r--src/libmemdraw/defont.c68
-rw-r--r--src/libmemdraw/mkfile1
2 files changed, 0 insertions, 69 deletions
diff --git a/src/libmemdraw/defont.c b/src/libmemdraw/defont.c
deleted file mode 100644
index 21ea6cc0..00000000
--- a/src/libmemdraw/defont.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-
-Memsubfont*
-getmemdefont(void)
-{
- char *hdr, *p;
- int n;
- Fontchar *fc;
- Memsubfont *f;
- int ld;
- Rectangle r;
- Memdata *md;
- Memimage *i;
-
- /*
- * make sure data is word-aligned. this is true with Plan 9 compilers
- * but not in general. the byte order is right because the data is
- * declared as char*, not u32int*.
- */
- p = (char*)defontdata;
- n = (uintptr)p & 3;
- if(n != 0){
- memmove(p+(4-n), p, sizeofdefont-n);
- p += 4-n;
- }
- ld = atoi(p+0*12);
- r.min.x = atoi(p+1*12);
- r.min.y = atoi(p+2*12);
- r.max.x = atoi(p+3*12);
- r.max.y = atoi(p+4*12);
-
- md = mallocz(sizeof(Memdata), 1);
- if(md == nil)
- return nil;
-
- p += 5*12;
-
- md->base = nil; /* so freememimage doesn't free p */
- md->bdata = (uchar*)p; /* ick */
- md->ref = 1;
- md->allocd = 1; /* so freememimage does free md */
-
- i = allocmemimaged(r, drawld2chan[ld], md, nil);
- if(i == nil){
- free(md);
- return nil;
- }
-
- hdr = p+Dy(r)*i->width*sizeof(u32int);
- n = atoi(hdr);
- p = hdr+3*12;
- fc = malloc(sizeof(Fontchar)*(n+1));
- if(fc == 0){
- freememimage(i);
- return 0;
- }
- _unpackinfo(fc, (uchar*)p, n);
- f = allocmemsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i);
- if(f == 0){
- freememimage(i);
- free(fc);
- return 0;
- }
- return f;
-}
diff --git a/src/libmemdraw/mkfile b/src/libmemdraw/mkfile
index a8c32ff5..5668ea43 100644
--- a/src/libmemdraw/mkfile
+++ b/src/libmemdraw/mkfile
@@ -10,7 +10,6 @@ OFILES=\
cload-stub.$O\
cmap.$O\
cread.$O\
- defont.$O\
draw.$O\
draw-stub.$O\
ellipse.$O\