IdreesInc / Monocraft

A monospaced programming font inspired by the Minecraft typeface
https://idreesinc.com
SIL Open Font License 1.1
8.02k stars 115 forks source link

TTY compatible format for font #138

Open sophronesis opened 4 months ago

sophronesis commented 4 months ago

It would be sweet to get version of monocraft, that can be used as tty font (for example, when system boots up). i'm talking about setfont command and fonts in /usr/share/kbd/consolefonts. UPD: Tried to do it myself with bdf2psf and otf2bdf, but got unreadable font.

Dheatly23 commented 4 months ago

What the format is? It might be exportable by FontForge.

Edit: Yes, it is exportable (just change the output file extension in monocraft.py). But i can't confirm if it's usable or not.

SpomJ commented 3 months ago

What the format is? It might be exportable by FontForge.

Edit: Yes, it is exportable (just change the output file extension in monocraft.py). But i can't confirm if it's usable or not.

While it is possible, i tried "just changing output file extension" and... it just didn't export it. I'm sure there are methods to get this to work, but this should be done by someone who knows how to font (which i do not).

I also tried to do this using fontforge on a ttf, but some pixels duplicate in width for some reason ( ._.)

I think it might be easier to just parse the matrix in json files into .psf directly. Like seriously, try on scientifica for example:

sudo bdf2psf --fb scientifica-11.bdf /usr/share/bdf2psf/standard.equivalents /usr/share/bdf2psf/fontsets/Lat2.256 256 a.psf
xxd -b -c1 a.psf | tr '1' '#' | tr '0' ' ' | less

The output is literally just bitmap font, more compact than jsons used.

Some lines this outputs ``` 2c : . 2c█: . 2c2: . 2c3: . 2c4: ████ . 2c5: . 2c6: ████ . 2c7: . 2c8: . 2c9: . 2ca: . 2cb: . 2cc: . 2cd: . 2ce: █ @ 2cf: █ 2d : █ . 2d█: █ 2d2: █ @ 2d3: . 2d4: . 2d5: . 2d6: . 2d7: ██ ` 2d8: █ █ . 2d9: █ . 2da: █ 2db: █ @ 2dc: . 2dd: █ @ 2de: . 2df: . 2e : . 2e█: . 2e2: ██ ` 2e3: █ █ . 2e4: █ ██ . 2e5: █ ██ . 2e6: █ ██ . 2e7: █ . 2e8: ███ p 2e9: . 2ea: . ```
Dheatly23 commented 3 months ago

Did you do something like this?

diff --git a/src/monocraft.py b/src/monocraft.py
index 8e8069c..15b434d 100644
--- a/src/monocraft.py
+++ b/src/monocraft.py
@@ -357,7 +357,7 @@ def generateFont(*, black=False, bold=False, semibold=False, light=False, extral
     for font in fontList:
         if font is None:
             continue
-        font.generate(f"{outputDir}{font.fontname}.otf")
+        font.generate(f"{outputDir}{font.fontname}.psf")

     if output_ttc:
         fontList[0].generateTtc(

At least it exports on my end.

SpomJ commented 3 months ago

Oh, you can just export it into psf directly? Strange, because fontforge app can't. Though if you read what's inside, it is obviously not what it's supposed to be. Even if you skip headers (which there shouldn't be), the xxd shows just noise. I tried to convert to bdf first, knowing fontforge app can do that, but i guess there need to be some special options set before.

setfont also complains about wrong size.

SpomJ commented 3 months ago

Actually i'm wondering if you can just make a little header and parse the json by hand