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

📄 cafont_cfont.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 4 页
字号:
 * multiplying commanded character proportion (~=type_width / type_height), * from GSS/GSM, by commanded type size (=type_height). Because a normal * character_proportion, expressed as 100%, (as we define it within this * module) refers to a  *     width : size (=height) ratio = 720 centipoint / 1000 centipoint * xl_st .character_proportion needs to be multiplied by  *     (720 centipoint / 1000 centipoint) / 100[%] * to yield a true width : size (=height) ratio. Therefore the proposed * spacing critrion may be synthesized as follows:  */if  (cfont_selection_type == SGR_TYPE_FAMILY)    {	cfont_des.cfa_spacing_criterion = xl_st.propl_mode;	cfont_des.cfa_spacing_value =   (cfont_des.cfa_spacing_criterion == MONO_SPACED_MODE) ?	                                xl_st .hai :	 				(   ( ((LONG)xl_st .v_size)					    * ((LONG) xl_st .character_proportion)					    * 72L					    )/ 10000L 					);    }    else    {	cfont_spacing	(cfont_requested_id, 			 &cfont_des.cfa_spacing_criterion, 			 &cfont_des.cfa_spacing_value			);    }/*  Find the desired type_size *//* If assign by type family, then get it from xl_st_v_size, else get it from SGR */if  (cfont_selection_type == SGR_TYPE_FAMILY)    {	cfont_des.cfa_type_size = xl_st.v_size;    }    else    {	cfont_des.cfa_type_size = cfont_type_size (cfont_requested_id);	    }/* Find desired Scale factor*//* If assign by type family, then use 1, else get it from SGR */if  (cfont_selection_type == SGR_TYPE_FAMILY)    {	/*TEST CODE */	/* For now, scale factor is 1, need to deal with float values */	cfont_des.cfa_scale_factor = 1;	/*  cfont_des.cfa_scale_factor = SCALE_FACTOR_1;*/	/* END TEST CODE */    }    else    {	cfont_des.cfa_scale_factor = cfont_scale_factor (cfont_requested_id);    }/* Find desired Style*//*  Gather the desired attributes****  If the SGR is a select by type family (7 chars), or by xxx (12 chars)**  get the attributes from the attribute selection (xl_st.requested_attributes)****  Else, this is a select by font, get the attribute selection from the font_id*/if  (cfont_selection_type == SGR_FONT_16)    {	cfont_des.cfa_style = cfont_style (cfont_requested_id);	if (cfont_weight (cfont_requested_id) == BOLD_WEIGHT_CODE)	{	    cfont_des.cfa_style |= BOLD;	}    }        else    {	cfont_des.cfa_style = xl_st.requested_attributes;    }/* * Find desired Weight *  * If the selection is by FONT_16, then get the weight from the SGR * else get it from XL_ST */if  (cfont_selection_type == SGR_FONT_16)    {	cfont_des.cfa_weight = cfont_weight (cfont_requested_id);    }    else    {	cfont_des.cfa_weight = (xl_st.requested_attributes & BOLD) ?		    BOLD_WEIGHT_CODE : REGULAR_WEIGHT_CODE;     }/* Find desired Proportion *  * If the selection is by FONT_16, then get the proportion from the SGR * else get it from XL_ST */if  (cfont_selection_type == SGR_FONT_16)    {	cfont_des.cfa_proportion = cfont_proportion(cfont_requested_id);    }    else    {	cfont_des.cfa_proportion = xl_st.character_proportion;    }/*Find desired rotation */cfont_des.cfa_rotation = ROTATION_0;/*  Gather the selection criteria for the character set **  This entails:****	The character set ID**	Whether or not the character set is an NRCS that  can be obtained from a paired font****  The character set id may be obtained directly, or if we are dealing with User Preference CSET, **  must be de-referenced.*//* * Get a local copy of the character set desired for this g_table_entry. */	/* Point to selected CSET */cfont_des.cfa_cset	= xl_st .g_table [g_table_entry].char_set_id ;	/*  If this is the User Preference set, go through 	    an additional level of indirection	*/	if (cfont_des.cfa_cset  == USER_PREFERENCE)  {  cfont_des.cfa_cset = xl_st .user_pref_cset;  };/* Decide whether the character set can be obtained from a paired font*/    /* First is this set out of the 94 repertory, if not this is not an NRC */        if (!(cfont_des.cfa_cset & SET_96_BIT))    {	/* If so, is it in the NRC list */	/*  At this time, this code assumes that there is only 	    one supported pairing mechanism for each NRC,	    i.e. French can only be obtained from DEC_MCS,	    but not ISO_LATIN_#1, if this were to change, 	    this code, as well as the grading of fonts on CSET	    as well as the final setup performed by compute_font_for_gset	    need to be modified	*/    desired_pair = DEC_MCS_PAIR;    MCS_pairing_table_index = 3;    switch (cfont_des.cfa_cset)      {      case FRENCH                   : MCS_pairing_table_index++; /*16 */      case DEC_DUTCH                : MCS_pairing_table_index++; /*15 */    /*     * nrcs above this comment are supported differently by DEC and ISO SUPPLEMENTAL     */      case ISO_NORWEGIAN_DANISH     :      case DEC_NORWEGIAN_DANISH     : MCS_pairing_table_index++; /*14 */      case NORWEGIAN_DANISH         : MCS_pairing_table_index++; /*13 */      case ISO_SWEDISH              :      case DEC_SWEDISH              : MCS_pairing_table_index++; /*12 */      case DEC_PORTUGESE            : MCS_pairing_table_index++; /*11 */      case SPANISH                  : MCS_pairing_table_index++; /*10 */      case DEC_FRENCH_CANADIAN      : MCS_pairing_table_index++; /* 9 */      case GERMAN                   : MCS_pairing_table_index++; /* 8 */      case ITALIAN                  : MCS_pairing_table_index++; /* 7 */      case JIS_ROMAN                : MCS_pairing_table_index++; /* 6 */      case DEC_SWISS                : MCS_pairing_table_index++; /* 5 */      case ISO_FINNISH              :      case DEC_FINNISH              : MCS_pairing_table_index++; /* 4 */      case UNITED_KINGDOM           : break;  /* 3 */          case DEC_SUPPLEMENTAL         :      case DEC_TECHNICAL            :      case ASCII                    :      case DEC_VT100                :      default                       : MCS_pairing_table_index = 0;				      desired_pair = NO_DESIRED_PAIR;                                      break;  }} /* end if C94 repertory *//* We now have gathered the selection Criteria *//* Let's build the ID of the perfect font */cfont_id_type_family (& cfont_perfect_id, cfont_des.cfa_type_family);cfont_id_spacing (& cfont_perfect_id, cfont_des.cfa_spacing_criterion, cfont_des.cfa_spacing_value);cfont_id_type_size (& cfont_perfect_id, cfont_des.cfa_type_size);cfont_id_scale_factor (& cfont_perfect_id, cfont_des.cfa_scale_factor);cfont_id_attributes (& cfont_perfect_id, cfont_des.cfa_style);cfont_id_weight (& cfont_perfect_id, cfont_des.cfa_weight);cfont_id_proportion (& cfont_perfect_id, cfont_des.cfa_proportion);cfont_id_rotation (& cfont_perfect_id, cfont_des.cfa_rotation);cfont_id_cset (& cfont_perfect_id, cfont_des.cfa_cset);cfont_id_csubset (& cfont_perfect_id, subset_zzzz);cfont_id_encoding (& cfont_perfect_id);cfont_id_resolution (& cfont_perfect_id, RESOLUTION_300);cfont_id_reserved (& cfont_perfect_id);/* Let's initialize the dialogue with the Font Dictionary */font_get_default (cfont_des_orientation, & cfont_perfect_id, & current_font);/* Let's grade the default font returned */cfont_explode_attributes (&cfont_cur, &current_font.fdp_font_id);    cfont_grade_font (&cfont_cur, &cfont_des, &cfont_grade, desired_pair, &current_font);/* Initialize best so far to the default returned */cfont_update_best ( &cfont_data_best, &cfont_grade_best, &cfont_grade, &current_font, &cfont_cur);while (font_get_next(& current_font), current_font.fdp_font_index != END_OF_DICTIONARY){            /* if by magic we got the perfect one, quit */    if (!(strncmp (& current_font.fdp_font_id, & cfont_perfect_id, FIDS_FONT_ID)))    /*	Little Trivia, STRNCMP returns false if the strings are equal */    {    /*	The following lines are there to ensure that cfont_data_best gets filled     *	properly.     *	In a future optimization pass, these calls could be cut down to the minimum     *  necessary to fill the structure, knowing that everything is perfect.     */    cfont_explode_attributes (& cfont_cur,& current_font.fdp_font_id);        cfont_grade_font (& cfont_cur,& cfont_des,& cfont_grade, desired_pair, & current_font);    cfont_update_best ( &cfont_data_best, &cfont_grade_best, &cfont_grade, &current_font, &cfont_cur);    break;    }            cfont_explode_attributes (& cfont_cur,& current_font.fdp_font_id);        cfont_grade_font (& cfont_cur,& cfont_des,& cfont_grade, desired_pair, & current_font);    /* Compare best grade so far with current font */    if (cfont_comp_grade (&cfont_grade_best, &cfont_grade))    {	cfont_update_best ( &cfont_data_best, &cfont_grade_best, &cfont_grade, &current_font, &cfont_cur);    }}/*  Got best font for the job  *//*  Tell font dictionary to cache font  *  and get the font_number for the paired font *  if any *//* First find out if we decided to use pairing or not */    if	(cfont_grade_best.cfg_cset != PAIRING_FALL_BACK)	{	    cfont_data_best.cfb_pair_type = NO_DESIRED_PAIR;	}    cfont_data_best.cfb_pair_index = font_select (cfont_data_best.cfb_index,                                                   &cfont_data_best.cfb_scale,                                                   cfont_data_best.cfb_pair_type,                                                   g_table_entry);/*  Cache Gtable *//*  Algorithmic attributes *//*  NRC tables *//*  Algorithmic spacing *//*  Width table	*//*  Above and below baseline values *//* * The g_table is updated according to the font table information for the * best font file found ( = preferred_index). * * The algorithmic_attributes = the requested_attributes which are not  * already part of the best font file. */xl_st .g_table [g_table_entry] .gset_fontdata .algorithmic_attributes =     (~ (cfont_data_best.cfb_attr )) &  (cfont_des.cfa_style);    /* * The ps_font_number = the best font file's ps_font_number  *//*xl_st .g_table [g_table_entry] .gset_map .ps_font_number = **			cfont_data_best.cfb_index;*//* * The horizontal_spacing is determined by the horiz_spacing function below. */  xl_st .g_table [g_table_entry] .gset_fontdata .horizontal_spacing =    cfont_horiz_spacing (&cfont_data_best); xl_st .g_table [g_table_entry] .gset_fontdata . above_baseline_offset =     FNT_ABOVE_BASELINE(cfont_data_best.cfb_index); xl_st .g_table [g_table_entry] .gset_fontdata . below_baseline_offset =     FNT_BELOW_BASELINE(cfont_data_best.cfb_index);    /* Now deal with NRC stuff */    switch (cfont_data_best.cfb_pair_type)    {	case DEC_MCS_PAIR:  cfont_data_best.cfb_nrc_type = MCS_pairing_table_index;			    break;	case ISO_LAT_PAIR:  cfont_data_best.cfb_nrc_type = ISO_pairing_table_index;			    break;	case DEC_TEC_PAIR:  cfont_data_best.cfb_nrc_type = TEC_pairing_table_index;			    break;	case DEC_PUB_PAIR:  cfont_data_best.cfb_nrc_type = PUB_pairing_table_index;			    break;	case NO_DESIRED_PAIR:	default:	    cfont_data_best.cfb_nrc_type = 0;    }		    cfont_pairing (g_table_entry, &cfont_data_best);    /* if we got a CSET fault, (can't find cset), then use blob.     * Note, in a future optimization pass, this should be      * mutually exclusive with the above pairing code,      * provided we can ensure that Blob performs all the required functions     */    if 	(cfont_grade_best.cfg_fault_flags &  FLT_CSET)	 		{	    if	(cfont_grade_best.cfg_cset == BLOB_FALL_BACK)		{		    cfont_blob (g_table_entry, cfont_data_best.cfb_index);		}		else		{		    cfont_space (g_table_entry, cfont_data_best.cfb_index);		}	}    cfont_cache_widths(g_table_entry);    xl_st.g_table[g_table_entry].gset_valid = TRUE;}  /* end of compute_font_for_g_set */VOID cfont_cache_widths(g_table_entry)WORD	g_table_entry;{WORD i;for (i=0;i<=127;i++)    {    xl_st.g_table[g_table_entry].gset_map[i].char_width=	get_width(	    (xl_st.g_table[g_table_entry].gset_map[i].char_code),	    (xl_st.g_table[g_table_entry].gset_map[i].char_font)		 );    };}LONG cfont_horiz_spacing (cfont_data_best_ptr)PTR_CFB cfont_data_best_ptr;	/* ptr to structure containing among others :		*/				/* font_table index  of selected font			*/				/* spacing value of selected font (if MONO)		*/				/* spacing criterion of selected font   (MONO vs PROP)  */  /* This function returns the horizontal spacing which is to be associated with  * a G set's glyph's. A zero value means that the font's width table satisfies * the commanded spacing requirements; if the font's width table does not * satisfy the commanded spacing requirements, then a non-zero value is * returned which indicates the corrected value to use for spacing.  */{/* If what is commanded is a mono-spaced mode with a spacing = xl_st .hai but  * the font, indicated by the font table index i, is either proportionally * spaced (font_table [i] .spacing = 0) or mono-spaced (font_table [i] .spacing * = non-zero spacing value) but not equal to xl_st .hai, then use (i.e., * return) xl_st .hai.  * If what is commanded is a semi-proportional mode but the font, indicated by * the font table index i, is proporttionally spaced then use (i.e., return) * the font's average width.  * In all other situations return a value of zero signifying that the font's * width table satisfies the commanded spacing requirements. * * *                      |        commanded proportional spacing: *                      | *                      |   MONO_SPACED_                   SEMI_ *                      |   MODE           PROPORTIONAL_   PROPORTIONAL_ *      font file's     |   [xl_st .hai]   MODE            MODE *        spacing:      | *                      |------------------------------------------------ *      == xl_st .hai   |        0             0              0   *                      | *      != xl_st .hai   |    xl_st .hai        0              0 *                      | *      == proportional |    xl_st .hai        0         average_width *                      | */if (  (xl_st .propl_mode == MONO_SPACED_MODE)      &&      (xl_st .hai != cfont_data_best_ptr->cfb_spacing_value)    )  return (xl_st .hai);else if ( (xl_st .propl_mode == SEMI_PROPORTIONAL_MODE)          &&	  (cfont_data_best_ptr->cfb_spacing_crit == PROPORTIONAL_MODE)	)  return ( FNT_AVERAGE_WIDTH(cfont_data_best_ptr->cfb_index));else  return (0);}/*****  init_g_table() ************************************************** * Init G Table								* ************************************************************************/VOID init_g_table ()   {    WORD i;    /*      * All gsets have the same repertory, C94     */    for (i=0; i<G_TABLE_SIZE; i++)	xl_st .g_table [i].repertory = C94;    /*     * Init the char_set_id fields individually     */    xl_st .g_table [0].char_set_id =	xl_st .g_table [1].char_set_id = ASCII;    xl_st .g_table [2].char_set_id =	xl_st .g_table [3].char_set_id = USER_PREFERENCE;   }

⌨️ 快捷键说明

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