Esempio n. 1
0
static void
GrSetFontRotationWrapper(void *r)
{
	nxSetFontRotationReq *req = r;

 	GrSetFontRotation(req->fontid, req->tenthdegrees);
}
Esempio n. 2
0
int
main(int ac, char **av)
{
	GR_WINDOW_ID window;
	GR_GC_ID gc;
	GR_FONT_ID fontid;
	int x, y, fnum;
	GR_REGION_ID regionid;
#if CLIP_POLYGON
	GR_POINT points[] = { {20, 20}, {300, 20}, {300, 300}, {20, 300} };
#else
	GR_RECT clip_rect = { 20, 20, 300, 300 };
#endif

	if (GrOpen() < 0)
		exit(1);

	window = GrNewWindowEx(GR_WM_PROPS_APPWINDOW,
		"t1demo loadable fonts (truetype, t1lib, pcf, mgl, hzk)",
		GR_ROOT_WINDOW_ID, 50, 50, WIDTH, HEIGHT, BLACK);
	GrSelectEvents(window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ);
	GrMapWindow(window);

	gc = GrNewGC();
	GrSetGCUseBackground(gc, GR_FALSE);
	GrSetGCBackground(gc, BLACK);

#if CLIP_POLYGON
	/* polygon clip region */
	regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points);
#else
	/* rectangle clip region */
	regionid = GrNewRegion();
	GrUnionRectWithRegion(regionid, &clip_rect);
#endif
	GrSetGCRegion(gc, regionid);

	srand(time(0));
	while (1) {
		GR_EVENT event;

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

		fontid = GrCreateFontEx(names[fnum=RAND(MAXFONTS)], 0, 0, NULL);
		GrSetFontSizeEx(fontid, RAND(80) + 1, RAND(80) + 1);
		GrSetFontRotation(fontid, 330);		/* 33 degrees */
		GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
		GrSetGCFont(gc, fontid);

		GrSetGCForeground(gc, rand() & 0xffffff);
		/*GrSetGCBackground(gc, rand() & 0xffffff); */

		x = RAND(WIDTH);
		y = RAND(HEIGHT);

#if HAVE_HZK_SUPPORT
		{
#if HZKBIG5
		/* hzk big5 unicode-16 test*/
		static unsigned short buffer[] = {
		    0x9060, 0x898b, 0x79d1, 0x6280, 0x0061, 0x0041, 0
		};
		GrText(window, gc, x, y, buffer, 7, GR_TFUC16);

		/* hzk big5 dbcs test #1*/
		x = RAND(WIDTH);
		y = RAND(HEIGHT);
		GrText(window, gc, x, y,
		       "Microwindows,Åwªï¨Ï¥Î¤¤­^¤åÂI°}¦rÅé", -1, GR_TFASCII);

		/* hzk big5 dbcs test #2*/
		x = RAND(WIDTH);
		y = RAND(HEIGHT);
		GrText(window, gc, x, y, "£t£u£v£w£¸£¹£º", -1, GR_TFASCII);
#else
	#if 0
		/* hzk test #1*/
		static char buffer[] = {
			0x6c, 0x49, 0x73, 0x8b, 0x79,
			0xd1, 0x62, 0x80, 0x61, 0x00,
			0x41, 0x00, 0x00, 0xa1, 0x00,
			0xa6, 0x6c, 0x49, 0, 0
		};

		/* *static unsigned short buffer[] = {
			0x496c, 0x8b73, 0xd179, 0x8062, 0x0061,
			0x0041, 0xa100, 0xa600, 0x496c, 0
		};***/

		GrText(window, gc, x, y, buffer, 9, GR_TFUC16);
	#endif
		/* HZK Metrix font test, includes Chinese and English */
		x = RAND(WIDTH);
		y = RAND(HEIGHT);
		GrText(window, gc, x, y,
		       "Microwindows,»¶Ó­Ê¹ÓÃÖÐÓ¢ÎĵãÕó×ÖÌå", -1, GR_TFASCII);
#endif /* HZKBIG5*/
		}
#elif HAVE_BIG5_SUPPORT
		/* encoding BIG5 test 61 B1 64 B1 64 61 */
		GrText(window, gc, x, y, "\151\261\144\261\144\151", 6, MWTF_DBCS_BIG5);
#elif HAVE_GB2312_SUPPORT
		/* encoding GB2312 test BD A1 BD A1 */
		GrText(window, gc, x, y, "\275\241\275\241", 4, MWTF_DBCS_GB);
#elif HAVE_EUCJP_SUPPORT
		/* encoding EUC_JP test A2 A1 */
		GrText(window, gc, x, y, "ï¿½Þ¥ï¿½ï¿½ï¿½ï¿½í¥¦ï¿½ï¿½ï¿½ï¿½ï¿½É¥ï¿½ï¿½ï¿½ï¿½Ø¤è¤¦ï¿½ï¿½ï¿½ï¿½!", -1, MWTF_DBCS_EUCJP);
#elif HAVE_JISX0213_SUPPORT
		/* encoding JISX0213 test A2 A1 */
		GrText(window, gc, x, y, "\242\241", 2, MWTF_DBCS_JIS);
#elif HAVE_KSC5601_SUPPORT
		/* encoding KSC5601 test B0 B0 */
		GrText(window, gc, x, y, "\273\273", 2, MWTF_DBCS_EUCKR);
#elif HAVE_FREETYPE_2_SUPPORT
		/* ASCII test */
		GrText(window, gc, x, y, "Microwindows", -1, GR_TFASCII);
#elif HAVE_PCF_SUPPORT
		/* note: large PCF fonts require XCHAR2B, this is not
		   figured out yet for these fonts.  FIXME */
		if (fnum == 3) {
			/* japanese jiskan24*/
			unsigned short text[] =
			    { 0x213a, 0x213b, 0x2170, 0x2276, 0x2339 };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else if (fnum == 4) {
			/* chinese gb24st*/
			unsigned short text[] =
			    /* FIXME: why doesn't first row index correctly?*/
			    /*{ 0x7765, 0x7766, 0x7767, 0x777a, 0x777e };*/
			    { 0x2129, 0x212a, 0x212b, 0x212c, 0x212d };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else
			GrText(window, gc, x,y, "Microwindows", -1, GR_TFASCII);
#elif HAVE_FNT_SUPPORT
		/* UC16 test */
		if (fnum == 2 || fnum == 3) {
			/* japanese jiskan24, jiskan16-2000-1*/
			unsigned short text[] =
			    { 0x213a, 0x213b, 0x2170, 0x2276, 0x2339 };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else if (fnum == 4) {
			/* chinese gbk16-xke*/
			unsigned short text[] =
			    { 0x8144, 0x8147, 0x8148, 0xfe4e, 0xfe4f };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else
			GrText(window, gc, x,y, "Microwindows", -1, GR_TFASCII);
#else
		/* ASCII test */
		GrText(window, gc, x, y, "Microwindows", -1, GR_TFASCII);
#endif
		GrFlush();
		GrDestroyFont(fontid);
	}
	GrDestroyRegion(regionid);
	GrClose();
	return 0;
}
Esempio n. 3
0
int main()
{
	GR_WINDOW_ID 	window;
	GR_EVENT 	event;
        GR_GC_ID 	gc;
	GR_FONT_ID	fontid;
        int 		i, x, y;
	GR_REGION_ID	regionid = 0;
#if CLIP_POLYGON
	GR_POINT	points[]={ {100, 100},
				{300, 100},
				{300, 300},
				{100, 300}};
#else
	GR_RECT		clip_rect={100,100,300,300};
#endif
   
        srand(time(0));
   
        GrOpen();
	window = GrNewWindow(GR_ROOT_WINDOW_ID, 50,50, MAXW,MAXH, 4, BLACK,BLUE);
	GrMapWindow(window);

        gc = GrNewGC();

#if CLIP_POLYGON
	/* polygon clip region*/
	regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points);
#else
	/* rectangle clip region*/
        regionid = GrNewRegion();
	GrUnionRectWithRegion(regionid, &clip_rect);
#endif

	GrSetGCRegion(gc, regionid);
	
        GrSelectEvents(window,GR_EVENT_MASK_ALL);
        GrSetGCUseBackground(gc,GR_FALSE);
	GrSetGCBackground(gc, GR_RGB(0, 0, 0));
	while(1) {
	      GrCheckNextEvent(&event);
	   
	      i = (int)((float)MAXFONTS * rand() / (RAND_MAX + 1.0));
	      fontid = GrCreateFont(names[i], 20, NULL);
	      GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0)));
	      GrSetFontRotation(fontid, 330);	/* 33 degrees*/
  	      GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
  	      GrSetGCFont(gc, fontid);
	      /*GrSetGCBackground(gc, rand() & 0xffffff);*/
 	      GrSetGCForeground(gc, rand() & 0xffffff);
	      x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
	      y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0));

#if HAVE_HZK_SUPPORT
             {	/* to test Unicode 16 chinese characters display ,use HZK font Bitmap font (Metrix font). */
#ifndef BIG5		
		char buffer[256];
		buffer[0]=0x6c;
		buffer[1]=0x49;
		buffer[2]=0x73;
		buffer[3]=0x8b;
		buffer[4]=0x79;
		buffer[5]=0xd1;
		buffer[6]=0x62;
		buffer[7]=0x80;
		buffer[8]=0x61;
		buffer[9]=0x00;
		buffer[10]=0x41;
		buffer[11]=0x00;

		buffer[12]=0x00;
		buffer[13]=0xa1;
		buffer[14]=0x00;
		buffer[15]=0xa6;
		buffer[16]=0x6c;
		buffer[17]=0x49;
		buffer[18]=0x0;
		buffer[19]=0x0;
		GrText(window, gc,x,y+20, buffer,17, GR_TFUC16);
		x=0;y=16;
		GrText(window, gc,x,y+20, buffer,17, GR_TFUC16);
#else
		unsigned short buffer[7];
		buffer[0]=0x9060;
		buffer[1]=0x898b;
		buffer[2]=0x79d1;
		buffer[3]=0x6280;
		buffer[4]=0x0061;
		buffer[5]=0x0041;
		buffer[6]=0x0;
		GrText(window, gc,x,y+20, buffer,7, GR_TFUC16);
		x=0;y=16;
		GrText(window, gc,x,y+20, buffer,7, GR_TFUC16);
#endif
	      }

#ifndef BIG5
	      x=0;y=16;
	      /* HZK Metrix font test, includes Chinese and English*/
	      GrText(window, gc,x,y, "Microwindows,欢迎使用中英文点阵字体",
		      -1, GR_TFASCII);
#else	
	      GrText(window, gc,x,y, "Microwindows,舧ㄏノい璣ゅ翴皚砰",
		      -1, GR_TFASCII);
	      x=0;y=16*3+4;
	      GrText(window, gc,x,y, "89:", -1, GR_TFASCII);
#endif
	      GrFlush();

#else /* !HZK_FONT_SUPPORT*/

#if HAVE_BIG5_SUPPORT
	      /* ENCODING_BIG5 test*/
	      GrText(window, gc,x,y, "眃眃", -1, GR_TFASCII);
#else
#if HAVE_GB2312_SUPPORT
	      /* ENCODING_GB2312 test*/
	      GrText(window, gc,x,y, "\275\241\275\241", -1, GR_TFASCII);
#else
	      /* ASCII test*/
	      GrText(window, gc,x,y, "Microwindows", -1, GR_TFASCII);
#endif
#endif

#endif /* HZK_FONT_SUPPORT*/


	      GrDestroyFont(fontid);

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

	GrDestroyRegion(regionid);
	GrClose();
}
Esempio n. 4
0
int main(int argc, char **argv)
{
	GR_WINDOW_ID 	window;
	GR_EVENT 	event;
        GR_GC_ID 	gc;
	GR_FONT_ID	fontid;
        int 		x, y, rnd = 0;
	MWLOGFONT	lf;
	char		description[128];
   
        srand(time(0));
   
        GrOpen();
	window = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, MAXW, MAXH, 4, BLACK, BLUE);
	GrMapWindow(window);

        gc = GrNewGC();

        GrSelectEvents(window,GR_EVENT_MASK_ALL);
        GrSetGCUseBackground(gc,GR_FALSE);
	GrSetGCBackground(gc, GR_RGB(0, 0, 0));

	y = 30;
	x = 0;

	while(1) {
	      GrCheckNextEvent(&event);

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

	      sleep(1);

	      MWLF_Clear(&lf);
	      description[0] = '\0';

	      // lf.lfSerif = 1;

	      if ( rnd & 1 ) {
		      lf.lfWeight = MWLF_WEIGHT_BOLD;
		      strcat(description,"Bold ");
	      }
	      

	      if ( rnd & 2 ) {
		      lf.lfItalic = 1;
		      strcat(description,"Italics ");
	      }
	      if ( rnd & 4 ) {
		      lf.lfOblique = 1;
		      strcat(description,"Oblique ");
	      }

	      if ( rnd & 8 ) {
		      lf.lfMonospace = 1;
		      strcat(description,"°íÁ¤Æø Monospace ");
	      } else {
		      lf.lfProportional = 1;
		      strcat(description,"Proportional ");
	      }

	      if ( argc > 1 )
		      strcpy(lf.lfFaceName,argv[1]);
	      else
		      strcpy(lf.lfFaceName,"fantasy");

	      fontid = GrCreateFont(0, 0, &lf);
	      /* GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0))); */
	      GrSetFontSize(fontid,26);
	      GrSetFontRotation(fontid, 330);	/* 33 degrees*/
  	      GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
  	      GrSetGCFont(gc, fontid);
	      /*GrSetGCBackground(gc, rand() & 0xffffff);*/
 	      GrSetGCForeground(gc, 0xffffff);
	      /* x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
		 y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0)); */

	      GrText(window, gc,x,y, description, -1, GR_TFASCII);

	      GrDestroyFont(fontid);

	      rnd++;
	      y += 30;
	      if ( y > 460 )
		      y = 0;
	}

	GrClose();
}
Esempio n. 5
0
void Render(GR_WINDOW_ID window)
{
   int flags = 0;
   GR_SCREEN_INFO info;

   if (aa)
   	flags |= GR_TFANTIALIAS;
   if (kerning)
   	flags |= GR_TFKERNING;
   if (underline)
   	flags |= GR_TFUNDERLINE;
   if (bold)
   	flags |= GR_TFBOLD;

// flags |= MWTF_CMAP_0;	/* termcs1 only*/

   GrGetScreenInfo(&info);
   GrSetGCBackground(gid, WHITE);
   GrSetGCForeground (gid, WHITE);
   GrSetGCUseBackground(gid, GR_FALSE);
   GrFillRect(window, gid, 0, 0, info.cols, info.rows);
   GrSetGCForeground (gid, BLACK);

//	GrSetGCForeground (gid, GREEN);
//	GrSetGCBackground(gid, BLUE);
//	GrSetGCUseBackground(gid, GR_TRUE);
 
   /* Draw menu */
   GrSetGCFont(gid, fontid);
   GrSetFontAttr(fontid, flags & ~GR_TFUNDERLINE, -1);
   GrText(window, gid, 5, 20, "+ Rotate string clockwise", 25, GR_TFASCII);
   GrText(window, gid, 5, 40, "-  Rotate string counter-clockwise", 34, GR_TFASCII);
   GrText(window, gid, 5, 60, "a Toggle anti-aliasing", 22, GR_TFASCII);
   GrText(window, gid, 5, 80, "b Toggle bold", 13, GR_TFASCII);
   GrText(window, gid, 5, 100, "k Toggle kerning", 16, GR_TFASCII);
   GrText(window, gid, 5, 120, "u Toggle underline", 18, GR_TFASCII);
   GrText(window, gid, 5, 140, "l  Toggle alignment bottom/baseline/top", 39, GR_TFASCII);
#if HAVE_KSC5601_SUPPORT
   GrText(window, gid, 5, 160, "\xB0\xA1\xB0\xA2\xB0\xA3", 6, MWTF_DBCS_EUCKR);
#endif

	/* check display of glyphs with negative leftBearing*/
//	GrText(window, gid, 5, 160, "H\xAEH\xDEH\xF2H", 6, GR_TFASCII); // leftBearing < 0 helvB12.pcf.gz

	/* sym18.pcf.gz A0 should display blank*/
//	GrText(window, gid, 5, 160, "\xA0\xDC\xA0", 3, GR_TFASCII);	// should be SP <= SP
//	GrText(window, gid, 5, 180, "\x40\x80", 2, GR_TFASCII);		// should be approxequal,SP
 

#if 0
	/* jiskan24.pcf.gz test large pcf, UC16 and default character*/
{
	unsigned short text[32];

	text[0] = 1122;				/* blank*/
	text[1] = 1123;
	text[2] = 1124;
	text[3] = 1125;
	text[4] = 1126;
	text[5] = 0x2121;			/* default char*/
	text[6] = 0x2122;
	text[7] = 0x2123;
	text[8] = 0x2124;
	text[9] = 0x2125;
	GrText(window, gid, 5, 160, text, 10, MWTF_UC16);
}
#endif

   /* Draw test string */
   GrSetGCFont(gid, fontid2);
   GrSetFontAttr(fontid2, flags, -1);
   GrSetFontRotation(fontid2, angle);
   GrText(window, gid, MAXW/2, MAXH/2, buffer, n, state|GR_TFUTF8);
 
   /* Draw arrow */
   GrLine (window, gid, (MAXW/2)-10 , MAXH/2, (MAXW/2)+10, MAXH/2);
   GrLine (window, gid, MAXW/2, (MAXH/2)-10, MAXW/2, (MAXH/2)+10);
}