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

📄 set_spcs.c

📁 unix vnc 协议源码. VNC是一款远程控制工具软件.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $XConsortium: set_spcs.c,v 1.6 94/02/10 10:18:23 gildea Exp $ *//*Copyright 1989-1991, Bitstream Inc., Cambridge, MA.You are hereby granted permission under all Bitstream propriety rights touse, copy, modify, sublicense, sell, and redistribute the Bitstream Speedosoftware and the Bitstream Charter outline font for any purpose and withoutrestrictions; provided, that this notice is left intact on all copies of suchsoftware or font and that Bitstream's trademark is acknowledged as shown belowon all unmodified copies of such font.BITSTREAM CHARTER is a registered trademark of Bitstream Inc.BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDINGWITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR APARTICULAR PURPOSE.  BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECTDAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHERINCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTEDWITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.*//*************************** S E T _ S P C S . C ***************************** *                                                                           * * This module implements all sp_set_specs() functionality.                  * *                                                                           * ****************************************************************************/#define SET_SPCS#include "spdo_prv.h"               /* General definitions for Speedo    */#include "keys.h"#define   DEBUG      0#if DEBUG#include <stdio.h>#define SHOW(X) printf("X = %d\n", X)#else#define SHOW(X)#endif/***** GLOBAL VARIABLES *****//***** GLOBAL FUNCTIONS *****//****** EXTERNAL VARIABLES *****//***** STATIC VARIABLES *****//****** STATIC FUNCTIONS *****/#if PROTOS_AVAILstatic boolean sp_setup_consts(PROTO_DECL2 fix15 xmin, fix15 xmax,	fix15 ymin, fix15 ymax);static void sp_setup_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb);static fix15 sp_setup_mult(PROTO_DECL2 fix31 input_mult);static fix31 sp_setup_offset(PROTO_DECL2 fix31 input_offset);#elsestatic void    sp_setup_tcb();      /* Set up transformation control block */static fix15 sp_setup_mult();       /* Convert mult to internal form */static fix31 sp_setup_offset();     /* Convert offset to internal form */static boolean sp_setup_consts();   /* Set up scaling constants */#endifFUNCTION boolean set_specs(specsarg)GDECLspecs_t STACKFAR *specsarg;     /* Bundle of conversion specifications *//*  * Called by host software to set character generation specifications */{ufix8 FONTFAR  *pointer;       /* Pointer to font data */fix31   offcd;         /* Offset to start of character directory */fix31   ofcns;         /* Offset to start of constraint data */ fix31   cd_size;       /* Size of character directory */fix31   no_bytes_min;  /* Min number of bytes in font buffer */ufix16  font_id;       /* Font ID */ufix16  private_off;   /* offset to private header */fix15   xmin;          /* Minimum X ORU value in font */fix15   xmax;          /* Maximum X ORU value in font */fix15   ymin;          /* Minimum Y ORU value in font */fix15   ymax;          /* Maximum Y ORU value in font */sp_globals.specs_valid = FALSE;           /* Flag specs not valid */sp_globals.specs = *specsarg;   /* copy specs structure into sp_globals */sp_globals.pspecs = &sp_globals.specs;sp_globals.font = *sp_globals.pspecs->pfont;sp_globals.pfont = &sp_globals.font;sp_globals.font_org = sp_globals.font.org;if (read_word_u(sp_globals.font_org + FH_FMVER + 4) != 0x0d0a)    {    report_error(4);           /* Font format error */    return FALSE;    }if (read_word_u(sp_globals.font_org + FH_FMVER + 6) != 0x0000)    {    report_error(4);           /* Font format error */    return FALSE;    }if (get_cust_no(*specsarg->pfont) == 0)	{	sp_globals.key32 = 0;	sp_globals.key4 = 0;	sp_globals.key6 = 0;	sp_globals.key7 = 0;	sp_globals.key8 = 0;	}else	{	sp_globals.key32 = (KEY3 << 8) | KEY2;	sp_globals.key4 = KEY4;	sp_globals.key6 = KEY6;	sp_globals.key7 = KEY7;	sp_globals.key8 = KEY8;	}	sp_globals.no_chars_avail = read_word_u(sp_globals.font_org + FH_NCHRF);/* Read sp_globals.orus per em from font header */sp_globals.orus_per_em = read_word_u(sp_globals.font_org + FH_ORUPM);/* compute address of private header */private_off = read_word_u(sp_globals.font_org + FH_HEDSZ);sp_globals.hdr2_org = sp_globals.font_org + private_off;/* set metric resolution if specified, default to outline res otherwise */if (private_off > EXP_FH_METRES)	{	sp_globals.metric_resolution = read_word_u(sp_globals.font_org + EXP_FH_METRES);	}else	{	sp_globals.metric_resolution = sp_globals.orus_per_em;	}#if INCL_METRICSsp_globals.kern.tkorg = sp_globals.font_org + read_long(sp_globals.hdr2_org + FH_OFFTK);sp_globals.kern.pkorg = sp_globals.font_org + read_long(sp_globals.hdr2_org + FH_OFFPK); sp_globals.kern.no_tracks = read_word_u(sp_globals.font_org + FH_NKTKS);sp_globals.kern.no_pairs = read_word_u(sp_globals.font_org + FH_NKPRS);#endifoffcd = read_long(sp_globals.hdr2_org + FH_OFFCD); /* Read offset to character directory */ofcns = read_long(sp_globals.hdr2_org + FH_OFCNS); /* Read offset to constraint data */cd_size = ofcns - offcd;if ((((sp_globals.no_chars_avail << 1) + 3) != cd_size) &&    (((sp_globals.no_chars_avail * 3) + 4) != cd_size))    {    report_error(4);           /* Font format error */    return FALSE;    }#if INCL_LCD                   /* Dynamic character data load suppoorted? */#if INCL_METRICSno_bytes_min = read_long(sp_globals.hdr2_org + FH_OCHRD); /* Offset to character data */#else                          /* Dynamic character data load not supported? */no_bytes_min = read_long(sp_globals.hdr2_org + FH_OFFTK); /* Offset to track kerning data */#endif#else                          /* Dynamic character data load not supported? */no_bytes_min = read_long(sp_globals.hdr2_org + FH_NBYTE); /* Offset to EOF + 1 */#endifsp_globals.font_buff_size = sp_globals.pfont->no_bytes;if (sp_globals.font_buff_size < no_bytes_min)  /* Minimum data not loaded? */    {    report_error(1);           /* Insufficient font data loaded */    return FALSE;    }sp_globals.pchar_dir = sp_globals.font_org + offcd;sp_globals.first_char_idx = read_word_u(sp_globals.font_org + FH_FCHRF);/* Register font name with sp_globals.constraint mechanism */#if INCL_RULESfont_id = read_word_u(sp_globals.font_org + FH_FNTID);if (!(sp_globals.constr.font_id_valid) || (sp_globals.constr.font_id != font_id))    {    sp_globals.constr.font_id = font_id;    sp_globals.constr.font_id_valid = TRUE;    sp_globals.constr.data_valid = FALSE;    }sp_globals.constr.org = sp_globals.font_org + ofcns;sp_globals.constr.active = ((sp_globals.pspecs->flags & CONSTR_OFF) == 0);#endif/* Set up sliding point constants *//* Set pixel shift to accomodate largest transformed pixel value */xmin = read_word_u(sp_globals.font_org + FH_FXMIN);xmax = read_word_u(sp_globals.font_org + FH_FXMAX);ymin = read_word_u(sp_globals.font_org + FH_FYMIN);ymax = read_word_u(sp_globals.font_org + FH_FYMAX);if (!sp_setup_consts(xmin,xmax,ymin,ymax))    {    report_error(3);           /* Requested specs out of range */    return FALSE;    }#if INCL_ISW/* save the value of the max x oru that the fixed point constants are based on*/sp_globals.isw_xmax = xmax; #endif/* Setup transformation control block */sp_setup_tcb(&sp_globals.tcb0);/* Select output module */sp_globals.output_mode = sp_globals.pspecs->flags & 0x0007;#if INCL_USEROUTif (!init_userout(sp_globals.pspecs))#endifswitch (sp_globals.output_mode)    {#if INCL_BLACKcase MODE_BLACK:                        /* Output mode 0 (Black writer) */	sp_globals.init_out = sp_init_black;    sp_globals.begin_char		= sp_begin_char_black;    sp_globals.begin_sub_char	= sp_begin_sub_char_out;   	sp_globals.begin_contour	= sp_begin_contour_black;    sp_globals.curve			= sp_curve_out;   	sp_globals.line			= sp_line_black;    sp_globals.end_contour		= sp_end_contour_out;   	sp_globals.end_sub_char	= sp_end_sub_char_out;    sp_globals.end_char		= sp_end_char_black;    break;#endif#if INCL_SCREENcase MODE_SCREEN:                        /* Output mode 1 (Screen writer) */	sp_globals.init_out = sp_init_screen;    sp_globals.begin_char		= sp_begin_char_screen;    sp_globals.begin_sub_char	= sp_begin_sub_char_out;   	sp_globals.begin_contour	= sp_begin_contour_screen;    sp_globals.curve			= sp_curve_screen;   	sp_globals.line			= sp_line_screen;    sp_globals.end_contour		= sp_end_contour_screen;   	sp_globals.end_sub_char	= sp_end_sub_char_out;    sp_globals.end_char		= sp_end_char_screen;	break;#endif#if INCL_OUTLINEcase MODE_OUTLINE:                        /* Output mode 2 (Vector) */	sp_globals.init_out = sp_init_outline;    sp_globals.begin_char		= sp_begin_char_outline;    sp_globals.begin_sub_char	= sp_begin_sub_char_outline;   	sp_globals.begin_contour	= sp_begin_contour_outline;    sp_globals.curve			= sp_curve_outline;   	sp_globals.line			= sp_line_outline;    sp_globals.end_contour		= sp_end_contour_outline;   	sp_globals.end_sub_char	= sp_end_sub_char_outline;    sp_globals.end_char		= sp_end_char_outline;	break;#endif#if INCL_2Dcase MODE_2D:                        /* Output mode 3 */	sp_globals.init_out = sp_init_2d;    sp_globals.begin_char		= sp_begin_char_2d;    sp_globals.begin_sub_char	= sp_begin_sub_char_out;   	sp_globals.begin_contour	= sp_begin_contour_2d;    sp_globals.curve			= sp_curve_out;   	sp_globals.line			= sp_line_2d;    sp_globals.end_contour		= sp_end_contour_out;   	sp_globals.end_sub_char	= sp_end_sub_char_out;    sp_globals.end_char		= sp_end_char_2d;    break;#endifdefault:    report_error(8);           /* Unsupported mode requested */    return FALSE;    }	if (!fn_init_out(sp_globals.pspecs))		{		report_error(5);		return FALSE;		}		sp_globals.curves_out = sp_globals.pspecs->flags & CURVES_OUT;if (sp_globals.pspecs->flags & BOGUS_MODE) /* Linear transformation requested? */    {    sp_globals.tcb0.xtype = sp_globals.tcb0.ytype = 4;    }else                           /* Intelligent transformation requested? */    {#if INCL_RULES#else    report_error(7);           /* Rules requested; not supported */    return FALSE;#endif    }if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) ||    (sp_globals.pspecs->flags & SQUEEZE_RIGHT) ||    (sp_globals.pspecs->flags & SQUEEZE_TOP) ||    (sp_globals.pspecs->flags & SQUEEZE_BOTTOM) )    {#if (INCL_SQUEEZING)#else     report_error(11);     return FALSE;#endif    }if ((sp_globals.pspecs->flags & CLIP_LEFT) ||    (sp_globals.pspecs->flags & CLIP_RIGHT) ||    (sp_globals.pspecs->flags & CLIP_TOP) ||    (sp_globals.pspecs->flags & CLIP_BOTTOM) )    {#if (INCL_CLIPPING)#else     report_error(11);     return FALSE;#endif    }sp_globals.specs_valid = TRUE;return TRUE;}#if INCL_MULTIDEV#if INCL_BLACK || INCL_SCREEN || INCL_2DFUNCTION boolean set_bitmap_device(bfuncs,size)GDECLbitmap_t *bfuncs;ufix16 size;{if (size != sizeof(sp_globals.bitmap_device))	return FALSE;sp_globals.bitmap_device = *bfuncs;sp_globals.bitmap_device_set = TRUE;}#endif#if INCL_OUTLINEFUNCTION boolean set_outline_device(ofuncs,size)GDECLoutline_t *ofuncs;ufix16 size;{if (size != sizeof(sp_globals.outline_device))	return FALSE;sp_globals.outline_device = *ofuncs;sp_globals.outline_device_set = TRUE;}#endif#endif#ifdef oldFUNCTION boolean sp_setup_consts(xmin, xmax, ymin, ymax)#elsestatic FUNCTION boolean sp_setup_consts(xmin, xmax, ymin, ymax)#endifGDECLfix15   xmin;          /* Minimum X ORU value in font */fix15   xmax;          /* Maximum X ORU value in font */fix15   ymin;          /* Minimum Y ORU value in font */fix15   ymax;          /* Maximum Y ORU value in font *//* * Sets the following constants used for fixed point arithmetic: *      sp_globals.multshift    multipliers and products; range is 14 to 8 *      sp_globals.pixshift     pixels: range is 0 to 8 *      sp_globals.mpshift      shift from product to sub-pixels (sp_globals.multshift - sp_globals.pixshift) *      sp_globals.multrnd      rounding for products

⌨️ 快捷键说明

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