Page 1 of 1

About font renderers..

Posted: Mon May 15, 2006 4:02 am
by mystran
I was looking at status of various projects, and noticed Clicker website says it uses Candy's font renderer, and I'm wondering, why aren't you people using Freetype, which need not depend on much of anything? Assuming ofcourse that Candy's doesn't do full truetype.

Since there is a free set of acceptable looking sans, serif and monospace fonts in truetype format (http://www.gnome.org/fonts/) available since a few years now, you might want to consider. Since the above gives you full basic set of system fonts, and having Truetype rendering out of box lets users use their own fonts, the only complication I can see is dealing with variable width fonts.

As it is, dealing with variable width fonts isn't terribly complicated, and freetype site has a nice tutorial for doing it with kerning and all. You people should take a look.

Disclaimer: I haven't tried running freetype under my own OS yet (I'm missing a few more things before I can write a video-server), but my experience from using it for a small X toolkit experiment is that it is relatively easy to hack into a anything.

Oh, about the vera fonts: They are designed to work nicely in small sizes when anti-aliased without hinting (or at least they do), so they work fine without the legally difficult opcodes, but the downside is that they don't have proper hinting to display small fonts nicely without anti-aliasing.


I'm sure you all knew this, just reminding you, 'cos it shouldn't be hard to get proper truetype rendering these days. ;)

Re:About font renderers..

Posted: Mon May 15, 2006 4:50 am
by distantvoices
sure I know about freetype. have not yet found the time to incorporate it into my os. Need to do lots of reworking in the gui/uilib stuff.

Stay SAfe :-)

Re:About font renderers..

Posted: Mon May 15, 2006 6:44 am
by mystran
FYI, I took a look at porting Freetype to new OS.

The system dependant code is in src/base/ftsystem.c, which is a total of 303 lines long (and even that is mostly comments). Just just malloc wrappers, and simple stream-system for reading font files.

In addition to that, certain amount of OS independent standard library functions are used. They are listed in /include/freetype/config/ftstdlib.h which groups all the ISO C includes into once place, and lists defines with ft_ prefix for all the required functions, making life easy. Almost all of it is rather trivial, with sprintf, qsort, and setjmp/longjmp being the hardest to code.

I'd say that even without C library available, wrapping it would take a day or two at most. And even most kernels contain over half of the required standard library functions.

Re:About font renderers..

Posted: Mon May 15, 2006 7:49 am
by Pype.Clicker
mystran wrote: I was looking at status of various projects, and noticed Clicker website says it uses Candy's font renderer, and I'm wondering, why aren't you people using Freetype, which need not depend on much of anything? Assuming ofcourse that Candy's doesn't do full truetype.
No, candy's renderer doesn't do truetypes at all. And for the very simple reason that he kindly wrote it on request with the goal of being extremely simple.

TrueType fonts are significantly trickier to render. I mean by there you need floating math, more memory (a cache of rendered characters for given resolutions would most definitely speedup the drawing, for instance), and more processing power (rendering on QEMU may be overkill, f.i.)

That doesn't imply TTF are evils and do not belong an OS. That just means Clicker's support for graphical mode is still too young to support these (not speaking about the still-under-development support for usermode).

The question i was facing was "if there's a kernel panic while in graphical mode, can we afford using freetype ?" -- and my answer was "no: we need something KISS for that purpose".
Yet, at the time of writing, if there's a kernel panic in graphical Clicker, all you get is the screen turning to green or to red and being shifted on the right by some resolution-dependent amount, and there's noone to render fonts anyway :P

Re:About font renderers..

Posted: Mon May 15, 2006 10:48 am
by Candy
mystran wrote: I was looking at status of various projects, and noticed Clicker website says it uses Candy's font renderer, and I'm wondering, why aren't you people using Freetype, which need not depend on much of anything? Assuming ofcourse that Candy's doesn't do full truetype.
Not even close to truetype rendering. I made it because I have a genuine preference for code that has my copyrights on it so I can't blame anybody else for bugs, and I get to understand it better. Also, imho, TrueType is a kind of really bloated format, especially including the hints. It's completely sufficient for any case, which is why I don't like it. I'd like a polygon-based format that you can prerender for display etc. One that's quick to display, not able to do all.

It's mainly the complexity I'm against. Complexity allows for tiny bugs you don't notice except for some very awkward conditions and it allows (commonly) for some form of scripting, which again commonly results in exploits being created. Just keep the complexity out of my stuff, I'll be happy then.

Re:About font renderers..

Posted: Mon May 15, 2006 2:32 pm
by mystran
Actually, unless you are willing to accept antialiasing of small fonts, and the fuzzyness that comes with that, or really ugly fontshapes, you either need:

- hand-crafter bitmap fonts, which can't be scaled
- proper hinting

The principal reason fonts look good on systems where they look good (like Windows), is that they are properly hinted.

Vera is surprisingly readable with anti-aliasing instead of hinting, though. AFAIK, that's because hinting can't be officially part of the open desktops like Gnome (even if everybody compiles with it enabled anyway, to get Windows fonts look right), because of the patent trouble.

I don't necessarily disagree; truetype isn't the simplest possible format. But proper hinting is a good thing.

And sure you can do prerendering, at least for scripts where letter shape doesn't vary based on previous characters. ;)

Re:About font renderers..

Posted: Mon May 15, 2006 2:34 pm
by mystran
I want to add that I do intend to have a really simple bitmap based font renderer as well, exactly for the purpose of drawing things like kernel panics on screen when the graphics code has crashed, and all I have is hopefully some linear framebuffer address and the screen width.

Re:About font renderers..

Posted: Mon May 15, 2006 9:45 pm
by LongHorn
The true type fonts shall be rendered at first by any rendering engines then store the image in a bitmap format and use those fonts just like anyother bitmap fonts by that way you will have a nice looking font. This will be a temporary solution for those who are interested in truetype fonts.
If somebody could do this plz post it here. Now i am using some pd font posted by pype.
@pype: You posted font with capital letters(font 8x8) and i need corresponding small letters also.

Re:About font renderers..

Posted: Mon May 15, 2006 10:34 pm
by mystran
Storing bitmapped versions of truetype fonts is like eating dried fruit. Sure, they are edible, but if you can have the original, what's the point.

Re:About font renderers..

Posted: Mon May 15, 2006 11:05 pm
by LongHorn
Not a big deal just a temporary solution for those who are not just yet ready to incorporate freetype into their kernel. It needs a lot more services which have not yet been explored by most of us. I think so. I don't want to get trouble. I have a lot of things to worry about then adding true type support.

Re:About font renderers..

Posted: Tue May 16, 2006 2:59 am
by Pype.Clicker
LongHorn wrote: @pype: You posted font with capital letters(font 8x8) and i need corresponding small letters also.
they aren't there so far ... i mean, that font initially included pacman and ghosts, but no lowercase, nor symbols i saw no use for such as "@" or "=" ... I heard your prayer and will come with a more complete charset when spare time will come back.

Re:About font renderers..

Posted: Tue May 16, 2006 3:31 am
by mystran
There's 8x8 fonts in rather trivial format in linux console packages, if you just need some font. Pick a one you like, so you can deal with a real font later.. :)