Which font type is the easiest one to parse & render

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Which font type is the easiest one to parse & render

Post by torshie »

Hi all,
After switching to VESA mode, I got another problem: I need some type of font do display with. I just googled the TrueType, find out it is a super complex font format(for a hobby OS). So, anyone knows some type of font which is easier to parse and render.

Cheers
torshie
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: Which font type is the easiest one to parse & render

Post by quanganht »

Fixed size bitmap font. It's super easy, you can DIY without any help. :wink:
"Programmers are tools for converting caffeine into code."
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Which font type is the easiest one to parse & render

Post by Combuster »

The easiest way is a fixed size bitmap font. You turn the "on" pixels into foreground colour and "off" pixels into background color (or transparent), and you can just add a constant amount of pixels for every cell moved horizontally or vertically.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: Which font type is the easiest one to parse & render

Post by quanganht »

Two "Fixed size bitmap font" reply at almost the same time! :)
Well, Combuster's way is good, but I don't like doing "on" and "off" for every pixel. You can simply do it by constructing your own bitmap font and then use memcpy (You should have implemented this function so far) to copy directly from the bitmap to video memory. It is faster and easier.
"Programmers are tools for converting caffeine into code."
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Which font type is the easiest one to parse & render

Post by Owen »

Or implement FreeType. It's API is actually quite reasonable ;-)
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: Which font type is the easiest one to parse & render

Post by quanganht »

Owen wrote:Or implement FreeType. It's API is actually quite reasonable ;-)
He said it's too complex (to him) at first.
"Programmers are tools for converting caffeine into code."
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Which font type is the easiest one to parse & render

Post by Brendan »

Hi,

Fixed size bitmap fonts are easy to parse and render if you want something that looks like fixed size bitmap fonts.

Once you decide you want something that looks good, fixed size bitmap fonts become complex (e.g. bilinear scaling with anti-aliasing); and it becomes even more complex if you want to do it reasonably quickly. It's also a little expensive in terms of memory usage because you get much better results with much larger font data (8*8 characters scaled up to 60*80 looks like crap, but 128*256 characters scaled down to 60*80 can look good), and you'll probably want to pre-generate font data at different sizes to avoid the overhead of repeatedly rescaling (or at least maintain a cache of already scaled font data). For a rough estimate; about 1 million unicode characters with 128*256 bits per character (or 4 KiB per character) works out to about 4 GiB of data (ignoring things like bold/italic, etc)...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Which font type is the easiest one to parse & render

Post by Love4Boobies »

Instead of investing time in creating high-resolution bitmap fonts (it is a lot of work), I'd recommend outline fonts. It will look better on every size and you will end up saving time because you don't have to work as much on fonts.

If you want something that you know will always be displayed on the same resolution and will have the same size, this might provide an answer. It's a bitmap font so it's easy to parse.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Which font type is the easiest one to parse & render

Post by bewing »

I do not think anyone has come up yet with the "ultimate font format". I tend to think that stroke fonts using spline fitting for curves (plus antialiasing) is probably superior to all the current methods -- which means that there really IS NO good method currently. It needs much more research, and for the moment you just have to pick something and run with it.
koo5
Posts: 2
Joined: Fri Sep 11, 2009 3:09 pm

Re: Which font type is the easiest one to parse & render

Post by koo5 »

freaky line font!

Image
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Which font type is the easiest one to parse & render

Post by Owen »

quanganht wrote:
Owen wrote:Or implement FreeType. It's API is actually quite reasonable ;-)
He said it's too complex (to him) at first.
He said TrueType was too difficult to implement by hand. FreeType, on the other hand, should be reasonably implementable, as it just depends on an ANSI C library (and you need one of those anyway, so investing in that is useful)
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: Which font type is the easiest one to parse & render

Post by quanganht »

Owen wrote:He said TrueType was too difficult to implement by hand. FreeType, on the other hand, should be reasonably implementable, as it just depends on an ANSI C library (and you need one of those anyway, so investing in that is useful)
Sorry, I made a really quick skim so I thought you was talking about TrueType
"Programmers are tools for converting caffeine into code."
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Re: Which font type is the easiest one to parse & render

Post by torshie »

Thanks for all the replies.

I need to support Chinese, so DIY my own font file is impractical, I have to support some type of public available font file.
Maybe I should spend some time on porting FreeType. FreeType source code is more than 1M, it got to cost some serious time :shock:
User avatar
osdnlo
Member
Member
Posts: 136
Joined: Thu Feb 25, 2010 5:39 pm

Re: Which font type is the easiest one to parse & render

Post by osdnlo »

It may be easier to DIY your own font style. How many characters are in your alphabet? For my project, I simply created my font file based on ms serif (I like it, it looks clean), I wrote a simple html application to help me create it. The format is like this:

0x00 means end of line
0x01 means place dot
0x02 means move right one unit

My font file is pretty big, I also include special characters in my font, so I just load it from CD along with my other resources like images, configuration files, etc.

My font is displayed 10pt by default and can be sized dynamically, and the bold, italics, etc are done with code tricks, so I just need one file with both upper and lower case characters and the rest my code handles.

However, if you can port an already made font then why not, it will save you a lot of time.
Yes, I see that you have proven it, but my question was, 'How did you know that would work?'.
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Re: Which font type is the easiest one to parse & render

Post by torshie »

osdnlo wrote:It may be easier to DIY your own font style. How many characters are in your alphabet? For my project, I simply created my font file based on ms serif (I like it, it looks clean), I wrote a simple html application to help me create it. The format is like this:

0x00 means end of line
0x01 means place dot
0x02 means move right one unit

My font file is pretty big, I also include special characters in my font, so I just load it from CD along with my other resources like images, configuration files, etc.

My font is displayed 10pt by default and can be sized dynamically, and the bold, italics, etc are done with code tricks, so I just need one file with both upper and lower case characters and the rest my code handles.

However, if you can port an already made font then why not, it will save you a lot of time.
If only support English characters, DIY your own font is possible and much easier than porting FreeType. But I want to support Chinese(my mother tongue), thousands of characters are commonly used, so it's impractical to DIY a font as large as this.
Post Reply