Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Cyrillic fonts for allegro

Credits go to DanielH, Evert, gnolam, Kirr, Matt Smith, miran, and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
Cyrillic fonts for allegro
Thomas Fjellstrom
Member #476
June 2000
avatar

or use grabber's fonst script loading.. Just enter the correct info into a textfile and import as a FONT.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

DanielH
Member #934
January 2001
avatar

Can you do that with two different sets of values?

The font should contain 224 characters:

176: 0x20 - 0xcf
48: 0x410 - 0x44f

Thomas Fjellstrom
Member #476
June 2000
avatar

Thats what that font loader is for, to load more than one charater range into the same allegro FONT. Unfortunately I don't know the format of the file the grabber wants.. but I'm sure someone around does.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Kirr
Member #5,060
September 2004
avatar

Wow, what a mess to just output text. How much easier it is to use TTF directly in your program. Also it lets you change the text size on-the-fly and see how it looks without re-running TTF2PCX, re-grabbing it with grabber etc..

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

miran
Member #2,407
June 2002

Daniel, Thomas: I already told him all that, but as usual he ignored it.

--
sig used to be here

Evert
Member #794
November 2000
avatar

Quote:

testfont.pcx 0x20 0x7F
testfont.pcx 0x400 0x44F

Use a dash (-) for the second file name and see if that helps.

Quote:

You have to use ttf2pcx and use a paint program to combine them.

No, you don't.

Quote:

Unfortunately I don't know the format of the file the grabber wants.. but I'm sure someone around does.

I posted the relevant link in my first post in this thread. Miran posted the format as well.

Nedjalko Milenkov
Member #5,394
January 2005

I did not used Paint program, but I think that the Font Editor is good too. Now I have one PCX file with English and Cyrillic, but when I write something and use unicode, I do see some strainght signs. How does allegro understand what part of the picture for an example "A" is?

Evert
Member #794
November 2000
avatar

Have a look at [url http://alleg.sourceforge.net/onlinedocs/en/index017.html#load_bitmap_font] for a description of how the font should formatted in the bitmap.

Nedjalko Milenkov
Member #5,394
January 2005

Somehow using ttf2pcx and Font Editor I`v managed to make a compilation - see the attached file, but when including it in my program, and print cyr. I see some unrecognized strings althought I have input cyrillic.

miran
Member #2,407
June 2002

How did you write your font script? And how did you enter the text? Extended ASCII or Unicode?

--
sig used to be here

Nedjalko Milenkov
Member #5,394
January 2005

Quote:

How did you write your font script? And how did you enter the text? Extended ASCII or Unicode?

I do not have font script. I just use data file. I use Unicode.

miran
Member #2,407
June 2002

For the millionth time, YOU NEED A FONT SCRIPT!!!!!!!!!!!!!!!!!! Scroll up this thread and pick a random post to see how it's done....

--
sig used to be here

Nedjalko Milenkov
Member #5,394
January 2005

miran - Arrrrrr...how can I explain that I CAN NOT USE A SCRIPT!
I load into the grabber font.txt which contains:
font.pcx 0x0020 0x007F
and the program says Could not load font.pcx. And when I add it manual to the data file it loads it, but in my program there is no cyr :(.
Is it too hard to say how realy is done, not some non working ideas.

P.S. Sorry if I sound too rude, but 4 days for Unicode seems too much!
There must be a way, but I found no tutorial which explaint HOW it is done.

P.S. 1 I do not use load_font because in version 4.0 there is no such function and ver. 4.1 is beta.

Evert
Member #794
November 2000
avatar

Quote:

Arrrrrr...how can I explain that I CAN NOT USE A SCRIPT!

I don't know, but you should try to say it before shouting.

Quote:

I load into the grabber font.txt which contains:
font.pcx 0x0020 0x007F
and the program says Could not load font.pcx.

That looks ok. Can you post the exact script and font file?

Quote:

P.S. 1 I do not use load_font because in version 4.0 there is no such function and ver. 4.1 is beta.

True, but the description of the font formats is the same as for the grabber, as I said in my first post.

Nedjalko Milenkov
Member #5,394
January 2005

Sorry for the "shouting", but ...
In the zip file is the script and the image.

miran
Member #2,407
June 2002

I found two errors:

1. There needs to be a space between - and the number in the second line
2. The contents of the script must match the contents of the pcx file!

EDIT: Attached is arial.ttf converted to pcx with my FontEditor at size 36 with no antialiasing and two ranges: normal ASCII and the cyrillic characters. Also in the zip is a working font script for this pcx and the whole font packaged as a dat file.

--
sig used to be here

Nedjalko Milenkov
Member #5,394
January 2005

I thought that they match ???
This is an extraction fon ttf2pcx and the range is the hole font. And with the script I want to include only two parts - eng and cyr.
What should I change in the pcx?

miran
Member #2,407
June 2002

I edited while you were posting. See my example in the post above...

--
sig used to be here

Nedjalko Milenkov
Member #5,394
January 2005

Thanks for the file, but again my grabber says that "I can not read arialfonts.pcx", but when I include the arialfonts.pcx direct from the PCX there is no problem at all :(. I`v tested the compiled data.dar and with set_uformat( U_UTF8 ); shows only ^^^ :(

miran
Member #2,407
June 2002

Quote:

my grabber says that "I can not read arialfonts.pcx", but when I include the arialfonts.pcx direct from the PCX there is no problem at all

First of all, the file I made was called arialcyr.pcx. Secondly, you need to put both files, arialcyr.txt and arialcyr.pcx in the same directory. Then load grabber, select object->new->font. Then grab the txt file. There should be no errors. If you do get errors, then your grabber is defected...

Quote:

I`v tested the compiled data.dar and with set_uformat( U_UTF8 ); shows only ^^^ :(

You need to call set_uformat(U_UNICODE) to be able to use that font, just
like the Unicode example.

EDIT:
If you want to continue using U_UTF8 (which btw is the default so you don't have to set it explicitely), you need to remap the glyphs in the font a bit. How exactly depends on the codepage you're using...

--
sig used to be here

Nedjalko Milenkov
Member #5,394
January 2005

It seems that my grabber is full of bugs :(

but with your datafile and with set_uformat(U_UNICODE); does not works
here is the code of a simple program

1/* UltraBlocks ver.:0.1
2 * By the ultimate and unforgiven game TETRIS
3 * Coder Nedjalko Milenkov
4 * e-mail redspace[at]bg-webmaster.com
5 * Just wait to see the final version :)
6 * Whats new: The whole code :)
7 */
8
9#include <allegro.h>
10 
11#include "data.h"
12 
13DATAFILE *data;
14FONT *myfont;
15 
16//The MAIN FUNCTION
17int main(void){
18char buf[512];
19 
20 allegro_init();
21
22 install_keyboard();
23
24 set_color_depth(16);
25
26 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)!=0)
27 {
28 set_color_depth(15);
29 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)!=0){
30 allegro_message("Unable initialize graphics module\n%s\n", allegro_error);
31 return -1;
32 }
33 }
34
35
36
37 BITMAP *buffer=create_bitmap(SCREEN_W, SCREEN_H);
38
39 if(buffer==NULL){
40 allegro_message("Sorry, not enough memory.");
41 allegro_exit();
42 exit(2);
43 }
44
45 data=load_datafile("arialcyr.dat");
46
47 if (!data) {
48 allegro_message("Unable to load %s\n");
49 return -1;
50 }
51 
52//set_uformat( U_UTF8 );
53//set_uformat(U_ASCII_CP);
54set_uformat(U_UNICODE);
55 
56
57 uconvert("Ïðîãðàìèðàíå dd", U_ASCII, buf, U_CURRENT, sizeof( buf ));
58 textprintf_centre(screen, data[0].dat, 300, 100, makecol( 255, 255, 255), buf);
59
60 //blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
61
62 readkey();
63
64 return 0;
65}
66END_OF_MAIN()

Thomas Fjellstrom
Member #476
June 2000
avatar

set_uformat should go BEFORE allegro_init() IIRC.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Nedjalko Milenkov
Member #5,394
January 2005

I tried it but it does not work :(, but when I put to the screen this "\x14\x04" ">\x04" , which is from the allegro example it works, but when I use uconvert("Ïðîãðàìèðàíå", U_ASCII, buf, U_UNICODE, sizeof( buf ));, there is no cyr output. This is 30% solution, because I do not want to write like "\x14\x04" only for one alphabet :(.

miran
Member #2,407
June 2002

You probably need to setup a codepage conversion table:

void set_ucodepage(const unsigned short *table, const unsigned short *extras);

--
sig used to be here

Nedjalko Milenkov
Member #5,394
January 2005

miran I do not think that I am the first man using unicode. Is there something done? And why when I used some already done PCX(from one site for beginers) it works?

 1   2   3 


Go to: