📄 caspac.c
字号:
#ifndef lintstatic char SccsId[] = " @(#)caspac.c 4.1 LPS_ULT_TRN 7/2/90";#endif/* file: caspac.c * * COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1985, * 1986, 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 * * 2-FEB-1988 16:55 mhs * Initial Entry of combination of caspac and duspac * * 23-JUN-1988 14:57 mhs * Change right margin from 65,536 (too large for a WORD * param without going negative) to CP_MAX_PARM in faked * call to SLRM in DEC_SHORP. * Add LN04 additional functionality to DEC_SHORP and DEC_VERP. * Add error handling to all spacing routines. * * 8-JUL-1988 09:53 mhw * Changes for cp_pbuf from WORD to LONG * * 30-NOV-1988 14:28 araj * Install cfont caching, change calls to compute font into calls to invalidate_font * Make sure references to vai or g_table have a test for the validity of the data * first * * 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 * Changed "gset_map" to "gset_map[0]" for Ultrix port. * * * 12-APR-1989 15:18 araj * unfixed compute_proportional mode, by commenting "if sgr_type != type_family * although if we select by font or by font collection (12/16) proportional * mode should come from there, the departure is too big to introduce without field * test. * * end edit_history * *----------------------------------------------------------- *//* *----------------------------------------------------------- * * begin description * * Filename: caspac.c * * Spacing/increment routines * * This module includes the following routines: * * dec_verp() * dec_shorp() * pr_spi() * pr_shs() * pr_svs() * * end description * *----------------------------------------------------------- *//* Translator edit history for this file * * file: xlc_spacing.c - Translator spacing/increment routines * created: gh 26-MAR-1986 09:10:31 * edit: gh 2-APR-1986 15:51:01 Adding spacing functionality * gh 24-APR-1986 09:19:37 Changed SGR .flag == AF to * .font_file TRUE in compute_proportional_mode * gh 7-MAY-1986 17:05:41 Change svs(), spi(), decverp() * to call compute_vai() and set only xl_st.vsi * gh 15-MAY-1986 14:55:40 Adding compute_font() call * after every compute_proportional_mode() call * gh 27-JUN-1986 17:29:08 Changed DECSHORP to snap .ahp * to nearest higher grid value of new .hai * nv 10-JUL-1986 18:50:31 Completely redesigned decshorp(), * compute_spacing(), compute_proportional_mode(), and * spi() to deal with 'semi-proportional' mode. * Added declaration for average_width_table. * nv 30-JUL-1986 10:03:59 Changed 'shs' to use 'CPI_xx' * literals. * Changed the way the ps_font_number of GL is accessed * on account of the changed declaration of .gl to .gl_ptr. * gh 15-AUG-1986 14:52:40 Changed decverp's call to * scale_vtabs by passing xl_st.vai rather than .vsi * nv 15-OCT-1986 17:49:59 Excluded, by conditional * compilation with respect to * 'FONT_FILE_MODE_IS_MEANINGFUL', a small part of code in * 'compute_proportional_mode'. * nv 17-OCT-1986 10:47:53 In 'spi' removed superfluous * call to 'compute_vai'. * Removed all reference to 'hsi'. */#define caspac (1)/* begin include_file */#include "portab.h" /* For portable definitions of types, etc. */#include "cpsys.hc" /* Parser Global defines */#include "camac.lib_hc" /* macros for action routines */#include "caglobal.hc" /* global defs */#ifdef DUMP#include "xlc_iface.hc" /* defines for oprintf */#include "dumpu.hc" /* Dump Utility */#endif DUMP/* end include_file *//***** compute_spacing() ********************************************** * * * compute_spacing() - Set .hai and proportional spacing flag * * depending on received (/default) values of DECPSM and DECSHORP. * ************************************************************************/VOID compute_spacing (old_hai1, new_hai1)LONG *old_hai1, *new_hai1; { LONG new_hai2; /* 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])); } *old_hai1 = (xl_st.propl_mode == MONO_SPACED_MODE) ? (xl_st.hai) : (FNT_AVERAGE_WIDTH(xl_st.gl_ptr -> gset_map[32].char_font)); /* If PSM is reset, then use the last DECSHORP value received; otherwise, * '0' (refer to PSRM Chapter 7 [on coordinate systems] sec 7.8.1 note 4 * and deviation 6 and sec 7.8.3 deviation 1). */ switch ( (xl_st.psel_mode) ? (0) : (xl_st.shorp) ) { case 0: xl_st.hai = PROPORTIONAL_PITCH; /* semi-prop spacing = 0 */ break; case 1: xl_st.hai = CPI_10; /* 10 cpi = 720 */ break; case 2: xl_st.hai = CPI_12; /* 12 cpi = 600 */ break; case 3: xl_st.hai = CPI_13_2; /* 13.2 cpi = 545 */ break; case 4: xl_st.hai = CPI_16_5; /* 16.5 cpi = 436 */ break; case 5: xl_st.hai = CPI_5; /* 5 cpi = 1440 */ break; case 6: xl_st.hai = CPI_6; /* 6 cpi = 1200 */ break; case 7: xl_st.hai = CPI_6_6; /* 6.6 cpi = 1090 */ break; case 8: xl_st.hai = CPI_8_25; /* 8.25 cpi = 872 */ break; case 9: xl_st.hai = CPI_15; /* 15 cpi = 480 */ break; case 10: xl_st.hai = CPI_12_77; /* 12.77 cpi = 56 */ break; case 11: xl_st.hai = CPI_17_1; /* 17.1 cpi = 421 */ break; case 12: xl_st.hai = CPI_8_55; /* 8.55 cpi = 842 */ break; case 13: xl_st.hai = CPI_18; /* 18 cpi = 400 */ break; case 14: xl_st.hai = CPI_9; /* 9 cpi = 800 */ break; case 15: xl_st.hai = CPI_10_3; /* 10.3 cpi = 696 */ break; default: return; /* invalid value, so return */ } /* * Invalidate the current font selection, as the pitch may have changes * as well as the spacing mode. */ invalidate_font(); /* * Compute the new hai * */ if (xl_st.propl_mode == MONO_SPACED_MODE) { new_hai2 = *new_hai1 = xl_st.hai; } else { compute_font_for_g_set ( xl_st.gl_ptr - (&xl_st.g_table[0])); new_hai2 = *new_hai1 = FNT_AVERAGE_WIDTH(xl_st.gl_ptr -> gset_map[0].char_font); } if (xl_st.propl_mode != PROPORTIONAL_MODE) { /* * 'Snap' current ahp to nearest higher character position under newer * hai value. */ update_ahp (((xl_st.curchar.ap.xval + (new_hai2 - 1)) / new_hai2) * new_hai2, &xl_st.h_lim_bound); } }/***** compute_proportional_mode() ************************************ * * * compute_proportional_mode() - Xl_st.propl_mode flag is SET if: * * DECPSP 'set' received, OR * * SPI with Pn =0 received, OR * * SGR with Ps selecting a font, OR * * DECSHORP with Ps =0 receid. * * * * Xl_st.propl_mode flag is RESET if: * * DECPSP 'reset' received, AND * * SPI with Pn <>0 received, AND * * SGR with Ps selecting a rendition, AND * * DECSHORP with Ps <>0 received. * ************************************************************************/VOID compute_proportional_mode() { /* * See if a condition exists warranting proportional mode. */ if (xl_st.psp/* || SEE EDIT HISTORY 12-APR-1989 15:37 on WHY (xl_st.sgr_tbl [xl_st.cur_sgr].selection_type != SGR_TYPE_FAMILY) */ ) { xl_st.propl_mode = PROPORTIONAL_MODE; } else /* * No conditions matched - whether 'hai' is '0' or not determines that * proportional mode is either semi-proportional or mono-spaced * respectively. */ { xl_st.propl_mode = (xl_st.hai != 0) ? (MONO_SPACED_MODE) : (SEMI_PROPORTIONAL_MODE); } } /***** spi() ********************************************************** * * * spi() - Spacing Pitch Increment allows setting the vertical * * spacing increment (Pv), the horizontal spacing increment (Ph), *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -