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

📄 hints.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/* $XConsortium: hints.c,v 1.4 91/10/10 11:18:13 rws Exp $ *//* Copyright International Business Machines, Corp. 1991 * All Rights Reserved * Copyright Lexmark International, Inc. 1991 * All Rights Reserved * * License to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of IBM or Lexmark not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF * THIS SOFTWARE. */ /* HINTS    CWEB         V0006 ********                             *//*:h1.HINTS Module - Processing Rasterization Hints &author. Sten F. Andler; continuity by Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com) and DuaineW. Pryor, Jr.  :h3.Include Files The included files are:*/ #include "objects.h"#include "spaces.h"#include "paths.h"#include "regions.h"#include "hints.h" /*:h3.Functions Provided to the TYPE1IMAGER User None.*/ /*:h3.Functions Provided to Other Modules This module provides the following entry point to other modules:*/  /*SHARED LINE(S) ORIGINATED HERE*/ /*:h3.Macros Provided to Other Modules None.*/ /*:h2.InitHints() - Initialize hint data structure*/ #define MAXLABEL 20static struct {  int inuse;  int computed;  struct fractpoint hint;} oldHint[MAXLABEL]; #define ODD(x) (((int)(x)) & 01)#define FPFLOOR(fp) TOFRACTPEL((fp) >> FRACTBITS)#define FPROUND(fp) FPFLOOR((fp) + FPHALF) void InitHints(){  int i;   for (i = 0; i < MAXLABEL; i++)    {    oldHint[i].inuse    = FALSE;    oldHint[i].computed = FALSE;    }} /*:h3.CloseHints(hintP) - Reverse hints that are still open*/ void CloseHints(hintP)  struct fractpoint *hintP;{  int i;   for (i = 0; i < MAXLABEL; i++)    {    if (oldHint[i].inuse)      {      hintP->x -= oldHint[i].hint.x;      hintP->y -= oldHint[i].hint.y;       oldHint[i].inuse = FALSE;       IfTrace3((HintDebug > 1),"  Hint %d was open, hint=(%p,%p)\n",                i, hintP->x, hintP->y);      }    }} /*:h3.ComputeHint(hP, currX, currY, hintP) - Compute the value of a hint*/ static void ComputeHint(hP, currX, currY, hintP)  struct hintsegment *hP;  fractpel currX, currY;  struct fractpoint *hintP;{  fractpel currRef, currWidth;  int idealWidth;  fractpel hintValue;  char orientation; /*By construction, width is never zero.  Therefore we can use thewidth value to determine if the hint has been rotated by amultiple of 90 degrees.*/   if (hP->width.y == 0)    {    orientation = 'v';  /* vertical */    IfTrace0((HintDebug > 0),"  vertical hint\n");    }  else if (hP->width.x == 0)    {    orientation = 'h';  /* horizontal */    IfTrace0((HintDebug > 0),"  horizontal hint\n");    }  else    {    IfTrace0((HintDebug > 0),"  hint not vertical or horizontal\n");    hintP->x = hintP->y = 0;    return;    }   /* Compute currRef and currWidth with a unit of 1 pel */  if (orientation == 'v')      /* vertical */    {    currRef = hP->ref.x + currX;    currWidth = ABS(hP->width.x);    }  else if (orientation == 'h') /* horizontal */    {    currRef = hP->ref.y + currY;    currWidth = ABS(hP->width.y);    }  else                             /* error */    {    abort("ComputeHint: invalid orientation");    }   IfTrace4((HintDebug > 1),    "  currX=%p, currY=%p, currRef=%p, currWidth=%p\n",    currX, currY,    currRef, currWidth);   if ((hP->hinttype == 'b')      /* Bar or stem */    || (hP->hinttype == 's'))    /* Serif */    {    idealWidth = NEARESTPEL(currWidth);    if (idealWidth == 0) idealWidth = 1;    if (ODD(idealWidth))         /* Is ideal width odd? */      {      /* center "ref" over pel */      hintValue = FPFLOOR(currRef) + FPHALF - currRef;      }    else      {      /* align "ref" on pel boundary */      hintValue = FPROUND(currRef) - currRef;      }    if (HintDebug > 2) {          IfTrace1(TRUE,"  idealWidth=%d, ", idealWidth);      }    }  else if (hP->hinttype == 'c')  /* Curve extrema */    {    /* align "ref" on pel boundary */    hintValue = FPROUND(currRef) - currRef;    }  else                           /* error */    {    abort("ComputeHint: invalid hinttype");    }   IfTrace1((HintDebug > 1),"  hintValue=%p", hintValue);   if (orientation == 'v')      /* vertical */    {    hintP->x = hintValue;    hintP->y = 0;    }  else if (orientation == 'h') /* horizontal */    {    hintP->x = 0;    hintP->y = hintValue;    }  else                             /* error */    {    abort("ComputeHint: invalid orientation");    }} /*:h3.ProcessHint(hP, currX, currY, hintP) - Process a rasterization hint*/ void ProcessHint(hP, currX, currY, hintP)  struct hintsegment *hP;  fractpel currX, currY;  struct fractpoint *hintP;{  struct fractpoint thisHint;   IfTrace4((HintDebug > 1),"  ref=(%p,%p), width=(%p,%p)",      hP->ref.x, hP->ref.y,      hP->width.x, hP->width.y);  IfTrace4((HintDebug > 1),", %c %c %c %c",      hP->orientation, hP->hinttype,      hP->adjusttype, hP->direction);  IfTrace1((HintDebug > 1),", label=%d\n", hP->label);   if ((hP->adjusttype == 'm')      /* Move */    || (hP->adjusttype == 'a'))    /* Adjust */    {    /* Look up hint in oldHint table */    if ((hP->label >= 0) && (hP->label < MAXLABEL))      {      if (oldHint[hP->label].computed)        /* Use old hint value if already computed */        {        thisHint.x = oldHint[hP->label].hint.x;        thisHint.y = oldHint[hP->label].hint.y;        oldHint[hP->label].inuse    = TRUE;        }      else        /* Compute new value for hint and store it for future use */        {        ComputeHint(hP, currX, currY, &thisHint);         oldHint[hP->label].hint.x = thisHint.x;        oldHint[hP->label].hint.y = thisHint.y;        oldHint[hP->label].inuse    = TRUE;        oldHint[hP->label].computed = TRUE;        }      }    else                             /* error */      {      abort("ProcessHint: invalid label");      }    }  else if (hP->adjusttype == 'r')  /* Reverse */    {    /* Use the inverse of the existing hint value to reverse hint */    if ((hP->label >= 0) && (hP->label < MAXLABEL))      {      if (oldHint[hP->label].inuse)        {        thisHint.x = -oldHint[hP->label].hint.x;        thisHint.y = -oldHint[hP->label].hint.y;        oldHint[hP->label].inuse = FALSE;        }      else                           /* error */        {        abort("ProcessHint: label is not in use");        }      }    else                           /* error */      {      abort("ProcessHint: invalid label");      }     }  else                           /* error */    {    abort("ProcessHint: invalid adjusttype");    }  IfTrace3((HintDebug > 1),"  label=%d, thisHint=(%p,%p)\n",    hP->label, thisHint.x, thisHint.y);   hintP->x += thisHint.x;  hintP->y += thisHint.y;   IfTrace2((HintDebug > 1),"  hint=(%p,%p)\n",    hintP->x, hintP->y);} 

⌨️ 快捷键说明

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