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

📄 cafont_cfont.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifndef lintstatic char SccsId[] = "  @(#)cafont_cfont.c	4.1   LPS_ULT_TRN   7/2/90";#endif/* file: cafont_cfont.c * *	COPYRIGHT  (c)  DIGITAL  EQUIPMENT CORPORATION 1987, *	1988, 1989 ALL RIGHTS RESERVED. * *	THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE *	USED AND COPIED ONLY IN ACCORDANCE  WITH THE TERMS OF *	SUCH  LICENSE  AND  WITH  THE  INCLUSION OF THE ABOVE *	COPYRIGHT  NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES *	THEREOF   MAY  NOT  BE  PROVIDED  OR  OTHERWISE  MADE *	AVAILABLE  TO  ANY  OTHER  PERSON.  NO  TITLE  TO AND *	OWNERSHIP  OF  THE  SOFTWARE  IS  HEREBY TRANSFERRED. * *	THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE *	WITHOUT  NOTICE  AND SHOULD  NOT BE  CONSTRUED  AS A *	COMMITMENT  BY  DIGITAL EQUIPMENT CORPORATION. * *	DIGITAL  ASSUMES  NO RESPONSIBILITY  FOR THE  USE  OR *	RELIABILITY  OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT *	SUPPLIED BY DIGITAL. * *//* *----------------------------------------------------------- * *   begin edit_history * *  araj   14-MAY-1988 11:38 *	Creation by splitting CAFONT_SEL.C * *  araj    22-MAY-1988 21:02 *	Added processing for assign by font_12 and *	assign by font 16 * *  araj    24-MAY-1988 12:32 *	Modified init_sgr_tbl to use a constant cfont_def_sgr. * *  mhs      7-JUL-1988 13:34 *	Move init_sgr_tbl to cafont_sgr. * *  araj    28-NOV-1988 16:50 *	Created and use cfont_data_best structure, to gather info *	about best font. * *	Modified update_best, horiz_spacing, .. to use it * *  ejs	    29-NOV-1988 12:43 *	Created cfont_cache_widths and called it from compute_font_for_g_set. * *  araj    30-NOV-1988 10:30 *	Merged Ed's changes and mine, removed cfont_transform_index, that *	was used to differentiate between real ISOs, and built in ISOs. *	This is now handled by codegen. * *  18-DEC-1988 15:19 ejs *		Major changes to data structutes.  GLYPH has been modified *		to allow struct copies more easily.  The PS output is not *		changed (barring bugs of course). * *  20-MAR-1989 C. Peters *		Removed extraneous '&' operators for Ultrix port. * *   end edit_history * *----------------------------------------------------------- *//* *----------------------------------------------------------- * *   begin description * *   Filename:  cafont_cfont.c * * *   This module includes * * ca_font_init () * b36_to_bin() * nbin_to_b36() * bin_to_b36() * cfont_type_family() * cfont_spacing() * cfont_type_size() * cfont_scale_factor() * cfont_style() * cfont_weight() * cfont_proportion() * cfont_rotation() * cfont_cset() * cfont_id_type_family() * cfont_id_spacing() * cfont_id_type_size() * cfont_id_scale_factor() * cfont_id_attributes() * cfont_id_weight() * cfont_id_proportion() * cfont_id_rotation() * cfont_id_cset() * cfont_id_csubset() * cfont_id_encoding() * cfont_id_resolution() * cfont_id_reserved() * compute_font() * invalidate_font() * invalidate_font_for_g_set90 * invalidate_vai() * cfont_space() * cfont_blob() * cfont_explode_attributes() * cfont_grade_font() * compute_font_for_g_set() * cfont_horiz_spacing() * init_g_table () * cfont_pairing() * *   end description * *----------------------------------------------------------- */#define cafont_cfont	(1)/*  begin include_file    */#include    "portab.h"	    /* portability constants */#include    "cpsys.hc"	    /* global defs, typedefs, etc. */#include    "cpast.hc"	    /* ANSI State Table & Token Table Declarations */#include    "cpglobal.hc"   /* globals for CP modules */#include    "camac.lib_hc"  /* non-dump oprintf */#include    "caglobal.hc"   /* globals defs for the CARs *//*  end   include_file    *//*****  ca_font_init()  ************************************************* * Do any initialization required to set up for font processing.	* ************************************************************************/VOID ca_font_init ()   {    if (xl_st.cur_sgr == 5)       {	xl_st.last_gss = xl_st.v_size = 670;	/* Typesize in centipoints */       }    else       {	xl_st.last_gss = xl_st.v_size = 1000;	/* Typesize in centipoints */       }    xl_st.character_proportion = 100;		/* % of char width to height */    xl_st.user_pref_cset = DEC_SUPPLEMENTAL;    xl_st.user_pref_repertory = C94;    xl_st.gl_ptr = &xl_st.g_table [0];    xl_st.gr_ptr = &xl_st.g_table [2];    xl_st.ssf = 0;     init_g_table ();    init_sgr_tbl();}  /* end of font_init *//*****  compute_vai() *************************************************** * Compute Vertical Advance Increment					* ************************************************************************/VOID compute_vai ()   {    /* Set the vertical advance increment equal either to the vertical space      * increment, if it is a real non-zero value, or otherwise, to the      * estimated total vertical size (in centipoint), controlled by GSS and     * GSM.  The 'total vertical size' is estimated by multiplying the nominal      * point size by 1.152 --this ratio is obtained from built-in 'courier'      * font metrics and is taken to be representative.      */     /*	First, make sure that GL is pointing to a valid GSET, as a change in the     *	font selection criteria may have invalidate the choice     */    if ( xl_st.gl_ptr->gset_valid == FALSE)	{	    compute_font_for_g_set ( xl_st.gl_ptr - (&xl_st.g_table[0]));	}    xl_st.vai = (xl_st.vsi != 0)       ? (xl_st.vsi)       : (FNT_HEIGHT(xl_st.gl_ptr->gset_map[32].char_font));    xl_st.vai_valid = TRUE;   }/*****  b36_to_bin () *************************************************** * Convert base 36 to binary						* ************************************************************************//*  This function converts a base 36 digit into binary, **  the digit must have already been capitalized, and **  checked to ensure validity*/WORD b36_to_bin (font_id_byte)UBYTE font_id_byte;{  if ('A' <= font_id_byte)    return ((WORD)(font_id_byte - 'A' + 10));  else    return ((WORD)(font_id_byte - '0'));}/*****  nbin_to_b36 () ************************************************** * Convert binary to base 36 (n bytes)					* ************************************************************************//*  This function converts a binary word in a base 36 string n bytes long*/VOID nbin_to_b36 (font_id_ptr, value, t_length)PUB font_id_ptr;WORD value;WORD t_length;{UBYTE	temp_byte;WORD	temp_value;WORD	i;temp_value = value;    for ( i = t_length - 1; i >= 0; i--)       {        temp_byte = temp_value % 36;        temp_value = temp_value / 36;            if (temp_byte < 10)           {	    font_id_ptr[i] = temp_byte +'0';	   }	else	   {    	    font_id_ptr[i] = temp_byte + 'A' - 10;	   }       }   }/*****  bin_to_b36 () *************************************************** * Convert binary to base 36 (1 byte)					* ************************************************************************//*  This function converts a binary word onto 1 base 36 byte, **  there is no provision for overflow.*/UBYTE bin_to_b36 (value)WORD value;{        if (value < 10)        {	return ((UBYTE)(value +'0'));	}	else	{	return ((UBYTE)(value + 'A' - 10));	}}/*****  cfont_type_family () ******************************************** * Type family								* ************************************************************************//* This function extracts the type family from a font_file_id*/VOID cfont_type_family (font_id_ptr,type_family_ptr)PTR_FONT_ID font_id_ptr;PB  type_family_ptr;{strncpy (type_family_ptr, font_id_ptr->fi_type_family, FIDS_TYPE_FAMILY);}/*****  cfont_spacing () ************************************************ * spacing								* ************************************************************************//* This function extracts the spacing from a font_file_id*/VOID cfont_spacing (font_id_ptr, spacing_criterion, spacing_value)PTR_FONT_ID font_id_ptr;PW spacing_criterion;PW spacing_value;{WORD tmp_spacing_value_fraction;WORD tmp_spacing_value;tmp_spacing_value = b36_to_bin (font_id_ptr->fi_spacing);			/* Get byte 8 */tmp_spacing_value_fraction = b36_to_bin (font_id_ptr->fi_res1);			/* Get byte 29 */    *spacing_criterion = MONO_SPACED_MODE;  switch (tmp_spacing_value)    {    case 0:	tmp_spacing_value = PROPORTIONAL_PITCH;		*spacing_criterion =  PROPORTIONAL_MODE;		break;    case 1: 	tmp_spacing_value = CPI_13_6;		break;    case 2: 	tmp_spacing_value = CPI_10_3;    		break;    case 3: 	tmp_spacing_value = CPI_6_8;    		break;    case 4: 	tmp_spacing_value = CPI_9_34;    		break;    case 5: 	tmp_spacing_value = CPI_7_5;    		break;    case 6: 	tmp_spacing_value = CPI_18_75;    		break;    case 7: 	tmp_spacing_value = CPI_13_3;    		break;    case 8: 	tmp_spacing_value = CPI_5_7;    		break;    case 9: 	tmp_spacing_value = CPI_5_4;    		break;    default:		tmp_spacing_value = 7200L/((LONG)tmp_spacing_value - 9L + ((LONG)tmp_spacing_value_fraction /20L ));        }    *spacing_value = tmp_spacing_value; }/*****  cfont_type_size () ********************************************* * type size								* ************************************************************************//*  This function extracts the type size from a font_file_id**  The actual point size is not the point size, but the point size * scale factor*/WORD cfont_type_size (font_id_ptr)PTR_FONT_ID font_id_ptr;{WORD i;WORD temp;    for (i=0, temp = 0; i<FIDS_TYPE_SIZE; i++)    {    	temp = (temp * 36) + b36_to_bin(font_id_ptr->fi_type_size[i]);    }    return (temp*10*cfont_scale_factor(font_id_ptr));}/*****  cfont_scale_factor () ******************************************* * Scale factor								* ************************************************************************//* This function extracts the scale factor from a font_file_id*/WORD cfont_scale_factor (font_id_ptr)PTR_FONT_ID font_id_ptr;{WORD temp;temp = (b36_to_bin (font_id_ptr->fi_scale_factor));switch (temp)    {/* Test code *//* we need to modify scale factor to return the floating point values */	default:    temp = 1;/*  End test code */    }return (temp);}/*****  cfont_style() *************************************************** * Style								* ************************************************************************//* This function extracts the style from a font_file_id*/WORD cfont_style (font_id_ptr)PTR_FONT_ID font_id_ptr;{WORD i;WORD temp;    for (i=0, temp = 0; i<FIDS_STYLE; i++)    {		temp = (temp * 36) + b36_to_bin(font_id_ptr->fi_style[i]);    }    if (temp & SLANT)    {	temp = ((temp & NO_SLANT) | ITALIC);    }    return (temp);}/*****  cfont_weight() ************************************************** * Weight								* ************************************************************************//* This function extracts the weight from a font_file_id*/WORD cfont_weight (font_id_ptr)PTR_FONT_ID font_id_ptr;{return (b36_to_bin (font_id_ptr->fi_weight));}/*****  cfont_proportion() ********************************************** * Proportion								* ************************************************************************//* This function extracts the proportion from a font_file_id*/WORD cfont_proportion (font_id_ptr)PTR_FONT_ID font_id_ptr;{WORD temp_proportion;    /*	Note, there is no recognized relationship between the codes     **	in the font ID, compressed, super compressed, ..    **	and the actual values received for the GSM    **	or stored in the font header.    **    **	The following code is an attempt (bad) to create such a relationship    */temp_proportion = (b36_to_bin (font_id_ptr->fi_proportion));    if (temp_proportion <= 3)     {		temp_proportion = 220;    }    else    {	if (temp_proportion >= 32)	{	    temp_proportion = 10;	}	else	{	    temp_proportion = ( 220-( (temp_proportion-4)*10) );	}    }    return (temp_proportion);}/*****  cfont_rotation () *********************************************** * Rotation								* ************************************************************************//* This function extracts the rotation from a font_file_id*/WORD cfont_rotation (font_id_ptr)PTR_FONT_ID font_id_ptr;{WORD i;WORD temp;    for (i=0, temp = 0; i<FIDS_ROTATION; i++)    {		temp = (temp * 36) + b36_to_bin(font_id_ptr->fi_rotation[i]);    }    return (temp);}/*****  cfont_cset() **************************************************** * Cset									* ************************************************************************//* This function extracts the character set from a font_file_id*/VOID cfont_cset (font_id_ptr, cset)PTR_FONT_ID font_id_ptr;PW cset;{WORD tmp_cset;WORD i;/* Get the 3-byte base-36 character set ID from Bytes 19-21 of the  * font file ID and convert it to a 16-bit hex value. */tmp_cset = 0;for (i=0; i<FIDS_CSET; i++)  {      tmp_cset = (tmp_cset*36)+(b36_to_bin (font_id_ptr->fi_cset[i]));  }/* If the character set id, in its 16 bit form, of a font file == 0x3c * reassign it as 0xab5 (the id for DEC supplemental). [ 0x3c was the old * 'user preference' id which was supposedly synonymous with DEC

⌨️ 快捷键说明

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