Re: [AD] translucent fonts

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, 2006-01-05 at 12:17 +0100, Evert Glebbeek wrote:
> Very cute! This will only work for true and high colour fonts, right?
> Some questions and one nit-picking:

Actually, it should work also with paletted ones, but I didn't test it.
Basically I added a mode where fonts are drawn using draw_trans_sprite
instead of draw_character or mask_blit - you have to set up the trans
blender you want yourself (in my case, I use an alpha TGA as font and
set_alpha_blender as blender).

> Shouldn't there be a get_font_translucency() function? Right now, you can
> do it by doing trans = set_font_trans(random); set_font_trans(trans); but
> that's sortof ugly.
> Am I correct in thinking that you could get the same effect without
> changing Allegro by using a custom font vtable (I think you can)? If so,
> would it be an idea to have a function that changes a FONT's vtable to a
> `translucent_font' vtable? Just brainstorming here!

I guess that could also work. So it would be like:

make_font_translucent(font);

And there would be a 3rd vtable, with a new "color_render" entry, and
the above would simply modify the vtable of the font (ASSERTing that it
is a color font). I guess it's better than a state.

> -   if (bitmap_color_depth(bmp) == 8) {
> -      c = 255;
> -   }
> -   else {
> -      c = makecol_depth(bitmap_color_depth(bmp), 255, 255, 0);
> -   }
> +   c = getpixel(bmp, 0, 0);
> Does this break existing fonts? I think not because I think all fonts are
> required to have an outline around the entire image already, but I'd like
> to have that confirmed.

If I understand font_find_character right, it always looks for something
like this (c is the background color):

cc
c*

So there must always be a border, even for the first character. It can
break if a font bitmap looks like this:

ggg
gcc
gc*

Where g is some garbage. The current font reader would see * as the
top-left pixel of the first glyph, ignoring the garbage.

One way around that would be to only use the top-left corner pixel as
background color for 32-bit alpha fonts, and keep 0 for 8-bit and yellow
for 15/16/24-bit and opaque 32-bit ones.

-- 
Elias Pschernig





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/