shithub: riscv

Download patch

ref: 4d919ab612f61c1ef1b21d41513f264d57c010d4
parent: ccfb6f412643128d5a537df73805c8478f0a24ae
author: mischief <[email protected]>
date: Fri Oct 12 04:31:05 EDT 2018

truetypefs: use /lib/font/ttf as default font path

--- a/sys/src/cmd/truetypefs.c
+++ b/sys/src/cmd/truetypefs.c
@@ -9,6 +9,8 @@
 static char Egreg[] = "my memory of truetype is fading";
 static char Enoent[] = "not found";
 
+static char *fontpath = "/lib/font/ttf";
+
 enum { MAXSUB = 0x100 };
 
 typedef struct TFont TFont;
@@ -219,7 +221,11 @@
 		goto inval;
 	buf = estrdup9p(name);
 	buf[d - name] = 0;
-	ttf = ttfopen(buf, sz, 0);
+	p = smprint("%s/%s", fontpath, buf);
+	if(p == nil)
+		sysfatal("smprint: %r");
+	ttf = ttfopen(p, sz, 0);
+	free(p);
 	if(ttf == nil){
 		free(buf);
 		return nil;
@@ -420,12 +426,22 @@
 	.destroyfid = fsdestroyfid,
 };
 
+static void
+usage(void)
+{
+	fprint(2, "usage: %s [-F fontpath]\n", argv0);
+	exits("usage");
+}
+
 void
 main(int argc, char **argv)
 {
 	ARGBEGIN {
+	case 'F':
+		fontpath = EARGF(usage());
+		break;
 	default:
-		sysfatal("usage");
+		usage();
 	} ARGEND;
 	
 	unmount(nil, "/n/ttf");