LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to create gohufont_12x22 from gohufont_6x11? (https://www.linuxquestions.org/questions/programming-9/how-to-create-gohufont_12x22-from-gohufont_6x11-4175591375/)

billy_bazooka 10-13-2016 11:18 PM

how to create gohufont_12x22 from gohufont_6x11?
 
I want to create gohufont 12x22 font.
I have gohufont-11.bdf file. I used bdf2raw tool and created gohufont-11.raw file.
The font is 6x11, which means it uses (1 byte for width) X (11 bytes for height) X (256 characters) = 2816 bytes.

I want to create 12x22 font. Basically just double the original font in width and height.
So, the formula is this.
Original 6x11 font is like this:
--------
--------
-###----
#---#---
----#---
---#----
--#-----
-#------
#####---
--------
--------

For every bit in the original font I create 2 bits in the new font. Then i double the line like this:
----------------
----------------
----------------
----------------
--######--------
--######--------
##------##------
##------##------
--------##------
--------##------
------##--------
------##--------
----##----------
----##----------
--##------------
--##------------
##########------
##########------
----------------
----------------
----------------
----------------
That is 12x22 raw file.

This is the c program to do the conversion. I called it fd (font doubler).
Code:

#include <stdio.h>
int main (int argc, char **argv)
{
  int c;
  int n1, n2; /* new byte 1, new byte 2 */
  while ((c = getchar ()) != EOF)
  {
    /* from the left 4 bits, we create 8 bits */
    n1 = ((c&128)<<8) | ((c&128)<<7) | ((c&64)<<7) | ((c&64)<<6) | ((c&32)<<6) | ((c&32)<<5) | ((c&16)<<5) | ((c&16)<<4);
    /* from the right 4 bits, we create another 8 bits */
    n2 = ((c&8)<<4) | ((c&8)<<3) | ((c&4)<<3) | ((c&4)<<2) | ((c&2)<<2) | ((c&2)<<1) | ((c&1)<<1) | ((c&1)<<0);
    putchar (n1);
    putchar (n2);
    putchar (n1);
    putchar (n2);
  }
  return 0;
}

So I type:
Code:

./fd < gohufont-11.raw > gohufont-12x22.raw
Then I use:
Code:

raw2psf --height=22 --width=12 gohufont-12x22.raw gohufont-12x22.psf
Then I wanted to test it by gzipping it and using it in xterm. But no go.
Not working. Did I mess up something? Is my C code bad?

Sorry for the long post, but how to create gohu_12x22?
Can someone help me with this?
(original .bdf gohu files are at https://github.com/hchargois/gohufont)


All times are GMT -5. The time now is 01:38 AM.