Autor Tema: Mod_ttf  (Leído 14176 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
  • Sexo: Masculino
    • Ver Perfil
Mod_ttf
« en: Octubre 10, 2009, 03:00:30 pm »
There were some bugs in the older mod_ttf or something; well at least the one I and some others had. So I packaged a new one with freetype 2.3.5 and it actually works.

See: http://wiki.bennugd.org/index.php?title=Mod_ttf
-- Sandman

Conectado DCelso

  • Hero Member
  • *****
  • Mensajes: 3708
  • Karma: 180
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #1 en: Octubre 10, 2009, 03:21:53 pm »
Ohh, testing.
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

Conectado DCelso

  • Hero Member
  • *****
  • Mensajes: 3708
  • Karma: 180
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #2 en: Octubre 10, 2009, 04:29:09 pm »
I have changed the examples of the wiki, updating they to the new format.
It goes very well in 16 bits mode, but if  you try to load in 32 bits mode the ttf_loadaa does not load well the font and colors. You can try the effect using the new example of the ttf_load tha I put in the wiki changing set_mode(320,200,16) by this other set_mode(320,200,32)
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

Desconectado Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #3 en: Octubre 10, 2009, 06:35:37 pm »
Yes this may be a problem, didn't think of it. I gave it a brief look and fixed the 16bit on 32bit failure. 32bit fonts in 32bit mode still doesn't work though...

Upload new version ( http://wiki.bennugd.org/images/2/29/Mod_ttf.zip ).

Good job on the examples.

[EDIT]
And 32bit in 32bit mode is also fixed now.
« última modificación: Octubre 10, 2009, 06:47:56 pm por Sandman »
-- Sandman

Conectado DCelso

  • Hero Member
  • *****
  • Mensajes: 3708
  • Karma: 180
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #4 en: Octubre 11, 2009, 05:20:17 am »
Yeah, now runs well in all modes.
Karma up.
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

Desconectado Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
  • Sexo: Masculino
    • Ver Perfil
    • TRINIT Asociación de Informáticos de Zaragoza
Re: Mod_ttf
« Respuesta #5 en: Octubre 11, 2009, 05:26:12 am »
wait wait wait...

Sorry for my english but... I think you are talking about .ttf fonts support for Bennu.

DCelso was working on a 32 bits FNT editor, but it only had an option in order to establish a constant alpha on shadow and border...

.ttf is an "almost" vectorial format, and curves can estabish the correct alpha in ALL pixels... The curvature is PERFECT. A .ttf is a TRUE font... I have just downloaded the new DLL, I'm very excited.

Cooking a karma...
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Desconectado Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
  • Sexo: Masculino
    • Ver Perfil
    • TRINIT Asociación de Informáticos de Zaragoza
Re: Mod_ttf
« Respuesta #6 en: Octubre 11, 2009, 05:53:39 am »
Dudes, I have just installed mod_ttf (copy+paste), but I don't know how to use a .ttf file.

I hope there was a FUNCTION load_ttf ( string ) and I can use write ( ) as always using the load_ttf identifier as first parameter.

Please, copy+paste any code you have used, it will be very helpful :P

(Still cooking the karma, trust me)
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Desconectado Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #7 en: Octubre 11, 2009, 06:29:08 am »
That is how it works, yes.

On the mod_ttf page you will find two functions:
ttf_load(STRING filename , INT height), also called load_ttf()
ttf_loadaa(STRING filename , INT height , INT colordepth , INT backgroundcolor , INT textcolor), also called load_ttfaa()

They both return a fontID of a newly generated font, using the TTF file and other settings.
-- Sandman

Conectado DCelso

  • Hero Member
  • *****
  • Mensajes: 3708
  • Karma: 180
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #8 en: Octubre 11, 2009, 07:28:36 am »
Yes, I tested the examples of the wiki with the president ttf file and they work well.
Splinter left the president ttf link in the topic of the bennu3d logo
http://forum.bennugd.org/index.php?action=dlattach;topic=128.0;attach=435
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

Desconectado Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
  • Sexo: Masculino
    • Ver Perfil
    • TRINIT Asociación de Informáticos de Zaragoza
Re: Mod_ttf
« Respuesta #9 en: Octubre 11, 2009, 08:42:16 am »
Ok, I'm testing it now... Sandman, if it works well I'll invite all Bennu comunity to give you a Karma.

It will be a Karmageddon xD
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Desconectado josebita

  • Administrator
  • Hero Member
  • *****
  • Mensajes: 4039
  • Karma: 257
  • Sexo: Masculino
    • Ver Perfil
    • BennuGD Mobile Worklog
Re: Mod_ttf
« Respuesta #10 en: Octubre 11, 2009, 09:20:40 am »
Great, Sandman!

This was really needed. :)

Conectado DCelso

  • Hero Member
  • *****
  • Mensajes: 3708
  • Karma: 180
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #11 en: Octubre 11, 2009, 09:49:40 am »
Is possible to do that the background were a little bigger or it could be configurable?
And
Is possible to do an offset in x and y to the background, similar to fntedit do currently?
« última modificación: Octubre 11, 2009, 09:54:25 am por DCelso »
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

Desconectado Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #12 en: Octubre 11, 2009, 12:34:11 pm »
There's no such thing as a background actually. The 'bg' color is used to perform anti-aliasing, nothing more. It cannot be moved. Of course you can build this functionality, but that would be a new functionality.

For some reason write_in_map() doesn't like 32bit mode, in that it doesn't work... after many hours of trying to build Bennu, and finally succeeding by using codeblocks, I'm giving up. Never ask me to build Bennu again...  :-\
Anyway, here's the code. It's all yours, Splinter. You may have to change the TTF file path:
Código: [Seleccionar]
import "mod_text"
import "mod_key"
import "mod_ttf"
import "mod_video"
import "mod_map"
import "mod_draw"
import "mod_say"

Process Main()
Private
int f;
int* ip;
int i;
Begin

set_mode(320,240,32);
frame;
f = ttf_loadx("C:\Windows\fonts\vladimir.ttf",40,32,rgba(255,255,255,255),rgba(255,255,255,0),0);

map_clear(0,0,rgb(0,255,0));
drawing_map(0,graph);
drawing_color(rgb(255,0,0));
draw_box(100,100,200,200);
graph = write_in_map(f,"HELLOLLO",0);
say("depth: " + map_info(0,graph,G_DEPTH));
write(f,10,10,0,"HELLOLLO");

x = 50;
y = 50;
size = 400;

ip = map_buffer(0,graph);
for(i=0;i<20; i++)
ip[i] = 080FFFFFFh;
end

While(!key(_ESC))
frame;
End

End

[EDIT]
I should note that TTF_LoadX() is a new function. I actually wanted to add more parameters, but then I got fed up with the write_in_map() issue. ;)
« última modificación: Octubre 11, 2009, 12:50:26 pm por Sandman »
-- Sandman

Conectado DCelso

  • Hero Member
  • *****
  • Mensajes: 3708
  • Karma: 180
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #13 en: Octubre 11, 2009, 02:11:12 pm »
For testing the new ttf_loadx I did a new example
Código: [Seleccionar]
import "mod_key"
import "mod_proc"
import "mod_map"
import "mod_video"
import "mod_ttf"
import "mod_text"
import "mod_screen"
global
  int id_ttfs[4];
  int id_bg;
  int depth = 16;
Begin
    set_mode(320,240,depth);
    id_bg = new_map(320,240,depth);
    map_clear(0,id_bg,RGB(0,255,0));
    put_screen(0,id_bg);
    id_ttfs[0] = load_ttf("resources/presdntn.ttf",48);
    id_ttfs[1] = load_ttfaa("resources/presdntn.ttf",48,depth,RGBA(255,0,0,255),RGBA(255,0,0,0));
    id_ttfs[2] = ttf_loadx("resources/presdntn.ttf",48,depth,RGBA(0,0,255,255),RGBA(0,0,255,0),1);
    id_ttfs[3] = ttf_loadx("resources/presdntn.ttf",48,depth,RGBA(0,0,255,255),RGBA(0,0,255,0),100);
    id_ttfs[4] = ttf_loadx("resources/presdntn.ttf",48,depth,RGBA(0,0,255,255),RGBA(0,0,255,0),255);
    write(id_ttfs[0],25,30,0,"Hello");
    set_text_color(rgb(255,0,255));
    write(id_ttfs[0],155,30,0,"World");
    write(id_ttfs[1],25,130,0,"Bye");
    write(id_ttfs[2],155,90,0,"World");
    write(id_ttfs[3],155,130,0,"World");
    write(id_ttfs[4],155,170,0,"World");
    Repeat
        frame;
    Until(key(_ESC))

    unload_fnt(id_ttfs[4]);
    unload_fnt(id_ttfs[3]);
    unload_fnt(id_ttfs[2]);
    unload_fnt(id_ttfs[1]);
    unload_fnt(id_ttfs[0]);
    unload_map(0,id_bg);
End
Then I discovered a strange thing. If you try the example with depth=16 it work well (or it is that I think), but if you try the example with depth=32, the id_ttfs[2] and the id_ttfs[3] get the same result instead of a different result.
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

Desconectado Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
  • Sexo: Masculino
    • Ver Perfil
Re: Mod_ttf
« Respuesta #14 en: Octubre 11, 2009, 02:23:11 pm »
Try a different font, because they are different here.
-- Sandman