nanogui: Add Native font in compiler phase


Previous by date: 1 Dec 2006 21:56:58 +0000 come back from VTSWITCH, roberto\.bielli\.inwind\.it
Next by date: 1 Dec 2006 21:56:58 +0000 ttf font with fltk, Gianluca Moro
Previous in thread: 1 Dec 2006 21:56:58 +0000 Re: Add Native font in compiler phase, Greg Haerr
Next in thread: 1 Dec 2006 21:56:58 +0000 Re: Add Native font in compiler phase, Greg Haerr

Subject: RES: [nanogui] Add Native font in compiler phase
From: "Ricardo P. Jasinski" ####@####.####
Date: 1 Dec 2006 21:56:58 +0000
Message-Id: <20061201050925.295AF955C@thialf.cpdtt.cefetpr.br>

Hi all, 

I tried to put together the few steps necessary to add a new compiled-in
font in microwindows/nano-x. Hope it helps.

Also, if anyone could give me a hint, I would like to know how to switch the
default font used when drawing a window. I mean, I would like to draw half
the screen using one font, and the other half with a different font. Can
anyone give me a brief description on how to do that?

Cheers,

Ricardo.

-------------------------------------------------------------------------
Step-by-step tutorial for adding compiled-in fonts in microwindows/nano-x
-------------------------------------------------------------------------
by Ricardo Jasinski

Step 1. Obtain a c-source file for the new font. In windows, this can be
bone using the convfnt32.exe tool, for example. You can find this tool in
src/fonts/tools. At this point, you will specify the font size and attibutes
(bold, italic, etc.). Be sure to respect font owner's copyrights.

Step 2. Throw the resulting c-file (say, winArial4x12.c) in the src/fonts
folder. You might want to fix the declaration of the offset table (look for
the comment /* Character->glyph data. */) from 'static unsigned short' to
'static unsigned long', as suggested by Greg.

Step 3. Make note of your new font structure name, as you'll be using it
later. In the case, it would be font_winArial4x12, and it would be located
at the bottom of the file winArial4x12.c. Note: you can have as many fonts
in the src/fonts folder as you want, and as long as they are not used by the
rest of your code they won't take up any memory in your system.

Step 4. Announce your new font to the rest of the code. This is done by
editing the src/drivers/genfont.c file. You should add:

    extern MWCFONT font_winArial4x12;

right below the comment line /* compiled in fonts*/. Also, expand your
genfonts table with a new font entry. Add as a last element the line:

    {&fontprocs, 0, 0, 0, "Arial", &font_winArial4x12}

Then, increase the NUM_FONTS definition in genfont.h line #11. In my case,
it increased from the default value of 4 to 5. That's it. Your new font is
already in the system.

(**Stopgap**) Step 5. Test your new font into the system. One
quick-and-dirty way of doing this would be replacing the first entry in the
genfonts table (file genfont.c, line #72) with the newly created font:

  MWCOREFONT gen_fonts[NUMBER_FONTS] = {
    {&fontprocs, 0, 0, 0, MWFONT_SYSTEM_VAR, &font_winArial4x12},
    ...
  }

Note: a better approach would be changing your default font in compile time
using the specific nano-x functions, but for now I don't know how to do
this. Any ideas? Thanks!!

One last hint: you'll probably have better results with convfnt32.exe if you
turn off you operating system's anti-aliasing capabilities (clear type,
etc.).

That's it!!



-----Mensagem original-----
De: Greg Haerr ####@####.#### 
Enviada em: quinta-feira, 30 de novembro de 2006 19:18
Para: ####@####.#### nanogui
Assunto: Re: [nanogui] Add Native font in compiler phase

> How can i add a .c trasformed with convfnt32.exe font when i compile
Nano-X and in which files?

The MWCFONT structure name is added to the initialized incore font array in
drivers/genfont.c.  You'll of course have to modify the drivers/Makefile
stuff also.

Regards,

Greg


---------------------------------------------------------------------
To unsubscribe, e-mail: ####@####.####
For additional commands, e-mail: ####@####.####


Previous by date: 1 Dec 2006 21:56:58 +0000 come back from VTSWITCH, roberto\.bielli\.inwind\.it
Next by date: 1 Dec 2006 21:56:58 +0000 ttf font with fltk, Gianluca Moro
Previous in thread: 1 Dec 2006 21:56:58 +0000 Re: Add Native font in compiler phase, Greg Haerr
Next in thread: 1 Dec 2006 21:56:58 +0000 Re: Add Native font in compiler phase, Greg Haerr


Powered by ezmlm-browse 0.20.