Re: [AD] Unicode example program

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


On Sat, 30 Jun 2001, Eric Botcazou wrote:
> I've coded a little example program that demonstrates the use of the 16-bit
> Unicode format: http://www.multimania.com/ebotcazou/dev/exunicod.zip
> 
> Should it be included in the lib, given that the datafile size is ~50k ?

It's a really nice example, and there's no other unicode example
available, so I vote yes. Another possibility would be to extend Allegro's
demo to show messages in the different languages. I could do the
translations for spanish then. Maybe it's a lot of work for a simple demo,
but it would be cool to see the demo texts in japanese :)

The example works better with the following patch because it doesn't
depend on screen resolution, and I have successfully tested it from
256x200 to 1152x864 (on the low res you see only half messages, but it's
still ok). 

BTW, maybe you should delete the spanish message, since it just shows the
usual 7-bit ascii characters. Replace it with something more exotic, like
Klingon :-) 

--- exunicod.c	Sat Jun 30 03:10:52 2001
+++ exunicod.c.new	Sat Jun 30 10:11:42 2001
@@ -89,8 +89,8 @@
    }
 
    /* set the graphics mode */
-   if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
-      allegro_message(uconvert_ascii("Unable to set a 640x480x8 mode", tmp));
+   if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) {
+      allegro_message(uconvert_ascii("Unable to set a graphic mode", tmp));
       return -1;
    }
 
@@ -104,7 +104,7 @@
 
    /* get a handle to the Unicode font */
    f = data[UNIFONT].dat;
-   height = text_height(f) + 16;
+   height = MAX (text_height(f) + 8, SCREEN_H / NLANGUAGES);
 
    /* prepare the bitmaps */
    for (i=0; i<NLANGUAGES; i++) {
@@ -127,7 +127,7 @@
       pos[i] = ((float)rand()/RAND_MAX) * SCREEN_W;
       mesg_bmp[i] = create_system_bitmap(length[i], height);
       clear_to_color(mesg_bmp[i], makecol(255, 255, 255));
-      textout(mesg_bmp[i], f, mesg, 8, 4, makecol(0, 0, 0));
+      textout(mesg_bmp[i], f, mesg, 8, 1, makecol(0, 0, 0));
 
       free(mesg);
    }
@@ -135,10 +135,10 @@
    /* do the scrolling */
    while (!keypressed()) {
       for (i=0; i<NLANGUAGES; i++) {
-         blit(mesg_bmp[i], screen, 0, 0, pos[i], 40+i*height, length[i], height);
+         blit(mesg_bmp[i], screen, 0, 0, pos[i], (height / 2) + i*height, length[i], height);
          delta = pos[i] + length[i] - SCREEN_W;
          if (delta > 0)
-            blit(mesg_bmp[i], screen, length[i] - delta, 0, 0, 40+i*height, delta, height);
+            blit(mesg_bmp[i], screen, length[i] - delta, 0, 0, (height / 2) + i*height, delta, height);
 
          pos[i] += step[i];
          if (pos[i] >= SCREEN_W)



--
 Grzegorz Adam Hankiewicz   gradha@xxxxxxxxxx   http://gradha.infierno.org



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