nanogui: Thread: TrueType not using specified background


[<<] [<] Page 1 of 1 [>] [>>]
Subject: TrueType not using specified background
From: Junior ####@####.####
Date: 12 Jun 2008 20:30:50 -0000
Message-Id: <A9F2C099DA2.00000561ejr@inbox.com>

Hi,
Is their some design reason why truetype fonts do not use the background color specified in gc?
The other bitmap fonts do use it but I'm not sure why not ttf fonts. The background color is simply ignored.

Is this something the that needs to be done in nano-X devfonts code or is it something that I need to build into the freetype library? Perhaps someone intimately familiar with the library build parameters can say whether the latte is possible.

Thanks,
Jr.
Subject: Re: [nanogui] TrueType not using specified background
From: "Greg Haerr" ####@####.####
Date: 13 Jun 2008 01:52:22 -0000
Message-Id: <004301c8ccf8$654b0470$6401a8c0@winXP>

> Is their some design reason why truetype fonts do not use the background 
> color specified in gc?
The other bitmap fonts do use it but I'm not sure why not ttf fonts.

Sounds like a bug, although interesting nobody has found it...  try 
modifying
the src/demo/nanox fontdemo?.c app that draws text around a circle,
lets use a non-white background.  Thinking about this I'll bet that
all TTF drawing occurs without drawing any background...


> Is this something the that needs to be done in nano-X devfonts code or is 
> it something that I need to build into the freetype library?

No, this would be done in the devfont.c code.  There are two options:
when the background is set to ON, then you can either clear the
background with a GdFillRect first, then let the engine draw
the glyph foreground bits only, or have the engine draw the glyph
foreground and background bits. I suggest using the former; internal
builtin fonts are displayed using the latter (its pretty slow drawing
each bit, TTF uses a blit unlike builtin fonts)

Since TTF allows text to be displayed at an angle, I'm betting that
this is why its not implemented.  The simple case would be to
implement it only for non-angled text only.

Regards,

Greg 

Subject: Re: [nanogui] TrueType not using specified background
From: Junior ####@####.####
Date: 13 Jun 2008 16:28:59 -0000
Message-Id: <B46A3653B34.0000028Fejr@inbox.com>

> -----Original Message-----
> From: ####@####.####
> Sent: Thu, 12 Jun 2008 19:54:19 -0600
> To: ####@####.#### ####@####.####
> Subject: Re: [nanogui] TrueType not using specified background
> 
>> Is their some design reason why truetype fonts do not use the background
>> color specified in gc?
> The other bitmap fonts do use it but I'm not sure why not ttf fonts.
> 
> Sounds like a bug, although interesting nobody has found it...  try
> modifying
> the src/demo/nanox fontdemo?.c app that draws text around a circle,
> lets use a non-white background.  Thinking about this I'll bet that
> all TTF drawing occurs without drawing any background...
> 
> 
>> Is this something the that needs to be done in nano-X devfonts code or
>> is
>> it something that I need to build into the freetype library?
> 
> No, this would be done in the devfont.c code.  There are two options:
> when the background is set to ON, then you can either clear the
> background with a GdFillRect first, then let the engine draw
> the glyph foreground bits only, or have the engine draw the glyph
> foreground and background bits. I suggest using the former; internal
> builtin fonts are displayed using the latter (its pretty slow drawing
> each bit, TTF uses a blit unlike builtin fonts)
> 
> Since TTF allows text to be displayed at an angle, I'm betting that
> this is why its not implemented.  The simple case would be to
> implement it only for non-angled text only.

Hi Greg,
I added the lines to GdDrawAreaInternal since it appears that only freetype2 uses this function:

if (gr_usebg)
        {
            psd->FillRect(psd, x, y, x + width - 1, y + height - 1,
                gr_background);
        }

This is a start with two problems:
The first problem here is that the bitmap is not fixed and only where the fonts are drawn the background is drawn.
If I can use FillRect on the entire string length then I can clear the area before writing the text.
This is not easy because the space character (0x20) is not written as a blank space, it onlu advances the cursor.
Is their a way round this?
The other problem is I'll need to define a total height which would be considering all the characters in the string.
Is their a method already implemented to do this?

Thanks,
Jr.
Subject: Re: [nanogui] TrueType not using specified background
From: Junior ####@####.####
Date: 13 Jun 2008 21:26:28 -0000
Message-Id: <B70311C6384.000004F6ejr@inbox.com>


> -----Original Message-----
> From: ####@####.####
> Sent: Fri, 13 Jun 2008 08:28:49 -0800
> To: ####@####.#### ####@####.####
> Subject: Re: [nanogui] TrueType not using specified background
> 
>> -----Original Message-----
>> From: ####@####.####
>> Sent: Thu, 12 Jun 2008 19:54:19 -0600
>> To: ####@####.#### ####@####.####
>> Subject: Re: [nanogui] TrueType not using specified background
>> 
>>> Is their some design reason why truetype fonts do not use the
>>> background
>>> color specified in gc?
>> The other bitmap fonts do use it but I'm not sure why not ttf fonts.
>> 
>> Sounds like a bug, although interesting nobody has found it...  try
>> modifying
>> the src/demo/nanox fontdemo?.c app that draws text around a circle,
>> lets use a non-white background.  Thinking about this I'll bet that
>> all TTF drawing occurs without drawing any background...
>> 
>> 
>>> Is this something the that needs to be done in nano-X devfonts code or
>>> is
>>> it something that I need to build into the freetype library?
>> 
>> No, this would be done in the devfont.c code.  There are two options:
>> when the background is set to ON, then you can either clear the
>> background with a GdFillRect first, then let the engine draw
>> the glyph foreground bits only, or have the engine draw the glyph
>> foreground and background bits. I suggest using the former; internal
>> builtin fonts are displayed using the latter (its pretty slow drawing
>> each bit, TTF uses a blit unlike builtin fonts)
>> 
>> Since TTF allows text to be displayed at an angle, I'm betting that
>> this is why its not implemented.  The simple case would be to
>> implement it only for non-angled text only.
> 
> Hi Greg,
> I added the lines to GdDrawAreaInternal since it appears that only
> freetype2 uses this function:
> 
> if (gr_usebg)
>         {
>             psd->FillRect(psd, x, y, x + width - 1, y + height - 1,
>                 gr_background);
>         }
> 
> This is a start with two problems:
> The first problem here is that the bitmap is not fixed and only where the
> fonts are drawn the background is drawn.
> If I can use FillRect on the entire string length then I can clear the
> area before writing the text.
> This is not easy because the space character (0x20) is not written as a
> blank space, it onlu advances the cursor.
> Is their a way round this?
> The other problem is I'll need to define a total height which would be
> considering all the characters in the string.
> Is their a method already implemented to do this?

Hi Greg,
I think I'm almost their. I haven't determing how efficient this patch is yet but so far it seems the best way to do it.
I've added this to freetype2_drawtext:
        
        freetype2_gettextsize(pfont, text, cc, flags, &fnt_w, &fnt_h, &fnt_b);
        if (gr_usebg)
        {
            psd->FillRect(psd, ax, ay-fnt_b-4, ax+fnt_w, ay+fnt_h-4, gr_background);
        }
I'm trying to iron out some issues with TFTOP, TFBOTTOM & TFBASELINE. The above is for BASELINE and I think when it's done I'll have to add some condition statements to take care of the others.
Any comments?

Regards,.
Jr.








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

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
Check it out at http://www.inbox.com/marineaquarium
Subject: Re: [nanogui] TrueType not using specified background
From: "Greg Haerr" ####@####.####
Date: 19 Jun 2008 04:42:25 -0000
Message-Id: <029401c8d1c6$522fc010$2f01a8c0@HaydenLake>

> The first problem here is that the bitmap is not fixed and only where the 
> fonts are drawn the background is drawn.
> If I can use FillRect on the entire string length then I can clear the 
> area before writing the text.

I don't understand your "not fixed" issue above.


> This is not easy because the space character (0x20) is not written as a 
> blank space, it onlu advances the cursor.

Was this fixed with your latest patch?

Regards,

Greg

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


Powered by ezmlm-browse 0.20.