nanogui: Thread: Cyrillic font buit-in


[<<] [<] Page 1 of 2 [>] [>>]
Subject: Cyrillic font buit-in
From: Cristian Chiarello ####@####.####
Date: 5 May 2008 07:46:21 -0000
Message-Id: <481EBB83.2020503@fimm.com>

Hi,
I need to embedded cyrillic font support on microwindows. Actually, we 
use built-in font generated by convfnt32 and ttf fonts.
I have found the dejavu project on sourceforge that have ttf font with 
cyrillic simbols.
How can I extract this ones?

Thank you, Cristian C.

Subject: Re: [nanogui] Cyrillic font buit-in
From: "Greg Haerr" ####@####.####
Date: 5 May 2008 19:20:35 -0000
Message-Id: <039201c8aee5$045f08e0$0300a8c0@RDP>

: I need to embedded cyrillic font support on microwindows. Actually, we
: use built-in font generated by convfnt32 and ttf fonts.
: I have found the dejavu project on sourceforge that have ttf font with
: cyrillic simbols.
: How can I extract this ones?

Nano-X includes a font converter, convbdf, which will create
a .c file from a .bdf file.  This file is then easily included as a built-in
font, of the fixed size specified by the .bdf file.  I'm pretty sure
there is a .ttf -> .bdf conversion program somewhere that will
create a .bdf of a specified fixed raster size from the .ttf file.
This .bdf could then be used to create a .c file.

Regards,

Greg 

Subject: Re: [nanogui] Cyrillic font buit-in
From: Greg Ford ####@####.####
Date: 6 May 2008 05:30:35 -0000
Message-Id: <481FECE0.3090104@reddfish.co.nz>

Hi all

Greg Haerr wrote:
 > I'm pretty sure
 > there is a .ttf -> .bdf conversion program somewhere that will
 > create a .bdf of a specified fixed raster size from the .ttf file.

I use fontforge to edit fonts.
It is a fairly powerful free font editor and can easily generate
multiple bdfs in your choice of raster size.
See:
http://fontforge.sourceforge.net/

I run Fontforge on Linux, - that's the easiest -
but they have a Cygwin version for Windows
(compiling and running Fontforge under Cygwin is
too complicated for my liking).

Greg Ford
Subject: Re: [nanogui] Cyrillic font buit-in
From: Cristian Chiarello ####@####.####
Date: 9 May 2008 10:03:45 -0000
Message-Id: <482421B7.6000604@fimm.com>

Hi Greg,
thank you very much for your suggestion.
For ttf to bdf conversion I have used otf2bdf (an evolution of ttf2bdf).
Then, have created the .c with convbdf that have converted all symbols 
(.c is more than 8Mb).
Now I have another problem: I'm not read the correct symbol on the screen.
My application read a UTF-8 file and show it on a text area.
When I use the .ttf file, all work correctly (but is very slow).
With the same font converted as explained above, I see latin symbols 
like ", ?, !, space...

I have read devfont.c source and I have seen PMWFONTPROCS struct have 
"encoding" member: if I set it to MWTF_UTF8 in GdCreateFont function 
when the built-in font is loaded, can be the right way?

Still thank.
Regards, Cristian C.


Greg Haerr ha scritto:
> : I need to embedded cyrillic font support on microwindows. Actually, we
> : use built-in font generated by convfnt32 and ttf fonts.
> : I have found the dejavu project on sourceforge that have ttf font with
> : cyrillic simbols.
> : How can I extract this ones?
> 
> Nano-X includes a font converter, convbdf, which will create
> a .c file from a .bdf file.  This file is then easily included as a built-in
> font, of the fixed size specified by the .bdf file.  I'm pretty sure
> there is a .ttf -> .bdf conversion program somewhere that will
> create a .bdf of a specified fixed raster size from the .ttf file.
> This .bdf could then be used to create a .c file.
> 
> Regards,
> 
> Greg 
> 
> 
> 
Subject: Re: [nanogui] Cyrillic font buit-in
From: "Greg Haerr" ####@####.####
Date: 9 May 2008 18:39:12 -0000
Message-Id: <0b6801c8b203$f27c0840$0300a8c0@RDP>

: I have read devfont.c source and I have seen PMWFONTPROCS struct have 
: "encoding" member: if I set it to MWTF_UTF8 in GdCreateFont function 
: when the built-in font is loaded, can be the right way?

The encoding member in the built-in MWFONTPROCS struct
must be something that lets nano-X know that the font is 
larger than 256 characters.  I usually use MWTF_UC16 in
the struct, and then specify the text encoding passed to GrText
as whatever your application is using.  Nano-X will convert
between the formats.  The UC16 allows 16-bit access to
the font glyphs.

I don't understand your statement about GdCreateFont.

Regards,

Greg
Subject: Re: [nanogui] Cyrillic font buit-in
From: Cristian Chiarello ####@####.####
Date: 12 May 2008 07:12:32 -0000
Message-Id: <4827EE1A.9060500@fimm.com>

My problem is that I need to use cyrillic built-in font with a 
microwindows application that use the win32 API.
After I have converted the font from .ttf to .c (otf2bdf, convbdf) I 
have a very long array with a lot of symbols (2^16?).
So, when I start my applications, I'm not read the right symbols (my 
application read a UTF-8 coded file and show them in a text field).
Why? How can I do for get the right symbols?
I'm not understand where is the mistake, the ttf font work well.

I thought to resolve the problem (dirty way, I know :/ ) by forcing 
UTF-8 encoding in GdCreateFont function but this solution doesn't work.

Thank you.
Regards,

Cristian


Greg Haerr ha scritto:
> : I have read devfont.c source and I have seen PMWFONTPROCS struct have 
> : "encoding" member: if I set it to MWTF_UTF8 in GdCreateFont function 
> : when the built-in font is loaded, can be the right way?
> 
> The encoding member in the built-in MWFONTPROCS struct
> must be something that lets nano-X know that the font is 
> larger than 256 characters.  I usually use MWTF_UC16 in
> the struct, and then specify the text encoding passed to GrText
> as whatever your application is using.  Nano-X will convert
> between the formats.  The UC16 allows 16-bit access to
> the font glyphs.
> 
> I don't understand your statement about GdCreateFont.
> 
> Regards,
> 
> Greg
> 
> 
Subject: Re: [nanogui] Cyrillic font buit-in
From: "Greg Haerr" ####@####.####
Date: 12 May 2008 15:33:20 -0000
Message-Id: <05f201c8b445$7d812d60$6401a8c0@winXP>

: So, when I start my applications, I'm not read the right symbols (my 
: application read a UTF-8 coded file and show them in a text field).
: Why? How can I do for get the right symbols?
: I'm not understand where is the mistake, the ttf font work well.

Win32 doesn't provide a way to specify text encoding, so
you'll have to force it in the GdText call in the MwExTextOut
function, which I think is in src/mwin/winuser.c or winfont.c

Regards,

Greg
Subject: Re: [nanogui] Cyrillic font buit-in
From: Cristian Chiarello ####@####.####
Date: 13 May 2008 10:38:14 -0000
Message-Id: <48296FC6.1010006@fimm.com>

Greg Haerr:
> 
> Win32 doesn't provide a way to specify text encoding, so
> you'll have to force it in the GdText call in the MwExTextOut
> function, which I think is in src/mwin/winuser.c or winfont.c

The editbox component source is microwindows/src/mwin/winlib/newedit.c 
that define neTextOut as TextOutW, function defined at 757 of 
microwindows/src/mwin/wingdi.c. This one, call MwExtTextOut with UC16 
encoding.

I have modified this:

return MwExtTextOut(hdc, x, y, 0, NULL, lpszString, cbString, NULL, 
MWTF_UC16 );

with

return MwExtTextOut(hdc, x, y, 0, NULL, lpszString, cbString, NULL, 
MWTF_UTF8 );

Debugging, the function is called but the symbols are still wrong (the 
same as MWTF_UC16).

Regards, Cristian
Subject: Re: [nanogui] Cyrillic font buit-in
From: "Greg Haerr" ####@####.####
Date: 13 May 2008 18:02:35 -0000
Message-Id: <0f9401c8b523$80d93320$0300a8c0@RDP>

: return MwExtTextOut(hdc, x, y, 0, NULL, lpszString, cbString, NULL, 
: MWTF_UTF8 );
: 
: Debugging, the function is called but the symbols are still wrong (the 
: same as MWTF_UC16).

You should write a test program that displays text in a window
directly using this same function.  If it works, then there are
issues with how the edit box control stores text.  Otherwise,
there are still other issues.

Regards,

Greg
Subject: Re: [nanogui] Cyrillic font buit-in
From: Cristian Chiarello ####@####.####
Date: 15 May 2008 06:18:39 -0000
Message-Id: <482BD5F9.7030703@fimm.com>

Greg Haerr:
> : return MwExtTextOut(hdc, x, y, 0, NULL, lpszString, cbString, NULL, 
> : MWTF_UTF8 );
> : 
> : Debugging, the function is called but the symbols are still wrong (the 
> : same as MWTF_UC16).
> 
> You should write a test program that displays text in a window
> directly using this same function.  If it works, then there are
> issues with how the edit box control stores text.  Otherwise,
> there are still other issues.

Starting from pcfdemo.c, I have write builtinfont.c that use GrText
function that also call GdText function: I'm not be able to see the
right symbols but I have some new questions:
1) UTF8 use 1 2 and sometimes 4 bytes for one symbol: I use a char array
   for store the text file. Is this correct? (see attach for source code)
2) with fontforge I have open the .bdf and I have see that first
cyrillic symbol is the 1024 (unicode). I have try to show this only one
but I get an error (see attach char_utf8.txt). Why?

Tnx.
Regards, Cristian


/*
 * pcfdemo - demonstrate PCF font loading for Nano-X
 */
#include <stdio.h>
#include <stdlib.h>
#define MWINCLUDECOLORS
#include "nano-X.h"

GR_FONT_ID font = 0;
GR_WINDOW_ID main_wid;
GR_FONT_INFO finfo;

static void
draw_string(void)
{
	int count = 0;
	int x = 10;
	int y = 10;
	unsigned char ch;
	int tmp = 1024;
	GR_GC_ID gc = GrNewGC();

	GrSetGCFont(gc, font);

	GrSetGCForeground(gc, GR_RGB(255, 255, 255));
	GrSetGCBackground(gc, GR_RGB(0, 0, 0));

	printf("First char = %d, last char = %d\n", finfo.firstchar,
	       finfo.lastchar);
	printf("Max width = %d, max height = %d\n", finfo.maxwidth,
	       finfo.height);

	GrText(main_wid, gc, x, y, &tmp, 1, GR_TFTOP | GR_TFUC16); //this cause an assert error

/*
	for (ch = 0; ch < 255; ch++) {
		if (ch < finfo.firstchar || ch > finfo.lastchar)
			GrFillRect(main_wid, gc, x, y, finfo.maxwidth, finfo.height);
		else
			GrText(main_wid, gc, x, y, &ch, 1, GR_TFTOP | GR_TFASCII);

		if (++count >= 16) {
			x = 0;
			y += finfo.height;
			count = 0;
		} else
			x += finfo.maxwidth + 2;
	}
*/
	GrDestroyGC(gc);
}

static void drawFile(const char * fname){
	char buf[20]; //or int... unsigned?
	int count = 0;
	int x = 0;
	int y = 10;
	unsigned char ch;
	FILE * pfile;

	GR_GC_ID gc = GrNewGC();

	GrSetGCFont(gc, font);

	GrSetGCForeground(gc, GR_RGB(255, 255, 255));
	GrSetGCBackground(gc, GR_RGB(0, 0, 0));

	pfile = fopen(fname, "r");
	if( pfile > 0 ){
		fread(buf, 1, 20, pfile);
		GrText(main_wid, gc, x, y, buf, 20, GR_TFTOP | GR_TFUTF8);
	}
	GrDestroyGC(gc);
}

int
main(int argc, char **argv)
{
	int width, height;

	if (GrOpen() == -1)
		return (-1);

	font = GrCreateFont("DejaVuLGCSans", 19, 0); //This is a builtin fonts generated by convbdf
	if (!font)
		printf("Unable to load font\n");

	GrGetFontInfo(font, &finfo);

	width = ((finfo.maxwidth + 2) * 16);
	height =
		(((finfo.lastchar - finfo.firstchar) / 16) +
		 5) * finfo.height;

	main_wid = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, "builtinfont",
			GR_ROOT_WINDOW_ID, 0, 0, width, height, BLACK);
	GrSelectEvents(main_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_CLOSE_REQ);
	GrMapWindow(main_wid);

	while (1) {
		GR_EVENT event;
		GrGetNextEvent(&event);

		if (event.type == GR_EVENT_TYPE_EXPOSURE)
			draw_string();
//			drawFile("utf8.txt");
//			drawFile("unicode.txt");

	        if(event.type == GR_EVENT_TYPE_CLOSE_REQ) {
			GrClose();
			exit(0);
	      }
	}
}


tfb800@utfb800:~/src/x86/microwin_cvs/src/bin$ ./builtinfont 
XDefaultVisual:
  Visual  class: TrueColor (4)
             id: 35
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Screen RootDepth: 24
Screen RootVisual
  Visual  class: TrueColor (4)
             id: 35
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Depth: 24
Visual: 0
  Visual  class: TrueColor (4)
             id: 35
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 1
  Visual  class: TrueColor (4)
             id: 36
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 2
  Visual  class: TrueColor (4)
             id: 37
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 3
  Visual  class: TrueColor (4)
             id: 38
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 4
  Visual  class: TrueColor (4)
             id: 39
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 5
  Visual  class: TrueColor (4)
             id: 40
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 6
  Visual  class: TrueColor (4)
             id: 41
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 7
  Visual  class: TrueColor (4)
             id: 42
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 8
  Visual  class: DirectColor (5)
             id: 43
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 9
  Visual  class: DirectColor (5)
             id: 44
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 10
  Visual  class: DirectColor (5)
             id: 45
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 11
  Visual  class: DirectColor (5)
             id: 46
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 12
  Visual  class: DirectColor (5)
             id: 47
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 13
  Visual  class: DirectColor (5)
             id: 48
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 14
  Visual  class: DirectColor (5)
             id: 49
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Visual: 15
  Visual  class: DirectColor (5)
             id: 50
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Depth: 1
Depth: 4
Depth: 8
Depth: 15
Depth: 16
Depth: 32
Visual: 0
  Visual  class: TrueColor (4)
             id: 96
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
Selected Visual:
  Visual  class: TrueColor (4)
             id: 35
   bits_per_rgb: 8
    map_entries: 256
       red_mask: 0x00ff0000
     green_mask: 0x0000ff00
      blue_mask: 0x000000ff
createfont: (height == 0) found builtin font System (0)
createfont: (height == 0) found builtin font System (0)
fnt_createfont: DejaVuLGCSans,19 not found
pcf_createfont: DejaVuLGCSans,19 not found
createfont: (height != 0) using builtin font DejaVuLGCSans (4)
First char = 32, last char = 65533
Max width = 74, max height = 19
builtinfont: /home/tfb800/src/x86/microwin_cvs/src/drivers/fblin32.c:68: linear32_drawhorzline: Assertion `x2 >= x1' failed.
Aborted (core dumped)

[<<] [<] Page 1 of 2 [>] [>>]


Powered by ezmlm-browse 0.20.