📄 text1.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 */
/* */
/* TEXT1.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the SetFont and SetWorkGrafmap functions. */
/* */
/* 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 11/16/99 Got rid of ANSI compiler warnings */
/* */
/*************************************************************************/
#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 "wndo.h"
/* Function SETFONT sets the specified font record, FONT, to be the
current font. */
#define MAJORVER 0x02
#define MINORVER 0x20
void SetFont( fontRcd *FONT)
{
void InitBitmap(int argDEVICE, grafMap *argGRAFMAP);
void InitRowTable(grafMap *argBitMap, int argInrLve, int argInrSeg, int argInrSiz);
void SetWorkGrafmap(short);
void mwTxtBltH();
int i;
grafMap *bmapPtr;
long fontPtr;
long *adsRowTbl;
short ErrValue;
char METASIG[] = "NU__FONT";
if(FONT == 0)
return; /* exit if NULL pointer */
/* Verify NU__FONT signature */
for(i=0; i< 8; i++)
{
if(FONT->fontSign[i] != METASIG[i])
{
ErrValue = c_SetFont + c_BadFontVer;
nuGrafErr(ErrValue);
FONT = (fontRcd *) imbFnt;
break;
}
}
/* Check if font version meets requirement */
if(((FONT->fontVer & 0x0F) != MAJORVER) || (FONT->fontVer < MINORVER))
{
ErrValue = c_SetFont + c_BadFontVer;
nuGrafErr(ErrValue);
FONT = (fontRcd *) imbFnt;
}
/* At this point we have a validated font buffer */
grafPort.txFont = (long) FONT;
thePort->txFont = (long) FONT;
fntVertTbl[alignTop] = 0;
fntVertTbl[alignBaseline] = FONT->ascent - 1;
fntVertTbl[alignBottom] = FONT->chHeight - 1;
fntVertTbl[alignMiddle] = FONT->chHeight >> 1;
/* Set current vertical aligment */
fntVertAln = fntVertTbl[grafPort.txAlign.Y];
/* Initialize the Bitmapped and bitmap font's grafMap */
if(!(FONT->fontFlags & fontType))
{
bmapPtr = (grafMap *) ((long) FONT + FONT->bmapTbl);
fontPtr = (long) FONT + FONT->fontTbl;
adsRowTbl = (long *) ((long) FONT + FONT->rowTbl);
#ifdef FIXUP386
fontPtr += dllFixup;
#endif
/* Instal into font's grafMap record */
bmapPtr->mapTable[0] = (long **) adsRowTbl;
*adsRowTbl = fontPtr;
bmapPtr->devTech = dtUser;
/* Initialize a user defined grafMap */
InitBitmap(cUSER, bmapPtr);
/* Set flag indicating a linear bitmap for best speed */
bmapPtr->mapFlags = (short) mfRowTabl;
InitRowTable(bmapPtr, 0, 0, 0);
#ifdef FIXUP386
bmapPtr->mapTable[0] += dllFixup;
#endif
/* Set the current bitmapped text draw vector */
txtDrwIDV = mwTxtBltH;
/* Initialize the worspace grafmap for syth facing */
SetWorkGrafmap(FONT->chHeight);
}
/* InitStroked set the current stoked text draw vectors to initialize */
else
{
txtDrwIDV = txtStrokeIDV;
if(grafPort.txAlign.X == 0)
txtAlnIDV = txtStrokeIDV;
}
/* Set current text align vector */
txtAlnIDV = txtDrwIDV;
if(grafPort.txAlign.X != alignLeft)
txtAlnIDV = txtAPPIDV;
return;
}
/* Function SetWorkGrafmap setups the workspaces grafmap and rowtable to allow
blits from the workspace. The grafmap height is passed in font_Height, and
the width is set for the maximum allowable in the cuurent workspace buffer */
void SetWorkGrafmap(short font_Height )
{
void InitBitmap(int argDEVICE, grafMap *argGRAFMAP);
void InitRowTable(grafMap *argBitMap, int argInrLve, int argInrSeg, int argInrSiz);
/* de-allocate old rowtable */
mpWorkEnd += mpRowTblSz;
/* Allocate this rowtable */
mpRowTblSz = font_Height << 2;
mpWorkEnd -= mpRowTblSz;
/* mpWorkEnd now is a pointer to the workspace rowtable */
workGrafMap.mapTable[0] = (long **) mpWorkEnd;
/* BobB 9/9/98 - added the following line to set up first rowtable */
*workGrafMap.mapTable[0] = (long *) mpWorkSpace;
/* Set first row table entry to start of work buffer */
#ifdef FIXUP386
mpWorkEnd += dllFixup;
#endif
/* Compute size of remaining workspace */
/* Per raster calculation */
workGrafMap.pixBytes = ((short) (mpWorkEnd - mpWorkSpace)) / font_Height;
workGrafMap.pixWidth = workGrafMap.pixBytes << 3;
workGrafMap.pixHeight = font_Height;
/* Set as monoChrome - no driver */
workGrafMap.pixBits = 1;
workGrafMap.pixPlanes = 1;
/* Set devTech so no primitives loaded */
workGrafMap.devTech = dtUser;
/* initialize the grafmap */
InitBitmap(cUSER, &workGrafMap);
/* Set flag indicating a linear bitmap for best speed */
workGrafMap.mapFlags = mfRowTabl;
InitRowTable(&workGrafMap, 0, 0, 0);
#ifdef FIXUP386
workGrafMap.mapTable[0] += dllFixup;
#endif
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -