📄 cafont_cfont.c
字号:
* supplemental. Now 'user preference' is an indirect way of specifying a * character set; as such there theoretically no way of there being a 0x3c * character set. */if (tmp_cset == USER_PREFERENCE) tmp_cset = DEC_SUPPLEMENTAL; *cset = tmp_cset;}/***** cfont_id_type_family () ***************************************** * Type family * ************************************************************************//* This function inserts the type family into a font_file_id*/VOID cfont_id_type_family (font_id_ptr, type_family_ptr)PTR_FONT_ID font_id_ptr;PB type_family_ptr;{ strncpy (font_id_ptr->fi_type_family, type_family_ptr, FIDS_TYPE_FAMILY);}/***** cfont_id_spacing () ************************************************ * spacing * ************************************************************************//* This function inserts the spacing into a font_file_id*/VOID cfont_id_spacing (font_id_ptr, spacing_criterion, spacing_value)PTR_FONT_ID font_id_ptr;WORD spacing_criterion;WORD spacing_value;{WORD temp_fraction;WORD temp; if (spacing_criterion == PROPORTIONAL_MODE) { font_id_ptr->fi_res1=font_id_ptr->fi_spacing= '0'; } else { temp_fraction = 0; switch (spacing_value) { case CPI_13_6: temp = 1; break; case CPI_10_3: temp = 2; break; case CPI_6_8: temp = 3; break; case CPI_9_34: temp = 4; break; case CPI_7_5: temp = 5; break; case CPI_18_75: temp = 6; break; case CPI_13_3: temp = 7; break; case CPI_5_7: temp = 8; break; case CPI_5_4: temp = 9; break; default: temp = 7200L / spacing_value; temp_fraction = ((7200L % spacing_value) / 20L); temp += 10L - 1L; } font_id_ptr->fi_spacing = bin_to_b36(temp); /* 1 CPI is A, 2 is B ... */ font_id_ptr->fi_res1 = bin_to_b36 (temp_fraction); }}/***** cfont_id_type_size () ********************************************* * type size * ************************************************************************//* This function inserts the type size into a font_file_id*/VOID cfont_id_type_size (font_id_ptr,type_size)PTR_FONT_ID font_id_ptr;WORD type_size;{ /* note, internaly, the type size is in centipoints, but for the ID, and the ID ** only, it is decipoints */ nbin_to_b36 (font_id_ptr->fi_type_size, (type_size/10), FIDS_TYPE_SIZE);}/***** cfont_id_scale_factor () ******************************************* * Scale factor * ************************************************************************//* This function inserts the scale factor into a font_file_id*/VOID cfont_id_scale_factor (font_id_ptr,scale_factor)PTR_FONT_ID font_id_ptr;WORD scale_factor;{/* test code *//* For now scale factor will always be 20, which is 1 */font_id_ptr->fi_scale_factor = bin_to_b36(20); /* font_id_ptr->fi_scale_factor = bin_to_b36(scale_factor); */}/***** cfont_id_attributes () ****************************************** * Style * ************************************************************************//* This function inserts the style into a font_file_id*/VOID cfont_id_attributes (font_id_ptr, requested_attributes)PTR_FONT_ID font_id_ptr;WORD requested_attributes;{ /* First drop the bold attribute, which goes to weight, not style */ /* Also drop sub/superscript, that are not font attributes, but */ /* just used to select a different font requested_attributes = (requested_attributes & (NO_BOLD & NO_SUPERSCR & NO_SUBSCR); /* Now convert the result to an ID like style specification */ nbin_to_b36 (font_id_ptr->fi_style, requested_attributes, FIDS_STYLE);}/***** cfont_id_weight() ************************************************** * Weight * ************************************************************************//* This function inserts the weight into a font_file_id*/VOID cfont_id_weight (font_id_ptr,weight)PTR_FONT_ID font_id_ptr;WORD weight;{ font_id_ptr->fi_weight = bin_to_b36(weight);}/***** cfont_id_proportion() ********************************************** * Proportion * ************************************************************************//* This function inserts the proportion into a font_file_id*/VOID cfont_id_proportion (font_id_ptr, proportion)PTR_FONT_ID font_id_ptr;WORD proportion;{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 */ if (proportion > 220) { temp_proportion = 3; } else { if (proportion < 10) { temp_proportion = 32; } else { temp_proportion = ((220-proportion)/10)+4; } } font_id_ptr->fi_proportion = bin_to_b36(temp_proportion);}/***** cfont_id_rotation () ******************************************** * Rotation * ************************************************************************//* This function inserts the rotation into a font_file_id*/VOID cfont_id_rotation (font_id_ptr, rotation)PTR_FONT_ID font_id_ptr;WORD rotation;{ nbin_to_b36 (font_id_ptr->fi_rotation, rotation, FIDS_ROTATION);}/***** cfont_id_cset() ************************************************* * Cset * ************************************************************************//* This function inserts the character set into a font_file_id*/VOID cfont_id_cset (font_id_ptr, cset)PTR_FONT_ID font_id_ptr;WORD cset;{ nbin_to_b36 (font_id_ptr->fi_cset, cset, FIDS_CSET); /* Until we start supporting the additional bit for CSET ID, byte 30 ** (was res2) is set to 0. */ font_id_ptr->fi_res2 = bin_to_b36 (0);}/***** cfont_id_csubset() ********************************************** * Cset * ************************************************************************//* This function inserts the character sub set into a font_file_id*/VOID cfont_id_csubset (font_id_ptr, csubset_ptr)PTR_FONT_ID font_id_ptr;PB csubset_ptr;{ strncpy (font_id_ptr->fi_csubset, csubset_ptr, FIDS_CSUBSET);}/***** cfont_id_encoding () ******************************************** * Cset * ************************************************************************//* This function inserts the encoding into a font_file_id*/VOID cfont_id_encoding (font_id_ptr)PTR_FONT_ID font_id_ptr;{ nbin_to_b36 (font_id_ptr->fi_encoding, BIN_CFFF_ENCODING, FIDS_ENCODING);}/***** cfont_id_resolution () ****************************************** * Resolution * ************************************************************************//* This function inserts the resolution into a font_file_id*/VOID cfont_id_resolution (font_id_ptr, resolution)PTR_FONT_ID font_id_ptr;WORD resolution;{ font_id_ptr->fi_resolution = bin_to_b36 (RESOLUTION_300);}/***** cfont_id_reserved () ******************************************** * Reserved * ************************************************************************//* This function inserts the reserved fields into a font_file_id** at this time, the only one left is byte 31, reserved for customer, ** all other reserved bits have been assigned*/VOID cfont_id_reserved (font_id_ptr)PTR_FONT_ID font_id_ptr;{ font_id_ptr->fi_res3 = '0';}/***** compute_font() ************************************************** * Compute Font * ************************************************************************/VOID compute_font(){WORD i; /* for-loop index */ compute_proportional_mode ();/* Re-compute the font for all four G sets. */for (i = 0; i < G_TABLE_SIZE; i++) compute_font_for_g_set (i);compute_vai ();} /* end of compute_font *//***** invalidate_font() *********************************************** * Invalidate Font * ************************************************************************/VOID invalidate_font(){WORD i; /* for-loop index *//* Invalidate the font for all four G sets. */for (i = 0; i < G_TABLE_SIZE; i++) xl_st.g_table[i].gset_valid = FALSE;/* Invalidate the value of VAI as it depends on the font used for GL*/xl_st.vai_valid = FALSE;/* Compute font used to have teh side effect of calling * compute proportional mode * * To avoid breaking too many pieces, this side effect * is not transferred to invalidate_font * * At some future point, it might be worth looking at * all the calls to invalidate_font, and decide which ones * really need to call compute_proportional_mode */ compute_proportional_mode ();} /* end of invalidate_font *//***** invalidate_font_for_g_set() ************************************* * Invalidate Font for one G set * ************************************************************************/VOID invalidate_font_for_g_set(g_table_entry)WORD g_table_entry;{ xl_st.g_table[g_table_entry].gset_valid = FALSE;/* Invalidate the value of VAI as it depends on the font used for GL*/xl_st.vai_valid = FALSE;} /* end of invalidate_font_for_g_set *//***** invalidate_vai ************************************************** * Invalidate VAI * ************************************************************************/VOID invalidate_vai (){/* Invalidate the value of VAI as it depends on the font used for GL*/xl_st.vai_valid = FALSE;} /* end of invalidate_vai *//***** cfont_blob() **************************************************** * Cfont Blob * ************************************************************************/VOID cfont_blob (g_table_entry,cfont_index_best)WORD g_table_entry;FONT_NUMBER cfont_index_best;{/* Prepare the specified G set to print the error character for all character codes. */WORD i; for (i = 0; i <= 127; i++) { xl_st.g_table[g_table_entry].gset_map[i].char_code = VIR_CHAR_BLOB; xl_st.g_table[g_table_entry].gset_map[i].char_font = cfont_index_best; }} /* end of cfont_blob *//***** cfont_space() *************************************************** * Cfont space we don't even have a blob in the best font, use space * ************************************************************************/VOID cfont_space (g_table_entry,cfont_index_best)WORD g_table_entry;FONT_NUMBER cfont_index_best;{/* Prepare the specified G set to print the error character for all character codes. */WORD i; for (i = 0; i <= 127; i++) { xl_st.g_table[g_table_entry].gset_map[i].char_code = VIR_CHAR_SPACE; xl_st.g_table[g_table_entry].gset_map[i].char_font = cfont_index_best; }} /* end of space *//***** cfont_explode_attributes () ************************************* * cfont explode attributes * ************************************************************************/VOID cfont_explode_attributes (cfont_cur,src_font_id)PTR_CFA cfont_cur;PTR_FONT_ID src_font_id;{cfont_type_family (src_font_id, cfont_cur->cfa_type_family);cfont_spacing (src_font_id, & cfont_cur->cfa_spacing_criterion, & cfont_cur->cfa_spacing_value);cfont_cset (src_font_id, & cfont_cur->cfa_cset);cfont_cur->cfa_type_size = cfont_type_size (src_font_id);cfont_cur->cfa_scale_factor = cfont_scale_factor (src_font_id);cfont_cur->cfa_style = cfont_style (src_font_id);cfont_cur->cfa_weight = cfont_weight (src_font_id);cfont_cur->cfa_proportion = cfont_proportion (src_font_id);cfont_cur->cfa_rotation = cfont_rotation (src_font_id);}/***** cfont_grade_font () ********************************************* * cfont grade font * ************************************************************************/VOID cfont_grade_font (cfont_cur, cfont_des, cfont_g, des_pair, fdp_ptr)PTR_CFA cfont_cur; /* exploded attributes of the font to be graded */PTR_CFA cfont_des; /* exploded attributes of the desired font */PTR_CFG cfont_g; /* structure contining the grade of the font currently under considereration */UBYTE des_pair; /* What pairing mechanisms can be used to make the CSET */PTR_FDP fdp_ptr; /* Additional data passed by ditionary, ** What pairing mechanisms does the current font offer ** does it have a blob... */{ /* First, clear all fault flags */ cfont_g->cfg_fault_flags = FLT_NONE; /* Lets start with Type Family */ /* If there is an exact match, then no fault, grade = exact match ** If the font under consideration is no style (D000000), then no fault, grade = No style fall back ** If the font under consideration is builtin (DBILTIN), then fault, grade = built in fall back */ /* Little Trivia, STRNCMP returns false if the strings are equal */ if (!(strncmp (cfont_cur->cfa_type_family, cfont_des->cfa_type_family, FIDS_TYPE_FAMILY))) { cfont_g->cfg_type_family = EXACT_MATCH; } else if (!(strncmp (cfont_cur->cfa_type_family, dpi_font_string, FIDS_TYPE_FAMILY))) /* Little Trivia, STRNCMP returns false if the strings are equal */ { cfont_g->cfg_type_family = NO_STYLE_FALL_BACK; } else if (!(strncmp (cfont_cur->cfa_type_family, dbuiltin_string, FIDS_TYPE_FAMILY))) /* Little Trivia, STRNCMP returns false if the strings are equal */ { cfont_g->cfg_type_family = BUILT_IN_FALL_BACK; cfont_g->cfg_fault_flags |= FLT_TYPE_FAMILY; } else { cfont_g->cfg_type_family = NO_BUILT_IN_FALL_BACK; cfont_g->cfg_fault_flags |= FLT_TYPE_FAMILY; } /* Now do spacing */ /* If the spacing criterion are the same, then spacing criterion = EXACT_MATCH ** else MONO_PROP_FALL_BACK */ cfont_g->cfg_spacing_criterion = (cfont_cur->cfa_spacing_criterion == cfont_des->cfa_spacing_criterion) ? EXACT_MATCH : MONO_PROP_FALL_BACK; /* If the desired and current spacing value are the same, then exact match ** If the desired is larger than current, then value grading ** If the desired is smaller, then spacing fault and value grading */ cfont_g->cfg_spacing_value = ABS(cfont_cur->cfa_spacing_value - cfont_des->cfa_spacing_value); if (cfont_cur->cfa_spacing_value > cfont_des->cfa_spacing_value) { cfont_g->cfg_fault_flags |= FLT_SPACING_VALUE; } /* Now do character set */ /* If exact match then exact match
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -