LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-13-2016, 11:18 PM   #1
billy_bazooka
LQ Newbie
 
Registered: Aug 2016
Posts: 26

Rep: Reputation: Disabled
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)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Returns to options of Create a document & Create a folder ramia Linux - Software 4 12-20-2015 12:39 PM
[SOLVED] Cannot create VirtualBox hd image - VBoxManage: error: Failed to create hard disk Vanyel Linux - Software 1 01-10-2013 09:06 AM
how create create extreme limited user ss4sgoku Linux - Newbie 5 10-28-2012 01:17 AM
How to create bridge and how to create hub? Grawp Linux - Networking 5 04-22-2007 05:10 AM
Linux, Create Dirs=no, Create files=yes. Possible? tisource Linux - General 4 01-12-2004 10:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration