l1text.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 491 行 · 第 1/2 页
C
491 行
_TextSettings.width;
space->ycoord = (float)( base->ycoord * _TextSettings.spacing ) /
_TextSettings.width;
} else {
space->xcoord = (float)( up->xcoord * _TextSettings.spacing ) /
(float) _TextSettings.height;
space->ycoord = (float)( up->ycoord * _TextSettings.spacing ) /
(float) _TextSettings.height;
}
}
static void CalcSides( struct xycoord * length, struct xycoord * height,
/*==================*/ struct xycoord * base, struct xycoord * up,
struct xycoord * space, char _WCI86FAR * str )
/* Compute the sides of the parallelogram. The length vector is along
the orientation vector; the visual height vector is perpendicular to
the orientation vector. */
{
short len;
short len_A;
short temp;
short width;
len_A = _CharWidth( 'A' );
len = 0;
width = 0;
if( _TextSettings.txpath == _PATH_UP ||
_TextSettings.txpath == _PATH_DOWN ) {
while( *str != '\0' ) { /* must find the */
len += 1; /* maximum width */
temp = _CharWidth( *str++ );
if( temp > width ) width = temp;
}
length->xcoord = ( base->xcoord * width ) / len_A;
length->ycoord = ( base->ycoord * width ) / len_A;
height->xcoord = space->xcoord * ( len - 1 ) + len * up->xcoord;
height->ycoord = space->ycoord * ( len - 1 ) + len * up->ycoord;
} else {
while( *str != '\0' ) { /* must find the */
len += 1; /* total width */
width += _CharWidth( *str++ );
}
length->xcoord = space->xcoord * ( len - 1 ) +
(short)( ( (long)width * base->xcoord ) / len_A );
length->ycoord = space->ycoord * ( len - 1 ) +
(short)( ( (long)width * base->ycoord ) / len_A );
height->xcoord = up->xcoord;
height->ycoord = up->ycoord;
}
}
static void CalcTranslation( struct xycoord * trans, struct xycoord * length,
/*========================*/ struct xycoord * height, struct xycoord * up,
short hor, short vert )
/* Calculate the translation vector: First assume that the lower left
corner of the text parallelogram corresponds to the text alignment
( _LEFT, _BOTTOM ). Second, find the translation required to move
the point corresponding to the true text alignment to the lower left
corner of the parallelogram. The remaining corners of the parallelogram
all obey the same transformation. */
{
switch( hor ) { /* Compute the translation for horizontal alignment */
case _LEFT :
trans->xcoord = 0;
trans->ycoord = 0;
break;
case _RIGHT :
trans->xcoord = -length->xcoord;
trans->ycoord = -length->ycoord;
break;
case _CENTER :
trans->xcoord = -length->xcoord / 2;
trans->ycoord = -length->ycoord / 2;
}
switch( vert ) { /* Add translation from vertical alignment */
case _TOP :
trans->xcoord -= height->xcoord;
trans->ycoord -= height->ycoord;
break;
case _CAP :
if( _TextSettings.txpath == _PATH_UP ||
_TextSettings.txpath == _PATH_DOWN ) {
trans->xcoord -= height->xcoord - up->xcoord / 4;
trans->ycoord -= height->ycoord - up->ycoord / 4;
} else {
trans->xcoord -= 3 * height->xcoord / 4;
trans->ycoord -= 3 * height->ycoord / 4;
}
break;
case _HALF :
trans->xcoord -= height->xcoord / 2;
trans->ycoord -= height->ycoord / 2;
break;
case _BASE :
if( _TextSettings.txpath == _PATH_UP ||
_TextSettings.txpath == _PATH_DOWN ) {
trans->xcoord -= up->xcoord / 4;
trans->ycoord -= up->ycoord / 4;
} else {
trans->xcoord -= height->xcoord / 4;
trans->ycoord -= height->ycoord / 4;
}
break;
case _BOTTOM :
break;
}
}
static void CalcCorners( struct xycoord _WCI86FAR * corner, struct xycoord * length,
/*====================*/ struct xycoord * height, struct xycoord * trans,
short xpos, short ypos )
/* Compute the corners of the character drawing parallelogram. */
{
short p; /* loop index */
corner[0].xcoord = 0; /* initialize the corners */
corner[0].ycoord = 0;
corner[1].xcoord = length->xcoord;
corner[1].ycoord = - length->ycoord;
corner[2].xcoord = length->xcoord + height->xcoord;
corner[2].ycoord = - length->ycoord - height->ycoord;
corner[3].xcoord = height->xcoord;
corner[3].ycoord = - height->ycoord;
trans->xcoord += xpos; /* final translation vector */
trans->ycoord = ypos - trans->ycoord;
for( p = 0; p <= 3; p++ ) { /* translate the 4 corners */
corner[p].xcoord += trans->xcoord;
corner[p].ycoord += trans->ycoord;
}
}
static void CalcNominal( struct xycoord * base, struct xycoord * up,
/*====================*/ struct xycoord * prop, struct xycoord * nommove,
struct xycoord * space, char ch )
/* Calculate the nominal move vector for one character. It is used in
updating the drawing point once a character has been drawn. It is
also used in computing the concatenation point. */
{
short len_A, len_ch;
len_A = _CharWidth( 'A' );
len_ch = _CharWidth( ch );
prop->xcoord = ( (long) base->xcoord * len_ch +
Round( base->xcoord, len_A ) ) / len_A;
prop->ycoord = ( (long) base->ycoord * len_ch +
Round( base->ycoord, len_A ) ) / len_A;
if( _TextSettings.txpath == _PATH_RIGHT ||
_TextSettings.txpath == _PATH_LEFT ) { /* increment is +base vector*/
nommove->xcoord = prop->xcoord + space->xcoord;
nommove->ycoord = prop->ycoord + space->ycoord;
} else {
nommove->xcoord = up->xcoord + space->xcoord; /* increment is +up vector */
nommove->ycoord = up->ycoord + space->ycoord;
}
if( _TextSettings.txpath == _PATH_LEFT ||
_TextSettings.txpath == _PATH_DOWN ) {
nommove->xcoord = -nommove->xcoord;
nommove->ycoord = -nommove->ycoord;
}
}
static short Round( short sign, short val )
/*=======================================*/
{
val = val / 2;
if( sign >= 0 ) {
return( val );
} else {
return( -val );
}
}
static void CalcConcat( struct xycoord _WCI86FAR * concat, struct xycoord * move,
/*===================*/ struct xycoord * space, short xpos, short ypos,
short hor, short vert )
/* Compute the concatenation point for only those cases where there is
no ambiguity. If the concatenation point cannot be computed exactly,
then simply return the character drawing point. */
{
short exact;
exact = 0; /* assume can't compute concatenation point */
concat->xcoord = xpos; /* return same point if can't compute */
concat->ycoord = ypos; /* the concatenation point exactly. */
switch( _TextSettings.txpath ) {
case _PATH_UP :
if( vert == _BASE || vert == _BOTTOM ) {
exact = 1;
}
break;
case _PATH_DOWN :
if( vert == _CAP || vert == _TOP ) {
exact = -1;
}
break;
case _PATH_RIGHT :
if( hor == _LEFT ) {
exact = 1;
}
break;
case _PATH_LEFT :
if( hor == _RIGHT ) {
exact = -1;
}
}
if( exact ) { /* adjust concatenation point */
concat->xcoord += exact * ( move->xcoord + space->xcoord );
concat->ycoord -= exact * ( move->ycoord + space->ycoord );
}
}
static short _CharWidth( char ch )
/*==============================*/
/* This routine returns the width of the character ch scaled to the
interval [0,127]. */
{
ch = ch;
// if( ch >= ' ' && ch <= 0x7e ) {
// if( _FontType == _STROKE ) {
// if( _PropFont ) {
// return( _CurrFont->font.stroke.width[ ch ] );
// } else {
// return( _CurrFont->font.stroke.width[ 'A' ] );
// }
// } else {
// return( _CurrFont->font.bit.width );
// }
return( _TextSettings.width );
// } else {
// return( 0 );
// }
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?