The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Article Feedback - Customizing Console Fonts
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Previous Message  |  Next Message 
 more info
Author: Greg Smith 
Date:   28-10-01 19:19

(posted by Dan Langille)

I was very excited to read the Customizing Console Fonts item, because I
thought it would help me with my own desire to mix characters from two
different fonts. I knew how to change the font used, via vidcontrol, but
not about the handy fontedit port.

[font project: including CP437 graphic characters into an ISO-8859-1 font.
I "enhanced" cdplay to use graphics characters instead of +,| etc., but
don't like the CP437 letters.]

Unfortunately, fontdump can't read FreeBSD's proprietary encoded format. So
I looked into how vidcontrol deals with them, and found decode.c. I rewrote
it as a standalone program - fontdecode.c - which can be used to convert a
FreeBSD .fnt file into one that fontdump will accept, i.e. a standard VGA
font file.


The code is here:
========= fontdecode.c ===========
<PRE>
#include <stdio.h>
#include <string.h>

int main()
{
int n, pos = 0;
char *p;
char temp[128];
char buffer[4096];

#define DEC(c) (((c) - ' ') & 0x3f)

do {
if (!fgets(temp, sizeof(temp), stdin))
return(0);
} while (strncmp(temp, "begin ", 6));
sscanf(temp, "begin %o %s", &n, temp);
for (;;) {
if (!fgets(p = temp, sizeof(temp), stdin))
return(0);
if ((n = DEC(*p)) <= 0)
break;
for (++p; n > 0; p += 4, n -= 3)
if (n >= 3) {
buffer[pos++] = DEC(p[0])<<2 | DEC(p[1])>>4;
buffer[pos++] = DEC(p[1])<<4 | DEC(p[2])>>2;
buffer[pos++] = DEC(p[2])<<6 | DEC(p[3]);
}
else {
if (n >= 1) {
buffer[pos++] =
DEC(p[0])<<2 | DEC(p[1])>>4;
}
if (n >= 2) {
buffer[pos++] =
DEC(p[1])<<4 | DEC(p[2])>>2;
}
if (n >= 3) {
buffer[pos++] =
DEC(p[2])<<6 | DEC(p[3]);
}
}
}
if (!fgets(temp, sizeof(temp), stdin) || strcmp(temp, "end\n"))
return(0);
for (n = 0; n < pos; n++)
putchar(buffer[n]);
return(pos);
}
</PRE>
=========================================
[The credit for this code goes to Soren. I just adapted it. I guess I
should have left the copyright notice in there. See vidcontrol/decode.c]

 Reply To This Message  |  Forum List  |  Flat View   Newer Topic  |  Older Topic 

 Topics Author  Date
 more info   new
Greg Smith 28-10-01 19:19 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org