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

📄 set_trns.c

📁 unix vnc 协议源码. VNC是一款远程控制工具软件.
💻 C
📖 第 1 页 / 共 3 页
字号:
    out_on_bottom = FALSE;/* * don't need Y squeezing if: *     - Y squeezing not enabled *     - bbox doesn't violate on top or bottom *     - top squeezing only is enabled and char isn't out on top *     - bottom squeezing only is enabled and char isn't out on bottom */if ((!squeeze_top && !squeeze_bottom) ||     (!out_on_top && !out_on_bottom) ||    (squeeze_top && !squeeze_bottom && !out_on_top) ||     (squeeze_bottom && !squeeze_top && !out_on_bottom))     return FALSE;if (squeeze_top && (bbox_top > EM_TOP))    *top_scale = ((fix31)EM_TOP << 16)/(fix31)(bbox_top);else    *top_scale = 0x10000L;  /* 1 in 16.16 fixed point */if (squeeze_bottom && (bbox_bottom < EM_BOT))    *bottom_scale = ((fix31)-(EM_BOT) << 16)/(fix31)-bbox_bottom;else    *bottom_scale = 0x10000L;if (sp_globals.squeezing_compound)    {    for (i=first_Y_zone; i < (first_Y_zone + no_Y_ctrl_zones + 1); i++)        {        if (sp_plaid.orus[i] >= 0)            sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *top_scale)                              +sp_globals.pixrnd) & sp_globals.pixfix;        else            sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *bottom_scale)                              +sp_globals.pixrnd) & sp_globals.pixfix;        }    }return TRUE;}#endif#if INCL_RULESFUNCTION static ufix8 FONTFAR *sp_setup_pix_table(    pointer, short_form, no_X_ctrl_zones, no_Y_ctrl_zones)GDECLufix8 FONTFAR *pointer;   /* Pointer to first byte in control zone table */boolean short_form; /* TRUE if 1 byte from/to specification */fix15   no_X_ctrl_zones; /* Number of X control zones */fix15   no_Y_ctrl_zones; /* Number of Y control zones *//* * Called by plaid_tcb() to read the control zone table from the * character data in the font. * Sets up a table of pixel values for all controlled coordinates.  * Updates the pointer to the byte following the control zone * data. */{fix15    i, j, n;fix31    ppo;  fix31    xppo0; /* top level pixels per oru */fix31    yppo0; /* top level pixels per oru */ufix8    edge_org;ufix8    edge;ufix8    start_edge;ufix8    end_edge;ufix16   constr_org;fix15    constr_nr;fix15    zone_pix;fix31    whole_zone; /* non-transformed value of the first X zone */ufix16   tmpufix16;  /* in extended mode, macro uses secnd term */#if INCL_SQUEEZINGfix31    x_scale;fix31	 y_top_scale, y_bottom_scale;fix31    x_offset;boolean  squeezed_y;fix15    setwidth_pix, em_top_pix, em_bot_pix;#endif#if INCL_ISWboolean  imported_width;fix31	 isw_scale;fix15    isw_setwidth_pix;#endif#if INCL_ISW || INCL_SQUEEZINGboolean squeezed_x;#endif#if INCL_PLAID_OUT               /* Plaid data monitoring included? */begin_ctrl_zones(no_X_ctrl_zones, no_Y_ctrl_zones);#endif                                                    edge_org = 0;constr_org = 0;sp_globals.rnd_xmin = 0;  /* initialize the error for chars with no zone */n = no_X_ctrl_zones;ppo = sp_globals.tcb.xppo;xppo0 = sp_globals.tcb0.xppo;yppo0 = sp_globals.tcb0.yppo;#if INCL_SQUEEZING || INCL_ISWsqueezed_x = FALSE;#endif#if INCL_SQUEEZINGsqueezed_x = calculate_x_scale (&x_scale, &x_offset, no_X_ctrl_zones);squeezed_y = calculate_y_scale(&y_top_scale,&y_bottom_scale,(n+1),	     no_Y_ctrl_zones);#if INCL_ISWif (sp_globals.import_setwidth_act == TRUE)setwidth_pix = ((fix15)(((fix31)sp_globals.imported_width * xppo0) >> 	     sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;else#endifsetwidth_pix = ((fix15)(((fix31)sp_globals.setwidth_orus * xppo0) >> 	     sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;/* check for overflow */if (setwidth_pix < 0)	setwidth_pix = 0x7fff; /* set to maximum */em_bot_pix = ((fix15)(((fix31)EM_BOT * yppo0) >> 	     sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;em_top_pix = ((fix15)(((fix31)EM_TOP * yppo0) >> 	     sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;#endif#if INCL_ISW/* convert to pixels */isw_setwidth_pix = ((fix15)(((fix31)sp_globals.imported_width * xppo0) >> 	     sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;/* check for overflow */if (isw_setwidth_pix < 0)	isw_setwidth_pix = 0x7fff; /* set to maximum */if (!squeezed_x && ((imported_width = sp_globals.import_setwidth_act) == TRUE))    {    isw_scale = compute_isw_scale();    /* look for the first non-negative oru value, scale and add the offset    */    /* to the corresponding pixel value - note that the pixel value           */    /* is set in read_oru_table.                                              */        /* look at all the X edges */        for (i=0; i < (no_X_ctrl_zones+1); i++)        if (sp_plaid.orus[i] >= 0)           {           sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], isw_scale)                  +sp_globals.pixrnd) & sp_globals.pixfix;           break;           }    }#endiffor (i = 0; ; i++)               /* For X and Y control zones... */    {    for (j = 0; j < n; j++)      /* For each zone in X or Y... */        {        if (short_form)          /* 1 byte from/to specification? */            {            edge = NEXT_BYTE(pointer); /* Read packed from/to spec */            start_edge = edge_org + (edge & 0x0f); /* Extract start edge */            end_edge = edge_org + (edge >> 4); /* Extract end edge */            }        else                     /* 2 byte from/to specification? */            {            start_edge = edge_org + NEXT_BYTE(pointer); /* Read start edge */            end_edge = edge_org + NEXT_BYTE(pointer); /* read end edge */            }        constr_nr = constr_org +            NEXT_BYTES(pointer, tmpufix16); /* Read constraint number */ #if INCL_SQUEEZING        if (i == 0 && squeezed_x)	    calculate_x_pix(start_edge, end_edge, constr_nr,                            x_scale, x_offset, ppo, setwidth_pix);	else if (i == 1 && squeezed_y)	    calculate_y_pix(start_edge, end_edge,constr_nr, 		y_top_scale, y_bottom_scale, ppo, em_top_pix, em_bot_pix);	else	{#endif#if INCL_ISW	if (i==0 && imported_width)            calculate_x_pix(start_edge, end_edge, constr_nr,                            isw_scale, 0,  ppo, isw_setwidth_pix);	else	{#endif        if (!sp_globals.c_act[constr_nr])   /* Constraint inactive? */            {            zone_pix = ((fix15)((((fix31)sp_plaid.orus[end_edge] -			(fix31)sp_plaid.orus[start_edge]) * ppo) /			(1<<sp_globals.mpshift)) + sp_globals.pixrnd) &			sp_globals.pixfix;            if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])                goto L1;            }        zone_pix = sp_globals.c_pix[constr_nr]; /* Use zone size from constr table */        if (start_edge > end_edge) /* sp_plaid.orus[start_edge] > sp_plaid.orus[end_edge]? */            {            zone_pix = -zone_pix; /* Use negatve zone size */            }    L1:                        /* inter-character spacing fix */        if ((j == 0) && (i == 0))      /* if this is the 1st X zone, save rounding error */            {                          /*  get the non-xformed - xformed zone, in right direction */            whole_zone = (((fix31)sp_plaid.orus[end_edge] -			(fix31)sp_plaid.orus[start_edge]) *			ppo) / (1<<sp_globals.mpshift);            sp_globals.rnd_xmin = whole_zone - zone_pix;            }        sp_plaid.pix[end_edge] = sp_plaid.pix[start_edge] + zone_pix; /* Insert end pixels */#if INCL_SQUEEZING        if (i == 0)  /* in the x direction */            { /* brute force squeeze */            if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) &&                 (sp_plaid.pix[end_edge] < 0))                sp_plaid.pix[end_edge] = 0;            if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) &&                 (sp_plaid.pix[end_edge] > setwidth_pix))                sp_plaid.pix[end_edge] = setwidth_pix;            }        if (i == 1) /* in the y direction */            {  /* brute force squeeze */            if ((sp_globals.pspecs->flags & SQUEEZE_TOP) &&                 (sp_plaid.pix[end_edge] > em_top_pix))                sp_plaid.pix[end_edge] = em_top_pix;            if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) &&                (sp_plaid.pix[end_edge] < em_bot_pix))                sp_plaid.pix[end_edge] = em_bot_pix;            }#endif#if INCL_SQUEEZING	}#endif#if INCL_ISW	}#endif#if INCL_PLAID_OUT               /* Plaid data monitoring included? */        record_ctrl_zone(            (fix31)sp_plaid.pix[start_edge] << (16 - sp_globals.pixshift),             (fix31)sp_plaid.pix[end_edge] << (16 - sp_globals.pixshift),             (fix15)(constr_nr - constr_org));#endif        }    if (i)                       /* Y pixels done? */        break;                                              edge_org = sp_globals.Y_edge_org;       /* Prepare to process Y ctrl zones */    constr_org = sp_globals.Y_constr_org;    n = no_Y_ctrl_zones;                          ppo = sp_globals.tcb.yppo;                                }#if DEBUGprintf("\nX PIX TABLE\n");n = no_X_ctrl_zones + 1;for (i = 0; i < n; i++)    printf("%2d %6.1f\n", i, (real)sp_plaid.pix[i] / (real)sp_globals.onepix);printf("\nY PIX TABLE\n");n = no_Y_ctrl_zones + 1;for (i = 0; i < n; i++)    {    j = i + no_X_ctrl_zones + 1;    printf("%2d %6.1f\n", i, (real)sp_plaid.pix[j] / (real)sp_globals.onepix);    }#endifreturn pointer;}#endif#if INCL_RULESFUNCTION static ufix8 FONTFAR *sp_setup_int_table(pointer, no_X_int_zones, no_Y_int_zones)GDECLufix8 FONTFAR *pointer;   /* Pointer to first byte in interpolation zone table */fix15  no_X_int_zones; /* Number of X interpolation zones */fix15  no_Y_int_zones; /* Number of X interpolation zones *//* * Called by plaid_tcb() to read the interpolation zone table from the * character data in the font.  * Sets up a table of interpolation coefficients with one entry for * every X or Y interpolation zone. * Updates the pointer to the byte following the interpolation zone * data. */{fix15    i, j, k, l, n;ufix8    format;ufix8    format_copy;ufix8    tmpufix8;fix15    start_orus;ufix8    edge_org;ufix8    edge;ufix16   adj_factor;fix15    adj_orus;fix15    end_orus;fix31    zone_orus;fix15    start_pix;fix15    end_pix;#if INCL_PLAID_OUT               /* Plaid data monitoring included? */begin_int_zones(no_X_int_zones, no_Y_int_zones);#endifi = 0;edge_org = 0;n = no_X_int_zones;for (j = 0; ; j++)    {    for (k = 0; k < n; k++)        {        format = NEXT_BYTE(pointer);        if (format & BIT7)       /* Short start/end point spec? */            {            tmpufix8 = NEXT_BYTE(pointer);            edge = edge_org + (tmpufix8 & 0xf);            start_orus = sp_plaid.orus[edge];            start_pix = sp_plaid.pix[edge];            edge = edge_org + (tmpufix8 >> 4);            end_orus = sp_plaid.orus[edge];            end_pix = sp_plaid.pix[edge];            }        else                     /* Standard start and end point spec? */            {            format_copy = format;            for (l = 0; ; l++)   /* Loop for start and end point */                {                switch (format_copy & 0x7) /* Decode start/end point format */                    {                case 0:          /* Index to control edge */                    edge = edge_org + NEXT_BYTE(pointer);                    end_orus = sp_plaid.orus[edge];                    end_pix = sp_plaid.pix[edge];                    break;                case 1:          /* 1 byte fractional distance to next edge */                    adj_factor =  0xffff & NEXT_BYTE(pointer) << 8;                    goto L1;                case 2:          /* 2 byte fractional distance to next edge */		    adj_factor = 0xffff & NEXT_WORD(pointer);                L1: edge = edge_org + NEXT_BYTE(pointer);                    end_orus = sp_plaid.orus[edge] +                        ((((fix31)sp_plaid.orus[edge + 1] - (fix31)sp_plaid.orus[edge]) *                         (ufix32)adj_factor + (fix31)32768) >> 16);                    end_pix = sp_plaid.pix[edge] +                        ((((fix31)sp_plaid.pix[edge + 1] - (fix31)sp_plaid.pix[edge]) *                         (ufix32)adj_factor + (fix31)32768) >> 16);                    break;                case 3:          /* 1 byte delta orus before first edge */                    adj_orus = -(fix15)NEXT_BYTE(pointer);                     goto L2;                case 4:          /* 2 byte delta orus before first edge */                    adj_orus = -NEXT_WORD(pointer);                L2: edge = edge_org;                    goto L4;                case 5:          /* 1 byte delta orus after last edge */                    adj_orus = (fix15)NEXT_BYTE(pointer);                    goto L3;                case 6:          /* 2 byte delta orus after last edge */                    adj_orus = NEXT_WORD(pointer);                L3: edge = j? sp_globals.Y_edge_org + sp_globals.no_Y_orus - 1: sp_globals.no_X_orus - 1;                L4: end_orus = sp_plaid.orus[edge] + adj_orus;                    end_pix = sp_plaid.pix[edge] +                         (((fix31)adj_orus * (fix31)(j? sp_globals.tcb.yppo: sp_globals.tcb.xppo) +                           sp_globals.mprnd) / (1<<sp_globals.mpshift));                    break;                    }                if (l)           /* Second time round loop? */                    break;                format_copy >>= 3; /* Adj format to decode end point format */                start_orus = end_orus; /* Save start point oru value */                start_pix = end_pix; /* Save start point pixel value */                }            }#if INCL_PLAID_OUT               /* Plaid data monitoring included? */        record_int_zone(            (fix31)start_pix << (16 - sp_globals.pixshift),             (fix31)end_pix << (16 - sp_globals.pixshift));#endif        zone_orus = (fix31)end_orus - (fix31)start_orus;        sp_plaid.mult[i] = ((((fix31)end_pix - (fix31)start_pix) << sp_globals.mpshift) +                    (zone_orus / 2)) / zone_orus;        sp_plaid.offset[i] =             (((((fix31)start_pix + (fix31)end_pix) << sp_globals.mpshift) -               ((fix31)sp_plaid.mult[i] * ((fix31)start_orus + (fix31)end_orus))) / 2) +             sp_globals.mprnd;        i++;        }    if (j)                       /* Finished? */        break;    edge_org = sp_globals.Y_edge_org;       /* Prepare to process Y ctrl zones */    n = no_Y_int_zones;    }#if DEBUGprintf("\nX INT TABLE\n");n = no_X_int_zones;for (i = 0; i < n; i++)    {    printf("%2d %7.4f %7.4f\n", i,         (real)sp_plaid.mult[i] / (real)(1 << sp_globals.multshift),         (real)sp_plaid.offset[i] / (real)(1 << sp_globals.multshift));    }printf("\nY INT TABLE\n");n = no_Y_int_zones;for (i = 0; i < n; i++)    {    j = i + no_X_int_zones;    printf("%2d %7.4f %7.4f\n", i,         (real)sp_plaid.mult[j] / (real)(1 << sp_globals.multshift),         (real)sp_plaid.offset[j] / (real)(1 << sp_globals.multshift));    }#endifreturn pointer;}#endif#if INCL_ISWFUNCTION fix31 compute_isw_scale()GDECL{fix31 isw_scale;	if (sp_globals.setwidth_orus == 0)    isw_scale = 0x00010000;else    isw_scale = ((fix31)sp_globals.imported_width << 16)/                 (fix31)sp_globals.setwidth_orus;return isw_scale;}#endif

⌨️ 快捷键说明

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