Page 1 of 2
Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 6:21 am
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
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 6:27 am
by quanganht
Fixed size bitmap font. It's super easy, you can DIY without any help.
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 6:29 am
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.
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 6:35 am
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.
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 7:03 am
by Owen
Or implement FreeType. It's API is actually quite reasonable
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 7:51 am
by quanganht
Owen wrote:Or implement FreeType. It's API is actually quite reasonable
He said it's too complex (to him) at first.
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 7:56 am
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
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 9:06 am
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.
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 2:57 pm
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.
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 3:35 pm
by koo5
freaky line font!
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 6:06 pm
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)
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 7:52 pm
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
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 9:48 pm
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
Re: Which font type is the easiest one to parse & render
Posted: Sun Mar 14, 2010 10:09 pm
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.
Re: Which font type is the easiest one to parse & render
Posted: Mon Mar 15, 2010 12:52 am
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.