Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Cyrillic font problem

This thread is locked; no one can reply to it. rss feed Print
Cyrillic font problem
Bob Bobosky
Member #7,151
April 2006

Hello

Please , help me with cyrillic font ( ttf , not pcx file )

I try use Glyph Keeper:

1#include "allegro.h"
2#include "glyph.h"
3#include <stdio.h>
4 
5 GLYPH_FACE *face;
6 GLYPH_REND *rend;
7 
8int main()
9{
10char *ch;
11 
12 set_uformat(U_ASCII);
13 allegro_init();
14 set_color_depth(32);
15 set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0);
16 clear_to_color(screen,0xFFFFFF);
17 install_keyboard();
18 
19 ch="Test: CYRILLIC TEXT";
20 face = gk_load_face_from_file("bera.ttf",0);
21 if (!face) exit(1);
22 
23 rend = gk_create_renderer(face,0);
24 if (!rend) exit(2);
25 
26 gk_rend_set_size_pixels(rend,40,40);
27 gk_rend_set_text_alpha_color(rend,0xFF000000);
28 gk_render_line_utf8(screen,rend,ch,225,325);
29 
30 readkey();
31 
32 return 0;
33}
34END_OF_MAIN()

But it show me like this:

Test: ? ? ? ? ? ? ? ? ?

http://www.hostfornet.net/vasilevs/test.png

Help

DanielH
Member #934
January 2001
avatar

Have you tried different unicode formats besides U_ASCII?

Bob Bobosky
Member #7,151
April 2006

Yes
I try all:
U_ASCII - fixed size, 8-bit ASCII characters
U_ASCII_CP - alternative 8-bit codepage (see set_ucodepage())
U_UNICODE - fixed size, 16-bit Unicode characters
U_UTF8 - variable size, UTF-8 format Unicode characters

but nothing :-(

By the way . I see your posts in forum. Can we talk online by ICQ etc. ?
I have some questions but my english very poor :-)

DanielH
Member #934
January 2001
avatar

Sorry, but I don't use ICQ.

I don't use GlyphKeeper, so I'm not sure if this is relevant.

From this website:
http://agdn.netfirms.com/main/html/unicode.htm

U_CURRENT is set to U_UTF8

void utextout( BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color )
{
    char buf[ 512 ];
    if ( need_uconvert( s, U_ASCII, U_CURRENT ) )
    {
        uconvert( s, U_ASCII, buf, U_CURRENT, sizeof( buf ) );
    }
    else
    {
        strcpy( buf, s );
    }
    textout( bmp, f, buf, x, y, color );
}

Using GK, would you need to convert it like this function would?

gnolam
Member #2,030
March 2002
avatar

U_ASCII just plain won't work, that much is obvious.

My instinct is "unconverted text", but if Daniel's advice doesn't help: please attach the font you're using - I've come across Cyrillic TTF fonts that were mapped to weird (KOI-8 or similar) encodings instead of standard Unicode...

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Bob Bobosky
Member #7,151
April 2006

Thank you guys !
This code work for me:

show_text(char *text,int *text_size_wh,int *text_size_hi,int *text_wh,int *text_hi,int color){

    if ( need_uconvert( text , U_ASCII , U_UTF8  ) ){
       uconvert( text , U_ASCII , buf , U_UTF8  , sizeof( buf ) );
       text=&buf;
    }

    gk_rend_set_size_pixels(rend,text_size_wh,text_size_hi);
    gk_rend_set_text_alpha(rend,255);
    gk_rend_set_text_color(rend,colors[color].r,colors[color].g,colors[color].b);
    gk_render_line_utf8(buffer,rend,text ,text_wh,text_hi);               
}

But i correct font by font editor :-)

Go to: