📄 str20.c
字号:
/*************************************************************************/
/* */
/* 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 */
/* */
/* STR20.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the mwTxtBltH function. */
/* */
/* AUTHOR */
/* */
/* Giac Dinh, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 9/10/98 Corrected for synthetic facing */
/* BobB 1/5/99 Corrected for bold spacing */
/* BobB 1/7/99 Corrected blit list pointer */
/* BobB 11/9/99 Removed unused variables */
/* */
/*************************************************************************/
#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"
/* Function mwTxtBltH() draws characters from the specified text string,
TEXTSTR, 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 drawn beginning at the current pen location. After the text
is drawn, the pen is located to the start of the next character position
past the last character drawn (where a continuation of the string just
drawn would start).
INTERNAL PROCESSING NOTES:
Character Widths:
There are two widths involved in processing each character:
1) the character's "image width", and
2) the chacacter's "spacing width".
The "image width" is the size of the actual character pixel width for
blitting from the font to the destination bitmap. The image width is
defined by the by the image offset values contained in "locTbl" for
the font. Image width is calculated as follows:
imageWidth = (offset for the nextChar) - (the offset for the char);
-or-
imageWidth = locTbl[charNbr+1] - locTbl[charNbr];
2) The "spacing width" is the amount of horizontal space the character
occupies (which may or may not be the same as the cell width). The
entries in the ofwdTbl are actually pen updating info, only having
relevance in determining the ending pen location. Depending on whether
the Proportional flag is set, these values intersect in two different ways:
fixed width: Uses .chWidth for all characters
proportional width: Uses ofwdTbl.wid for each character
The starting location for the image blit is determined by adding the
character's signed "ofwdTbl.ofs" offset value to the starting pen
position. The ending position for the pen is then determined by
adding the character's "ofwdTbl.wid" width value to the starting pen
position.
bgnBlitX = locX + ofwdTbl[aChar].ofs;
newLocX = locX + ofwdTbl[aChar].wid;
Limitations:
=============
All font elements (except pixImage) will reside in the same segment (64k).
This implies a limitation of about 30,000 chars per font file
(If you assume 16 bytes per char, thats about 480k of font file)
The max height/width is limited to 16k/32k pixels.
The TextColor() call is not implemented. Currently uses PenColor() vars
for blitter call.
Notice that ofwdTbl is two bytes, this limits the offset to +/- 127,
and charcter spacing width to be 0-255. */
void mwTxtBltH (void *TEXTSTR, int INDEX, int COUNT, int CHARSIZE)
{
void nuGrafErr(short Err);
#define maxChars 128 /* Maximum length of input string */
struct blitRec{ /* BlitList Rectangle Data Structure */
short sXmin ; /* src minimum X */
short sYmin ; /* src minimum Y */
short sXmax ; /* src maximum X */
short sYmax ; /* src maximum Y */
short dXmin ; /* dst minimum X */
short dYmin ; /* dst minimum Y */
short dXmax ; /* dst maximum X */
short dYmax ; /* dst maximum Y */
}StrPtr[maxChars];
/* BobB 9/25/98 - changed the following lines for chars > 127
char *textBytePtr; */
byte *textBytePtr;
word *textWordPtr;
short aCH, iCH;
short srcYmax;
short dstYmin,dstYmax;
short bgnX, bgnY, dstX;
long gpOfWdTbl ; /*grafPort.txFont.OfWdTbl*/
ofswid *ofWdPtr;
long gpLocTbl ; /*grafPort.txFont.locTbl*/
short *gpLocPtr ;
long gpTxFace ; /*grafPort.txFace*/
long gpTxTerm ; /*gafPort.txTerm*/
long gpTxExtra ; /*gafPort.txExtra*/
/* BobB 11/9/99 - removed the following variable since is never used
long gpTxSpace ; */ /*gafPort.txSpace*/
long gpTxMode ; /*gafPort.txMode*/
long gpTxPath ; /*grafPort.txPath*/
short txSpaceSw ; /*char to add txSpace for or txTerm*/
short imageWidth;
short char_width, char_ofset;
short icAdd ;
/* BobB 9/10/98 - changed the following variable
long *rowTable; */
long **rowTable;
byte *sfBitmap ;
/* BobB 9/10/98 - added the following variable */
byte *svBitmap ;
byte *wsBitmap ;
byte *ws2Bitmap ;
fontRcd *gpTxFont;
grafMap *gpGrafMap;
short sfPixBytes ;
short sfByteCnt ;
short sfSrc2Next ;
short sfDst2Next ;
short sfShiftBytes;
short sfCumShift ;
short sfShiftInc ;
short MaskLeft, MaskRight;
short ErrValue;
/* BobB 11/9/99 - removed the following variable since is never used
short srcPtr=0; */
rect *dstPtr;
int charCount=0;
int i;
int j;
int k;
int tempData;
short penSize;
short oldPen;
/* BobB 9/9/98 - added the following temporary variable */
byte boldData;
/* Tables */
short deltatbl[19]={0, 21, 46, 69, 92, 120, 149, 179, 215, 256,
304,364, 443, 548, 704, 960, 1452, 2926, 0};
short LfMask[8]={0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01};
short RtMask[8]={0xFF, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE};
/* BobB 9/25/98 - changed the following lines for chars > 127
textBytePtr = (char *) TEXTSTR + INDEX ; */
textBytePtr = (byte *) TEXTSTR + INDEX ;
textWordPtr = (word *) TEXTSTR + INDEX;
gpTxFont = (fontRcd *) grafPort.txFont;
dstX = bgnX = LocX;
bgnY = LocY;
srcYmax = gpTxFont->chHeight;
dstYmin = LocY - fntVertAln;
dstYmax = dstYmin + gpTxFont->chHeight;
gpLocTbl = (long) gpTxFont + gpTxFont->locTbl;
gpOfWdTbl = (long) gpTxFont + gpTxFont->ofwdTbl;
gpTxFace = grafPort.txFace;
gpTxExtra = grafPort.txExtra;
/* add extra interchar space for bold synth facing */
if(gpTxFace & faceBold)
gpTxExtra = gpTxExtra + grafPort.txBold ;
gpTxPath = grafPort.txPath ;
gpTxTerm = grafPort.txTerm ;
/* BobB 11/9/99 - removed the following line since variable is never used
gpTxSpace = grafPort.txSpace; */
/* add extra interspace for spacing */
if (grafPort.txSpace != 0)
{
txSpaceSw = ' ';
}
else
{
txSpaceSw = grafPort.txTerm;
}
/* Set the max size for Count */
if( COUNT > maxChars ) COUNT = maxChars;
COUNT--;
/* Terminate the function when COUNT is less than 0 */
if(COUNT < 0) return;
/* Loop to process each charater */
do {
if ( CHARSIZE != 0 )
{
aCH = (short) *textWordPtr++;
}
else
{
/* BobB 9/25/98 - changed the following lines for chars > 127
aCH = (char ) *textBytePtr++; */
aCH = (byte ) *textBytePtr++;
}
if (aCH == gpTxTerm ) break; /* Break do loop */
if(aCH < gpTxFont->fontMin || aCH > gpTxFont->fontMax)
{
aCH = gpTxFont->chBad ;
iCH = (gpTxFont->chBad - gpTxFont->fontMin);
ofWdPtr = ((ofswid *) (gpOfWdTbl + (iCH << 1)));
}
else
{
iCH = (aCH - gpTxFont->fontMin);
ofWdPtr = ((ofswid *) (gpOfWdTbl + (iCH << 1)));
if ((ofWdPtr->wid == 0xFF) && (ofWdPtr->ofs == -1))
{
aCH = gpTxFont->chBad ;
iCH = (gpTxFont->chBad - gpTxFont->fontMin);
ofWdPtr = ((ofswid *) (gpOfWdTbl + (iCH << 1)));
}
}
/* Ready to process character */
gpLocPtr = ((short *) gpLocTbl) + iCH;
StrPtr[charCount].sXmin = *gpLocPtr++;
StrPtr[charCount].sXmax = *gpLocPtr++;
char_width = gpTxFont->chWidth;
/* Get image offset and width */
/* BobB 10/6/98 - corrected the following line to allow for proportional
and underlining
if(gpTxFace == faceProportional) char_width = ofWdPtr->wid; */
if(gpTxFace & faceProportional) char_width = ofWdPtr->wid;
char_ofset = ofWdPtr->ofs;
/* Save src X and compute dst X limits */
StrPtr[charCount].dXmin = dstX + char_ofset;
imageWidth = StrPtr[charCount].sXmax - StrPtr[charCount].sXmin;
if(imageWidth > 0 )
{
StrPtr[charCount].dXmax = StrPtr[charCount].dXmin + imageWidth;
StrPtr[charCount].sYmin = 0;
StrPtr[charCount].sYmax = srcYmax;
StrPtr[charCount].dYmin = dstYmin;
StrPtr[charCount].dYmax = dstYmax;
charCount++;
}
/* Compute the amount to add between characters */
/* BobB 1/5/99 - corrected the following line for bold spacing
icAdd = grafPort.txExtra; */
icAdd = (short) gpTxExtra;
if(aCH == txSpaceSw) icAdd += grafPort.txSpace;
/* Advance in path direction */
if (gpTxPath >= 900 )
{
if(gpTxPath >= 2700)
{ /* Path Down */
icAdd += (dstYmax - dstYmin);
dstYmin += icAdd ;
dstYmax += icAdd ;
bgnY += icAdd ; /* update pen position */
}
else
{
if(gpTxPath >= 1800 )
{ /* Path Left */
icAdd += char_width;
dstX -= icAdd ;
}
else
{ /* Path Up */
icAdd += (dstYmax - dstYmin);
dstYmin -= icAdd ;
dstYmax -= icAdd ;
bgnY -= icAdd ; /* update pen position */
}
}
}
else
{ /* Path Right */
icAdd += char_width;
dstX += icAdd;
}
}while ((COUNT--) > 0 ); /* END LOOP */
/* Reset the counter */
COUNT = charCount;
charCount = 0;
/*************** Ready to blit characters **************/
if((grafPort.pnLevel >= 0) && (COUNT > 0))
{
grafBlit.blitCnt = COUNT;
gpTxMode = grafPort.txMode;
grafBlit.blitRop = grafPort.txMode;
gpGrafMap = (grafMap *) ((long) gpTxFont + gpTxFont->bmapTbl);
/* BobB 10/6/98 - Changed the following line to correct inversion
if(gpTxFace & !faceProportional) */
if(gpTxFace & ~faceProportional)
{ /****** DoSynthFacing *****/
/* The blitlist must be processed for each rectangle pair.
Each source rectangle must be placed into the workspace bitmap,
facing applied, and then blit from the workspace bitmap to the dest
bitmap */
grafBlit.blitCnt = 1;
grafBlit.blitSmap = &workGrafMap;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -