⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type1.c

📁 ARM9-2410教学实验系统下Linux下minigui程序
💻 C
📖 第 1 页 / 共 2 页
字号:
				}#if 0  				c = type1_inst_info->last_bits[ i * width / 8 + j];                		for (k = 0; k < 8; k++)              			      if (c  & (0x80>>k))                   			     fprintf (stderr, "*");                		      else                     			     fprintf (stderr, " ");#endif 			}#if 0            		fprintf (stderr, "\n");#endif		}	}	/*	 * if not set it to null, T1_SetChar will free it next time it is called,	 * we do so to keep it by ourself	 * */ 	glyph->bits = NULL;	return type1_inst_info->last_bits;	}#if 0static void* get_str_bitmap (LOGFONT* logfont, DEVFONT* devfont,            const unsigned char* str, int len,long spaceoff){	GLYPH * glyph;	int modflag;	int style;	TYPE1INSTANCEINFO* type1_inst_info = TYPE1_INST_INFO_P (devfont);	TYPE1INFO* type1_info = type1_inst_info->type1_info;	if(type1_inst_info->last_bitmap_str)		if(!strncmp(type1_inst_info->last_bitmap_str,str,len))				return type1_inst_info->last_bits;	modflag = 0;	style	= logfont->style;	modflag |= T1_KERNING ;	if ( style & FS_UNDERLINE_LINE ) {		modflag |= T1_UNDERLINE;	}	if ( style & FS_STRUCKOUT_LINE ) {		modflag |= T1_OVERSTRIKE;	}		glyph = T1_SetString ( type1_info->font_id, (char*)str, len, spaceoff,modflag,\			type1_inst_info->size , type1_inst_info->pmatrix) ;	type1_inst_info->last_bitmap_char = -1;	type1_inst_info->last_pixmap_char = -1;	if(type1_inst_info->last_bitmap_str){		free (type1_inst_info->last_bitmap_str);		type1_inst_info->last_bitmap_str = NULL;	}	if(type1_inst_info->last_pixmap_str){		free (type1_inst_info->last_pixmap_str);		type1_inst_info->last_pixmap_str = NULL;	}	type1_inst_info->last_bitmap_str = (char * ) calloc ( len, sizeof(char) );	strncpy(type1_inst_info->last_bitmap_str, str, len);    	type1_inst_info->last_ascent = glyph->metrics.ascent;    	type1_inst_info->last_descent = glyph->metrics.descent;    	type1_inst_info->last_leftSideBearing = glyph->metrics.leftSideBearing;    	type1_inst_info->last_rightSideBearing = glyph->metrics.rightSideBearing;    	type1_inst_info->last_advanceX = glyph->metrics.advanceX;    	type1_inst_info->last_advanceY = glyph->metrics.advanceY;    	type1_inst_info->last_bpp = glyph->bpp;	/*free the last char's bitmap*/	if(!type1_inst_info->last_bits)		free(type1_inst_info->last_bits);    	type1_inst_info->last_bits = glyph->bits;	/*change the endian*/	{		int height,width;		int i,j,k;		unsigned char c;		unsigned char d;		height = type1_inst_info->last_ascent - type1_inst_info->last_descent ;		width  = type1_inst_info->last_rightSideBearing - type1_inst_info->last_leftSideBearing ;   					width  = ( width + 7 ) >> 3 << 3 ;				fprintf(stderr, "height:%d, width %d\n", height, width);				for (i = 0; i < height; i++) {			for (j = 0; j < width/8 ; j++) {				c = type1_inst_info->last_bits[ i * width / 8 + j];				if( c ) {					d = 0;						for ( k = 0; k < 8; k++ ) {						if ( ( c >> k ) & 0x01 )							d |= 0x80 >> k ;					}					type1_inst_info->last_bits[ i * width / 8 + j] = d ;				}#if 0  				c = type1_inst_info->last_bits[ i * width / 8 + j];                		for (k = 0; k < 8; k++)              			      if (c  & (0x80>>k))                   			     fprintf (stderr, "*");                		      else                     			     fprintf (stderr, " ");#endif 			}#if 0            		fprintf (stderr, "\n");#endif		}	}	/*	 * if not set it to null, T1_SetString will free it next time it is called,	 * we do so to keep it by ourself	 * */ 	glyph->bits = NULL;	return type1_inst_info->last_bits;	}#endif static const void* get_char_pixmap (LOGFONT* logfont, DEVFONT* devfont,            const unsigned char* mchar, int len, int * pitch){	GLYPH * glyph;	TYPE1INSTANCEINFO* type1_inst_info = TYPE1_INST_INFO_P (devfont);	TYPE1INFO* type1_info = type1_inst_info->type1_info;	if(type1_inst_info->last_pixmap_char == *mchar){	/* same char as last call, use the cache one.*/		if ( pitch )	 		*pitch = type1_inst_info->last_rightSideBearing - type1_inst_info->last_leftSideBearing;   		return type1_inst_info->last_bits;		}		glyph = T1_AASetChar ( type1_info->font_id , *mchar , type1_inst_info->size , type1_inst_info->pmatrix) ;	type1_inst_info->last_pixmap_char = *mchar;	type1_inst_info->last_bitmap_char = -1;	if(type1_inst_info->last_bitmap_str){		free (type1_inst_info->last_bitmap_str);		type1_inst_info->last_bitmap_str = NULL;	}	if(type1_inst_info->last_pixmap_str){		free (type1_inst_info->last_pixmap_str);		type1_inst_info->last_pixmap_str = NULL;	}    	type1_inst_info->last_ascent = glyph->metrics.ascent;    	type1_inst_info->last_descent = glyph->metrics.descent;    	type1_inst_info->last_leftSideBearing = glyph->metrics.leftSideBearing;    	type1_inst_info->last_rightSideBearing = glyph->metrics.rightSideBearing;    	type1_inst_info->last_advanceX = glyph->metrics.advanceX;    	type1_inst_info->last_advanceY = glyph->metrics.advanceY;    	type1_inst_info->last_bpp = glyph->bpp;	/*free the last char's bitmap*/	if(!type1_inst_info->last_bits)		free(type1_inst_info->last_bits);    	type1_inst_info->last_bits = glyph->bits;	if ( pitch )	 	*pitch = type1_inst_info->last_rightSideBearing - type1_inst_info->last_leftSideBearing;   #if 0	{		int height,width;		int i,j,k;		unsigned char c;		unsigned char d;		height = type1_inst_info->last_ascent - type1_inst_info->last_descent ;		width  = type1_inst_info->last_rightSideBearing - type1_inst_info->last_leftSideBearing ;   							for (i = 0; i < height; i++) {			for (j = 0; j < width ; j++) {				c = type1_inst_info->last_bits[ i * width + j];				if( c ) 					fprintf(stderr, "%d",c);			 	else 					fprintf(stderr, " ");							}            		fprintf (stderr, "\n");		}	}#endif	/*	 * if not set it to null, T1_AASetChar will free it next time it is called,	 * we do so to keep it by ourself	 * */ 	glyph->bits = NULL;	return type1_inst_info->last_bits;	}#if 0static void* get_str_pixmap (LOGFONT* logfont, DEVFONT* devfont,            const unsigned char* str, int len, long spaceoff, int * pitch)/* FIXME:  * If u will use the function, please give values to pitch as  * I did in get_char_pixmap * */{	GLYPH * glyph;	int modflag;	int style;	TYPE1INSTANCEINFO* type1_inst_info = TYPE1_INST_INFO_P (devfont);	TYPE1INFO* type1_info = type1_inst_info->type1_info;		if(type1_inst_info->last_pixmap_str)		if(!strncmp(type1_inst_info->last_pixmap_str,str,len))				return type1_inst_info->last_bits;	modflag = 0; 	style	= logfont->style;	modflag |= T1_KERNING ;	if ( style & FS_UNDERLINE_LINE ) {		modflag |= T1_UNDERLINE;	}	if ( style & FS_STRUCKOUT_LINE ) {		modflag |= T1_OVERSTRIKE;	}	glyph = T1_AASetString ( type1_info->font_id, ( char* )str, len, spaceoff, modflag, 			type1_inst_info->size , type1_inst_info->pmatrix) ;	type1_inst_info->last_bitmap_char = -1;	type1_inst_info->last_pixmap_char = -1;	if(type1_inst_info->last_bitmap_str){		free (type1_inst_info->last_bitmap_str);		type1_inst_info->last_bitmap_str = NULL;	}	if(type1_inst_info->last_pixmap_str){		free (type1_inst_info->last_pixmap_str);		type1_inst_info->last_pixmap_str = NULL;	}	type1_inst_info->last_pixmap_str = (char * ) calloc ( len, sizeof(char) );	strncpy(type1_inst_info->last_pixmap_str, str, len);    	type1_inst_info->last_ascent = glyph->metrics.ascent;    	type1_inst_info->last_descent = glyph->metrics.descent;    	type1_inst_info->last_leftSideBearing = glyph->metrics.leftSideBearing;    	type1_inst_info->last_rightSideBearing = glyph->metrics.rightSideBearing;    	type1_inst_info->last_advanceX = glyph->metrics.advanceX;    	type1_inst_info->last_advanceY = glyph->metrics.advanceY;    	type1_inst_info->last_bpp = glyph->bpp;	/*free the last char's bitmap*/	if(!type1_inst_info->last_bits)		free(type1_inst_info->last_bits);    	type1_inst_info->last_bits = glyph->bits;	/*	 * if not set it to null, T1_AASetString will free it next time it is called,	 * we do so to keep it by ourself	 * */ 	glyph->bits = NULL;	return type1_inst_info->last_bits;	}#endif/*  * call this function after getting the bitmap/pixmap of the char  * to get the advance of the char  * */static void get_char_advance (LOGFONT* logfont, DEVFONT* devfont,                const unsigned char* mchar, int len,                 int* px, int* py){	TYPE1INSTANCEINFO* type1_inst_info = TYPE1_INST_INFO_P (devfont);	*px += type1_inst_info->last_advanceX;	*py -= type1_inst_info->last_advanceY;}static DEVFONT* new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font){	TYPE1INFO* type1_info = TYPE1_INFO_P (devfont);	TYPE1INSTANCEINFO* type1_inst_info = NULL;	DEVFONT* new_devfont = NULL;		unsigned char c ;	BBox bbox;	int i;	int width=0;	int sum=0;	int count=0;	int max_width=0;	if ((new_devfont = (DEVFONT *)calloc (1, sizeof (DEVFONT))) == NULL)	        goto out;	if ((type1_inst_info = (TYPE1INSTANCEINFO *)calloc (1, sizeof (TYPE1INSTANCEINFO))) == NULL)		goto out;	memcpy (new_devfont, devfont, sizeof (DEVFONT));	new_devfont->data = type1_inst_info;	type1_inst_info->type1_info = type1_info;	type1_inst_info->size     = logfont->size;	if(logfont->rotation)	{		type1_inst_info->rotation = logfont->rotation; /* in tenthdegrees */		type1_inst_info->pmatrix = T1_RotateMatrix( NULL ,     type1_inst_info->rotation / 10.0 );		}	type1_inst_info->last_bitmap_char = -1;	type1_inst_info->last_pixmap_char = -1;	type1_inst_info->last_bitmap_str  = NULL;		type1_inst_info->last_pixmap_str  = NULL;		c = 'A';	get_char_bitmap(logfont,new_devfont,&c,1);	bbox = T1_GetCharBBox(type1_info->font_id,'A');	type1_inst_info->csUnit2Pixel = (double) ( type1_inst_info->last_rightSideBearing - 		type1_inst_info->last_leftSideBearing ) / ( double ) ( bbox.urx - bbox.llx )  ;	bbox = T1_GetFontBBox(type1_info->font_id);	type1_inst_info->font_ascent = bbox.ury * type1_inst_info->csUnit2Pixel ;	type1_inst_info->font_descent = bbox.lly * type1_inst_info->csUnit2Pixel ; 	type1_inst_info->font_height = type1_inst_info->font_ascent - type1_inst_info->font_descent ;		for( i = 0 ; i<=255; i++)	{		width = T1_GetCharWidth ( type1_info->font_id, i );		if ( width > 0 ) {			count ++;			sum += width;			if ( width > max_width)				max_width = width;		}		}		type1_inst_info->max_width = max_width * type1_inst_info->csUnit2Pixel;	type1_inst_info->ave_width = ( sum / count + 1 ) * type1_inst_info->csUnit2Pixel ;	return new_devfont;	out:		free (type1_inst_info);		free (new_devfont);		return NULL;}static void delete_instance (DEVFONT* devfont){	TYPE1INSTANCEINFO* type1_inst_info = TYPE1_INST_INFO_P (devfont);	TYPE1INFO* type1_info = type1_inst_info->type1_info;	T1_DeleteSize(type1_info->font_id,type1_inst_info->size);	if(type1_inst_info->pmatrix)		free(type1_inst_info->pmatrix);	if(type1_inst_info->last_bits)		free(type1_inst_info->last_bits);	if(type1_inst_info->last_bitmap_str)		free(type1_inst_info->last_bitmap_str);	if(type1_inst_info->last_pixmap_str)		free(type1_inst_info->last_pixmap_str);	free (type1_inst_info);	free (devfont);}/**************************** Global data ************************************/static FONTOPS type1_font_ops = {	get_char_width,	get_str_width,	get_ave_width,	get_max_width,	get_font_height,	get_font_size,	get_font_ascent,	get_font_descent,	char_bitmap_size,	max_bitmap_size,	get_char_bitmap,	get_char_pixmap,	start_str_output,	get_char_bbox,	get_char_advance,	new_instance,	delete_instance#if 0		,	get_str_bitmap,	get_str_pixmap#endif};/* General transformation *//*         		( y11   y21 )    (x1,x2)    *   (           ) = (x1*y11 +x2 *y12, x1 *y21+x2*y22;   		( y12   y22 )   *//*static void my_TransformMatrix( T1_TMATRIX *matrix, double * x1, double  * x2 ){	double y1 ;	double y2 ;	if (matrix==NULL) return( NULL);   	y1 = ( *x1 ) * matrix->cxx + ( *x2 ) * matrix->cxy;	y2 = ( *x1 ) * matrix->cyx + ( *x2 ) * matrix->cyy; 	*x1 = y1;	*x2 = y2;	return;}*/#endif /* _TYPE1_SUPPORT */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -