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

📄 strk0.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*                                                                       */
/*         Copyright (c) 1997 - 1999 Accelerated Technology, Inc.        */
/*                                                                       */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      */
/* subject matter of this material.  All manufacturing, reproduction,    */
/* use, and sales rights pertaining to this subject matter are governed  */
/* by the license agreement.  The recipient of this software implicitly  */
/* accepts the terms of the license.                                     */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                            VERSION          */
/*                                                                       */
/*      STRK0.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the mwStrokeText, ScaleNode and ScalePath     */
/* functions.                                                            */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Giac Dinh, Accelerated Technology, Inc.                          */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*         BobB           7/1/98     Changed 2 byte structures for       */
/* addressing problems in PPC and ARM.                                   */
/*         BobB           1/6/99     Corrected slant angle sign          */
/*         GiacD          2/8/99     Added fixed point math support      */
/*                                                                       */
/*************************************************************************/

#include "meta_wnd.h"
#include "metconst.h"    /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h"    /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
#include "metfonts.h"
//#include "Nu_math.h"

 
/* Function mwStrokeText draws characters from the specified text string, TEXT, 
   beginning at "INDEX" characters from the start of the string, and continuing  
   for "COUNT" characters or until a null (x'00') character is encountered 
   (which ever occurs first).  The text is draw beginning at the current pen 
   location and ends up at the start of the next character position past the 
   last character drawn.

   Known Bugs:
   Ignores charsize argument and always processes array of bytes.
   Doesn't use badChar for missing characters, uses last char in font.  */

void mwStrokeText(char *TEXT, int INDEX, int COUNT,int CHARSIZE)
{
void ScaleNode(short nodeX, short nodeY, point *scaledNode);
void ScalePath(short nodeX, short nodeY, point *scaledPath);
	
	typedef struct _nodePt{
		signed char X;
		signed char Y;
	} nodePt;

	char *adsText	;	/*pointer to current TEXT character*/
	long adsLocTbl  ;	/*pointer to location table*/
	word *locTblPtr	;
	long adsOfWdTbl ;	/*pointer to offset/width table*/
	long adsNodeTbl ;	/*pointer to nodes table*/
	nodePt *chNodeTbl ;	/*this chars node pointer*/
	int  txTrm	;		/*termination char*/
	int  chIndex;		/*character index*/
	char aCH	;	 	/*character code*/
	signed char mov_draw   ;	/*node operation*/
	point fxWid    ;	/*scaled fixed width*/
	point txExt    ;	/*scaled text extra*/
	point txSpc    ;	/*scaled space extra*/
	point wd;
	short vAlign	;	/*vertical alignment*/
	short baseX, baseY, lastX, lastY ;
	short chCtrX, chCtrY ;	/*node center*/
	point temp;
	nodePt temNode;
	fontRcd *Font;
	ofswid *stOfWdTbl;
	void (*lineExecPntr)();

	lineExecPntr = (void (*)()) lineExecIDV;
	grafBlit.blitRop = grafPort.txMode;
	Font = (fontRcd *) grafPort.txFont;
	lastX = 0;
	lastY = 0;

/* Get pointer to users text string  */
	adsText = TEXT + INDEX;

/* compute pointer to location table  */
	adsLocTbl = (long) Font + Font->locTbl;

/* compute pointer to offset/width table  */
	adsOfWdTbl = (long) Font + Font->ofwdTbl;

/* compute pointer to node table  */
	adsNodeTbl = (long) Font + Font->fontTbl;
 
	chCtrX = Font->chCenter.X;
	chCtrY = Font->chCenter.Y;

/* compute vertical alignment (char origins are at LOWER left)
   precomputed fntVertAlign is at UPPER left  */
	vAlign = -((Font->chHeight - 1) - fntVertAln);

/* Scale fixed space size  */
	ScalePath(Font->fxSpac, 0, &fxWid);

/* Scale text extra size  */
	ScalePath(grafPort.txExtra, 0, &txExt);

/* Scale text space size  */
	ScalePath(grafPort.txSpace, 0, &txSpc);

/* Get termination character  */
	txTrm = grafPort.txTerm;

	while (COUNT-- > 0)	/* For each character in the string  */
	{
		aCH = *adsText++;
		if(aCH == txTrm) break;
		if((aCH < Font->minChar) || (aCH > Font->maxChar))
		{	/*  handle char out of range.
		Note: stroked fonts don't support the chBad field.
		The bad character for stroked fonts is always the
		character one beyond the maxChar.  */
			aCH = Font->maxChar + 1;
		}

	/* Compute index in font for this character  */
		chIndex = aCH - Font->minChar;
		stOfWdTbl = ((ofswid *) (adsOfWdTbl + (chIndex << 1)));
		if ((stOfWdTbl->wid == 0xFF) && (stOfWdTbl->ofs == -1))
			chIndex = Font->maxChar - Font->minChar + 1;

		locTblPtr = (word *) adsLocTbl + chIndex;
		chNodeTbl = (nodePt *) (adsNodeTbl + *locTblPtr);

	/* Scale offset and vertical alignment  */
		ScaleNode(stOfWdTbl->ofs, vAlign, &temp); 
		if(grafPort.txFace & faceMirrorX) temp.X = - temp.X; 
		if(!(grafPort.txFace & faceMirrorY)) temp.Y = - temp.Y;

		baseX = LocX + temp.X;
		baseY = LocY + temp.Y;
		
		mov_draw = 0;

	/* Advance to the next Node  */
		while (1)
		{
/* BobB 7/1/98 - change the following line for the ARM710 processor 
			temNode = *chNodeTbl++;*/
			temNode = *chNodeTbl;
			chNodeTbl = (nodePt *) ((long) chNodeTbl + 2);
			if(temNode.X == -1)
			{	/* Control node */
				if(temNode.Y == -2)
				{	/* advance to next node */
					mov_draw = 0;
					continue;
				}
				if(temNode.Y == -3)
				{	/* Handle filled rectangle control node  */
					temp.X = chNodeTbl->X - chCtrX;
					temp.Y = chNodeTbl->Y - chCtrY;
					ScaleNode(temp.X, temp.Y, &temp);
					grafBlist.Xmin = temp.X;
					grafBlist.Ymin = temp.Y;
/* BobB 7/1/98 - change the following line for the ARM710 processor 
					chNodeTbl++; */
					chNodeTbl = (nodePt *) ((long) chNodeTbl + 2);

					temp.X = chNodeTbl->X - chCtrX;
					temp.Y = chNodeTbl->Y - chCtrY;
					ScaleNode(temp.X, temp.Y, &temp);
					grafBlist.Xmax = temp.X;
					grafBlist.Ymax = temp.Y;
/* BobB 7/1/98 - change the following line for the ARM710 processor 
					chNodeTbl++; */
					chNodeTbl = (nodePt *) ((long) chNodeTbl + 2);

					if(grafPort.txFace & faceMirrorX)
					{
						grafBlist.Xmin = - grafBlist.Xmin;
						grafBlist.Xmax = - grafBlist.Xmax;
					}
				/* Factor in pen location   */
					grafBlist.Xmin += baseX;
					grafBlist.Xmax += baseX;

					if(!(grafPort.txFace & faceMirrorY))
					{
						grafBlist.Ymin = - grafBlist.Ymin;
						grafBlist.Ymax = - grafBlist.Ymax;
					}
				/* Factor in pen location   */
					grafBlist.Ymin += baseY;
					grafBlist.Ymax += baseY;

				/* Draw it  */
					if(grafPort.pnLevel >= 0)
					{
						grafBlist.Xmax++;
						grafBlist.Ymax++;
						grafBlit.blitDmap->prFill(&grafBlit);
					}
					continue;
				}

			/* Must be the end of the character and handle spacing  */
				if(grafPort.txFace & faceProportional)
				{
					stOfWdTbl = ((ofswid *) (adsOfWdTbl + (chIndex << 1)));
					ScalePath(stOfWdTbl->wid, 0, &wd);
				}
				else
				{
					wd = fxWid;
				}
					
				temp.X = wd.X + txExt.X;
				temp.Y = wd.Y + txExt.Y;
				if(aCH == ' ')
				{
					temp.X += txSpc.X;
					temp.Y -= txSpc.Y;
				}

				LocX += temp.X;
				LocY += temp.Y;
				break;	/* end of processing for one character */
			}
			else 
			{
				temp.X = temNode.X - chCtrX;
				temp.Y = temNode.Y - chCtrY;
			
				if(chNodeTbl->X == -1)
				{	/* Next node is a control node */
					grafBlist.skipStat = SkipLast;
				}
				else

⌨️ 快捷键说明

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