Jump to content

Make Cyrrilic Font in LE [SOLVED]


Umnik
 Share

Recommended Posts

I make cyrillic fonts in Font Studio.

 

I used the instruction: http://www.leadwerks.com/wiki/index.php?title=LoadFont

 

As a result, I do not see not a single letter in the text.

 

Using SetBlend (1) the text disappears completely.

 

SetFont(LoadFont("abstract::cyrrilic"));
...
...
DrawText(0,100,"Test Cyrrilic: Привет медвед!");

 

my font file: http://dev.ramgames.ru/temp/font.rar

post-170-12672213038112_thumb.jpg

Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS

Resource War Developer [ dev blog ]

Link to comment
Share on other sites

i find bug.

 

in INI file.

 

Error variant:

[FontData]
0Char=32
0A=0
0C=3
0Wid=9
0Hgt=22
0X1=0,0078125
0Y1=0,00390625
0X2=0,04296875
0Y2=0,046875
1Char=33

 

worked variant:

[FontData]
0Char=32
0A=0
0C=3
0Wid=9
0Hgt=22
0X1=0.0078125
0Y1=0.00390625
0X2=0.04296875
0Y2=0.046875
1Char=33

 

need , replace .

Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS

Resource War Developer [ dev blog ]

Link to comment
Share on other sites

Now this is caused by the no-unicode-support. As you said:

up to 255 characters there is not one letter of Russian alphabet.

 

Your first problem was a windows <-> leadwerks engine problem, because windows writes a "." but in some regions a "," as decimal place separator in ini files.

That would be no problem if only the windows functions would be used for saving and loading ini files, instead of a custom parser... (though using files from regions different than yours might also cause problems for the windows functions, not sure)

Link to comment
Share on other sites

No need for unicode for cyrillic. Font Studio uses 16-bit values for cyrillic letters, so all you have to do is to write a tool to shift the >255 letters into the byte range:

94Char=126

94A=1

94C=9

94Wid=11

94Hgt=22

94X1=0.28125

94Y1=0.171875

94X2=0.32421875

94Y2=0.2578125

95Char=1025

95A=1

95C=9

95Wid=11

95Hgt=22

95X1=0.32421875

95Y1=0.171875

95X2=0.3671875

95Y2=0.2578125

I'm writing such a tool now :)

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Cyrillic letters work in LE!

 

Here is demo program:

#include "engine.h"

typedef unsigned short int wrd;
typedef unsigned char chr;
typedef signed char byt;
typedef unsigned short int * str16;

int str16len(wchar_t *s)
{
int i=0;
while(1)
{
	if( s[i]==0 && s[i+1]==0 ) return i/2;
	i+=2;
	if( i>511 ) return 0;
}
}

str str16to8(wchar_t *s)
{
int n=str16len(s);
char *t=new char[n+1];
t[n]=0;
for(int i=0;i<n;i++)
{
	wrd c=(wrd)s[i];
	if(c>255)c-=1025+128;
	t[i]=(byt)c;
}
return t;
}

int main()
{
wchar_t *s=L"Test Cyrillic: Привет медвед!";
printf("****%s****\n",str16to8(s));
Initialize();
RegisterAbstractPath("c:/program files/leadwerks engine sdk");
Graphics();
CreateFramework();
SetFont(LoadFont("abstract::cyrillic"));
while(!KeyHit())
{
	UpdateFramework();
	RenderFramework();
	SetBlend(BLEND_ALPHA);
	DrawText(1,100,str16to8(s));
	SetBlend(BLEND_NONE);
	Flip(0);
}
Terminate();
}

And the result: Note that you can have well 2 different language fonts at the same time, and also more since you only need to switch the font in realtime (no FPS cost):

post-2-12672925385618_thumb.png

 

And here is the tool to convert Font Studio ini files from 16 to 8 bit:

fontstudioini16to8.zip

  • Upvote 1

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I noticed that Font Studio doesn't fill the char values very tight, so sometimes there are jumps in the series. I will write a more advanced tool and corresponding demo to maximize out the number of characters you can have in the byte range.

 

Right now there are even some of the cyrillic letters missing, because they jump over 255 at the end, although there would be enough space to fit them all in (213 characters used).

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Final version is ready, now it supports the following features:

 

  • Automatic optimization of full byte range for unicode characters
  • ASCII letter range unchanged, so that the Font Studio font works also with normal 8-byte text
  • Drag and drop support: simply drag the Font Studio ini file over the fontstudioini16to8.exe and it creates the index (.idx) and new ini file (.ini.new) which you can then safely rename
  • Conversion of country specific decimal signs to global standard format ("," -> ".")
  • Works with any project which uses Font Studio fonts, not only LE projects.
  • Price 9€ includes full source code of converter and C/C++ header files for the runtime

 

fontstudioini16to8 1.0 © 2010 Siipi (http://www.siipi.com)

 

Usage: fontstudioini16to8 <input.ini> <output.ini>

 

Converts Font Studio ini files from 16-bit to 8-bit, so that Cyrillic, Arabic,

etc... characters can be used without unicode support.

 

C:\home\username>fontstudioini16to8.exe cyrillic.ini

 

fontstudioini16to8 1.0 © 2010 Siipi (http://www.siipi.com)

 

Reading from input file cyrillic.ini

Creating output file cyrillic.ini.new

Creating index file cyrillic.idx

Indexed 213 characters.

Space remaining for 42 additional characters.

 

Demo:

#include "engine.h"
#include "fs16to8.h"

int main()
{
TFontIndex cyridx=LoadFontIndex("cyrillic.idx");
TFontIndex araidx=LoadFontIndex("arabic_arial_19.idx");
wchar_t *s1=L"Test Cyrillic: Привет медвед!";
wchar_t *s2=_wcsrev(_wcsdup(L"السلام عليكم :CIBARA TSET"));
Initialize();
RegisterAbstractPath("c:/program files/leadwerks engine sdk");
Graphics();
CreateFramework();
TFont cyrfnt=LoadFont("abstract::cyrillic");
TFont arafnt=LoadFont("abstract::arabic_arial_19");
while(!KeyHit())
{
	UpdateFramework();
	RenderFramework();
	SetBlend(BLEND_ALPHA);

	SetFontIndex(cyridx);
	SetFont(cyrfnt);
	DrawText(1,50,str16to8(s1));

	SetFontIndex(araidx);
	SetFont(arafnt);
	DrawText(1,70,str16to8(s2));

	SetFont(cyrfnt);

	SetBlend(BLEND_NONE);
	Flip(0);
}
Terminate();
}

post-2-12673689796499_thumb.png

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...