nanogui: Thread: Add Native font in compiler phase


[<<] [<] Page 1 of 1 [>] [>>]
Subject: Add Native font in compiler phase
From: ####@####.#### ####@####.####
Date: 30 Nov 2006 16:42:05 +0000
Message-Id: <J9JYDD$76802605151B116EC9A990E5155CA71F@libero.it>

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

Thanks


------------------------------------------------------
Cosa fai a Natale e Capodanno? Parti con Expedia: prima prenoti, piĆ¹ risparmi! Scopri subito tutte le offerte!
http://click.libero.it/Expedia_30nov06


Subject: Re: [nanogui] Add Native font in compiler phase
From: "Greg Haerr" ####@####.####
Date: 30 Nov 2006 21:18:30 +0000
Message-Id: <033901c714c5$0f6c5820$0300a8c0@RDP>

> 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

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: ####@####.####

Subject: Re: [nanogui] Add Native font in compiler phase
From: "Greg Haerr" ####@####.####
Date: 6 Dec 2006 23:20:06 +0000
Message-Id: <06d601c7198d$1bf36e90$0300a8c0@RDP>

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

Thanks, nice description.



:
: 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?

Assuming nano-X API:
fontid = GrCreateFont("Arial", 17, NULL);
GrSetGCFont(wid, font);

You'll need to have another fontid for the default
font, which is called "System"


: 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.

Better yet, find .bdf source from a free font distribution,
and use tools/convbdf -c filename.  This option also allows
creating a .fnt file using the -f option which then doesn't
require anything to be linked into the server,but loaded
on demand.


:
: 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.

Or, change the source to cnvfnt32.c ,and recompile the tool.



: 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!!

See above, and look at all those font demos I wrote:
src/demo*.sh, src/demos/nanox.

Regards,

Greg



[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.