Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTY compatible format for font #138

Open
sophronesis opened this issue Feb 25, 2024 · 5 comments
Open

TTY compatible format for font #138

sophronesis opened this issue Feb 25, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@sophronesis
Copy link

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.

@sophronesis sophronesis added the enhancement New feature or request label Feb 25, 2024
@Dheatly23
Copy link
Contributor

Dheatly23 commented Feb 26, 2024

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
Copy link

SpomJ commented Mar 17, 2024

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
Copy link
Contributor

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
Copy link

SpomJ commented Mar 18, 2024

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
Copy link

SpomJ commented Mar 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants