9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [Patch] enable tweak(1) to expand subfonts
@ 2024-12-04  6:37 Oliver Simmons
  0 siblings, 0 replies; only message in thread
From: Oliver Simmons @ 2024-12-04  6:37 UTC (permalink / raw)
  To: 9front

I assume this worked sometime in the past, as all the scaffolding is there.

Currently, decreasing the value of n in tweak(1) may shrink subfonts,
but increasing the value has no useful effect.
This is because the characters are given zero width, and any attempt
to open these characters fails.

This change makes it so new characters copy the width & properties of
the last character.

For ease of reading, note is it impossible (from within tweak?) to
create a 0-length subfont,
and that subfonts really do have n+1 characters, the extra one's
position is used to tell the width
of the last character.  See cachechars(2).

---
diff afe12c32f3368c088e82fdd4274408eaf68d14e2 uncommitted
--- a/sys/src/cmd/tweak.c
+++ b/sys/src/cmd/tweak.c
@@ -940,7 +940,7 @@
     Fontchar *fc, *nfc;
     Rectangle r;
     ulong chan;
-    int i, ld, d, w, c, doredraw, fdx, x;
+    int i, ld, d, w, c, doredraw, fdx, xi;
     Thing *nt;

     buttons(Up);
@@ -1139,8 +1139,12 @@
                 goto again;
             }
         r = t->b->r;
+        fc = f->info;
+        xi = fc[f->n].x - fc[f->n-1].x;
         if(w < f->n)
-            r.max.x = f->info[w].x;
+            r.max.x = fc[w].x;
+        else
+            r.max.x = fc[f->n].x + xi * (w - f->n);
         b = allocimage(display, r, t->b->chan, 0, 0);
         if(b == 0)
             goto nobmem;
@@ -1160,14 +1164,12 @@
             freeimage(b);
             return;
         }
-        fc = f->info;
         for(i=0; i<=w && i<=f->n; i++)
             nfc[i] = fc[i];
-        if(w+1 < i)
-            memset(nfc+i, 0, ((w+1)-i)*sizeof(Fontchar));
-        x = fc[f->n].x;
-        for(; i<=w; i++)
-            nfc[i].x = x;
+        for(; i<=w; i++){
+            nfc[i] = fc[f->n-1];
+            nfc[i].x = nfc[i-1].x + xi;
+        }
         f = allocsubfont(t->name, w, f->height, f->ascent, nfc, b);
         if(f == 0)
             goto nofmem;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-04  6:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-04  6:37 [9front] [Patch] enable tweak(1) to expand subfonts Oliver Simmons

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).