[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
3.13: Word baselines
From: |
Chip Salzenberg |
Subject: |
3.13: Word baselines |
Date: |
Mon, 15 Feb 1999 03:19:43 -0500 |
This patch makes 3.13 behave as I think it must -- making various
words on the same line share a common baseline.
I think it's a good sign that the patch only eliminates code.
Index: externs.h
***************
*** 847,851 ****
struct
{ FULL_LENGTH ofont_size;
- FULL_LENGTH ofont_xheight2;
FULL_LENGTH ofont_spacewidth;
MAPPING ofont_mapping : 7;
--- 847,850 ----
***************
*** 1199,1203 ****
#define font_page(x) (x)->os1.ou2.os25.ofont_page
#define font_size(x) (x)->os1.ou3.os32.ofont_size
- #define font_xheight2(x) (x)->os1.ou3.os32.ofont_xheight2
#define font_spacewidth(x) (x)->os1.ou3.os32.ofont_spacewidth
#define font_mapping(x) (x)->os1.ou3.os32.ofont_mapping
--- 1198,1201 ----
***************
*** 2559,2563 ****
extern void FontWordSize(OBJECT x);
extern FULL_LENGTH FontSize(FONT_NUM fnum, OBJECT x);
- extern FULL_LENGTH FontHalfXHeight(FONT_NUM fnum);
extern MAPPING FontMapping(FONT_NUM fnum, FILE_POS *xfpos);
extern FULL_CHAR *FontName(FONT_NUM fnum);
--- 2557,2560 ----
Index: z24.c
***************
*** 40,44 ****
#include "externs.h"
#define StartUpResource "LoutStartUp"
- #define DEFAULT_XHEIGHT 500
#define NO_FONT 0 /* actually stolen from z37.c
*/
#define NO_COLOUR 0
--- 40,43 ----
*************** typedef struct
*** 70,74 ****
BOOLEAN gs_cpexists; /* TRUE if a current point exists */
FULL_LENGTH gs_currenty; /* if cpexists, its y coordinate */
- short gs_xheight2; /* of font exists, half xheight
*/
} GRAPHICS_STATE;
--- 69,72 ----
*************** static int gs_stack_top; /* top of grap
*** 78,82 ****
static FONT_NUM currentfont; /* font of most recent atom
*/
static COLOUR_NUM currentcolour; /* colour of most recent atom */
- static short currentxheight2;/* half xheight in current font */
static BOOLEAN cpexists; /* true if a current point
exists */
static FULL_LENGTH currenty; /* if cpexists, its y coordinate */
--- 76,79 ----
*************** void PrintWord(OBJECT x, int hpos, int v
*** 591,595 ****
if( word_font(x) != currentfont )
{ currentfont = word_font(x);
- currentxheight2 = FontHalfXHeight(currentfont);
fprintf(out_fp, "%hd %s", FontSize(currentfont, x),
FontName(currentfont));
--- 588,591 ----
*************** void PrintWord(OBJECT x, int hpos, int v
*** 615,620 ****
/* move to coordinate of x */
- debug1(DGP, DDD, " currentxheight2 = %d", currentxheight2);
- vpos = vpos - currentxheight2;
if( cpexists && currenty == vpos )
{ printnum(hpos, out_fp);
--- 611,614 ----
*************** void PrintWord(OBJECT x, int hpos, int v
*** 695,700 ****
if( word_font(x) != currentfont )
{ currentfont = word_font(x);
! currentxheight2 = FontHalfXHeight(currentfont);
! PDFFont_Set(out_fp, FontSize(currentfont, x), FontName(currentfont));
}
--- 689,693 ----
if( word_font(x) != currentfont )
{ currentfont = word_font(x);
! PDFFont_Set(out_fp, FontSize(currentfont, x), FontName(currentfont));
}
*************** void PrintWord(OBJECT x, int hpos, int v
*** 713,718 ****
/* move to coordinate of x */
- debug1(DGP, DDD, " currentxheight2 = %d", currentxheight2);
- vpos = vpos - currentxheight2;
if( cpexists && (currenty == vpos) && PDFHasValidTextMatrix() )
{ /* printnum(hpos, out_fp); */
--- 706,709 ----
*************** void SaveGraphicState(OBJECT x)
*** 1141,1145 ****
gs_stack[gs_stack_top].gs_cpexists = cpexists;
gs_stack[gs_stack_top].gs_currenty = currenty;
- gs_stack[gs_stack_top].gs_xheight2 = currentxheight2;
debug0(DRS, D, "SaveGraphicState returning.");
} /* end SaveGraphicState */
--- 1132,1135 ----
*************** void RestoreGraphicState(void)
*** 1168,1172 ****
cpexists = gs_stack[gs_stack_top].gs_cpexists;
currenty = gs_stack[gs_stack_top].gs_currenty;
- currentxheight2 = gs_stack[gs_stack_top].gs_xheight2;
gs_stack_top--;
/* ***
--- 1158,1161 ----
*************** void DefineGraphicNames(OBJECT x)
*** 1266,1270 ****
{ currentfont = font(save_style(x));
if( currentfont > 0 )
! { currentxheight2 = FontHalfXHeight(currentfont);
#if 1 /* VT 98/01/04: modified for PDF */
if (BackEnd == POSTSCRIPT)
--- 1255,1259 ----
{ currentfont = font(save_style(x));
if( currentfont > 0 )
! {
#if 1 /* VT 98/01/04: modified for PDF */
if (BackEnd == POSTSCRIPT)
*************** void SaveTranslateDefineSave(OBJECT x, F
*** 1362,1366 ****
gs_stack[gs_stack_top].gs_cpexists = cpexists;
gs_stack[gs_stack_top].gs_currenty = currenty;
- gs_stack[gs_stack_top].gs_xheight2 = currentxheight2;
/* from CoordTranslate */
--- 1351,1354 ----
*************** void SaveTranslateDefineSave(OBJECT x, F
*** 1373,1377 ****
gs_stack[gs_stack_top].gs_cpexists = cpexists;
gs_stack[gs_stack_top].gs_currenty = currenty;
- gs_stack[gs_stack_top].gs_xheight2 = currentxheight2;
/* accumulated output from all four calls, repackaged */
--- 1361,1364 ----
*************** void PrintGraphicInclude(OBJECT x, FULL_
*** 1439,1443 ****
if( font(save_style(x)) != currentfont )
{ currentfont = font(save_style(x));
- currentxheight2 = FontHalfXHeight(currentfont);
fprintf(out_fp, "%hd %s\n", FontSize(currentfont,x),
FontName(currentfont));
}
--- 1426,1429 ----
Index: z37.c
***************
*** 26,31 ****
/* MODULE: Font Service
*/
/* EXTERNS: FontInit(), FontDefine(), FontChange(), FontWordSize(),
*/
! /* FontSize(), FontHalfXHeight(), FontEncoding(),
*/
! /* FontMapping(), FontFamilyAndFace(), FontNeeded()
*/
/*
*/
/* This module implements fonts, using encoding vectors and Adobe font
*/
--- 26,31 ----
/* MODULE: Font Service
*/
/* EXTERNS: FontInit(), FontDefine(), FontChange(), FontWordSize(),
*/
! /* FontSize(), FontEncoding(), FontMapping(),
*/
! /* FontFamilyAndFace(), FontNeeded()
*/
/*
*/
/* This module implements fonts, using encoding vectors and Adobe font
*/
***************
*** 34,38 ****
/*****************************************************************************/
#include "externs.h"
- #define DEFAULT_XHEIGHT 500 /* the default XHeight if font has none */
#define NO_FONT 0 /* the not-a-font font number
*/
#define SZ_DFT 1000 /* default lout size is 50p
*/
--- 34,37 ----
*************** static void ReadFont(OBJECT face, OBJECT
*** 271,279 ****
{ OBJECT filename, fontname;
FULL_CHAR buff[MAX_BUFF], command[MAX_BUFF], ch;
! int wx, llx, lly, urx, ury, xheight2, i, lnum, ligtop;
! float fl_wx, fl_llx, fl_lly, fl_urx, fl_ury, fl_xheight2, fl_under_pos,
fl_under_thick;
int under_pos, under_thick;
! BOOLEAN upfound, utfound, xhfound, wxfound, bfound;
BOOLEAN fixed_pitch = FALSE;
FILE_NUM fnum; FILE *fp;
--- 270,278 ----
{ OBJECT filename, fontname;
FULL_CHAR buff[MAX_BUFF], command[MAX_BUFF], ch;
! int wx, llx, lly, urx, ury, i, lnum, ligtop;
! float fl_wx, fl_llx, fl_lly, fl_urx, fl_ury, fl_under_pos,
fl_under_thick;
int under_pos, under_thick;
! BOOLEAN upfound, utfound, wxfound, bfound;
BOOLEAN fixed_pitch = FALSE;
FILE_NUM fnum; FILE *fp;
*************** static void ReadFont(OBJECT face, OBJECT
*** 352,356 ****
/* read font metrics file */
! xhfound = upfound = utfound = FALSE;
fontname = nilobj; lnum = 1;
while ( ( StringFGets(buff, MAX_BUFF, fp) ) != NULL )
--- 351,355 ----
/* read font metrics file */
! upfound = utfound = FALSE;
fontname = nilobj; lnum = 1;
while ( ( StringFGets(buff, MAX_BUFF, fp) ) != NULL )
*************** static void ReadFont(OBJECT face, OBJECT
*** 384,401 ****
- case 'X':
-
- if( StringEqual(command, AsciiToFull("XHeight")) )
- { if( xhfound )
- { Error(37, 15, "XHeight found twice in font file (line %d)",
- FATAL, &fpos(filename), lnum);
- }
- sscanf( (char *) buff, "XHeight %f", &fl_xheight2);
- xheight2 = fl_xheight2 / 2;
- xhfound = TRUE;
- }
- break;
-
-
case 'F':
--- 383,386 ----
*************** static void ReadFont(OBJECT face, OBJECT
*** 438,442 ****
Error(37, 19, "FontName missing in file %s",
FATAL, &fpos(filename), FileName(fnum));
- if( !xhfound ) xheight2 = DEFAULT_XHEIGHT / 2;
while( StringFGets(buff, MAX_BUFF, fp) != NULL &&
!StringBeginsWith(buff, AsciiToFull("EndCharMetrics")) )
--- 423,426 ----
*************** static void ReadFont(OBJECT face, OBJECT
*** 514,520 ****
case POSTSCRIPT:
case PDF: fnt[ch].left = llx;
! fnt[ch].down = lly - xheight2;
fnt[ch].right = wx;
! fnt[ch].up = ury - xheight2;
fnt[ch].last_adjust =
(urx == 0 || wx == 0 || fixed_pitch) ? 0 :
urx - wx;
--- 498,504 ----
case POSTSCRIPT:
case PDF: fnt[ch].left = llx;
! fnt[ch].down = lly;
fnt[ch].right = wx;
! fnt[ch].up = ury;
fnt[ch].last_adjust =
(urx == 0 || wx == 0 || fixed_pitch) ? 0 :
urx - wx;
*************** static void ReadFont(OBJECT face, OBJECT
*** 645,650 ****
font_size(fontname) =
(BackEnd != PLAINTEXT) ? SZ_DFT : PlainCharHeight;
- font_xheight2(fontname) =
- (BackEnd != PLAINTEXT) ? xheight2 : PlainCharHeight / 4;
font_mapping(fontname) = font_mapping(filename);
ch = MapCharEncoding(STR_PS_SPACENAME, font_mapping(fontname));
--- 629,632 ----
*************** static void ReadFont(OBJECT face, OBJECT
*** 652,656 ****
finfo[font_count].font_table = fontname;
finfo[font_count].original_font = face;
! finfo[font_count].underline_pos = xheight2 - under_pos;
finfo[font_count].underline_thick = under_thick;
finfo[font_count].size_table = fnt;
--- 634,638 ----
finfo[font_count].font_table = fontname;
finfo[font_count].original_font = face;
! finfo[font_count].underline_pos = -under_pos;
finfo[font_count].underline_thick = under_thick;
finfo[font_count].size_table = fnt;
*************** static void ReadFont(OBJECT face, OBJECT
*** 681,686 ****
/* close file, debug and exit */
fclose(fp);
! debug4(DFT, D, "ReadFont returning: %d, name %s, fs %d, xh2 %d",
! font_count, string(fontname), font_size(fontname), xheight2);
return;
}
--- 663,668 ----
/* close file, debug and exit */
fclose(fp);
! debug3(DFT, D, "ReadFont returning: %d, name %s, fs %d",
! font_count, string(fontname), font_size(fontname));
return;
}
*************** void FontChange(STYLE *style, OBJECT x)
*** 907,912 ****
SetGap(space_gap(*style), nobreak(space_gap(*style)), FALSE, TRUE,
FIXED_UNIT, EDGE_MODE, font_spacewidth(fsize));
! debug2(DFT, D,"FontChange returning (old) %d (XHeight2 = %d)",
! font(*style), font_xheight2(finfo[font(*style)].font_table));
return;
}
--- 889,893 ----
SetGap(space_gap(*style), nobreak(space_gap(*style)), FALSE, TRUE,
FIXED_UNIT, EDGE_MODE, font_spacewidth(fsize));
! debug1(DFT, D, "FontChange returning (old) %d", font(*style));
return;
}
*************** void FontChange(STYLE *style, OBJECT x)
*** 935,939 ****
Link(face, new);
font_size(new) = BackEnd != PLAINTEXT ? flen : font_size(old);
- font_xheight2(new) = font_xheight2(old) * font_size(new) /
font_size(old);
font_mapping(new) = font_mapping(old);
font_spacewidth(new) = font_spacewidth(old) *
font_size(new)/font_size(old);
--- 916,919 ----
*************** void FontChange(STYLE *style, OBJECT x)
*** 988,993 ****
SetGap(space_gap(*style), nobreak(space_gap(*style)), FALSE, TRUE,
FIXED_UNIT, EDGE_MODE, font_spacewidth(new));
! debug2(DFT, D,"FontChange returning (scaled) %d (XHeight2 = %d)",
! font(*style), font_xheight2(finfo[font(*style)].font_table));
/* FontDebug(); */
} /* end FontChange */
--- 968,972 ----
SetGap(space_gap(*style), nobreak(space_gap(*style)), FALSE, TRUE,
FIXED_UNIT, EDGE_MODE, font_spacewidth(new));
! debug1(DFT, D,"FontChange returning (scaled) %d", font(*style));
/* FontDebug(); */
} /* end FontChange */
*************** void FontWordSize(OBJECT x)
*** 1135,1139 ****
! /*@::FontSize(), FontHalfXHeight(), FontEncoding(),
FontName()@***************/
/*
*/
/* FULL_LENGTH FontSize(fnum, x)
*/
--- 1114,1118 ----
! /*@::FontSize(), FontEncoding(),
FontName()@**********************************/
/*
*/
/* FULL_LENGTH FontSize(fnum, x)
*/
*************** FULL_LENGTH FontSize(FONT_NUM fnum, OBJE
*** 1151,1171 ****
return font_size(finfo[fnum].font_table);
} /* end FontSize */
-
-
-
/*****************************************************************************/
- /*
*/
- /* FULL_LENGTH FontHalfXHeight(fnum)
*/
- /*
*/
- /* Return the xheight2 value of this font.
*/
- /*
*/
-
/*****************************************************************************/
-
- FULL_LENGTH FontHalfXHeight(FONT_NUM fnum)
- { debug1(DFT, DD, "FontHalfXHeight( %d )", fnum);
- assert( fnum <= font_count, "FontHalfXHeight!" );
- debug1(DFT, DD, "FontHalfXHeight returning %d",
- font_xheight2(finfo[fnum].font_table));
- return font_xheight2(finfo[fnum].font_table);
- } /* end FontHalfXHeight */
--- 1130,1133 ----
Index: z38.c
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 414,418 ****
{ MAPPING m; int i; OBJECT new_y, new_x, new_acat, tmp;
FULL_CHAR buff[MAX_BUFF], *uc, *p, *q;
! FONT_NUM small_font; FULL_LENGTH vshift; int state; STYLE new_style;
static OBJECT font_change_word = nilobj;
assert( is_word(type(x)), "MapSmallCaps: !is_word(type(x))" );
--- 414,418 ----
{ MAPPING m; int i; OBJECT new_y, new_x, new_acat, tmp;
FULL_CHAR buff[MAX_BUFF], *uc, *p, *q;
! FONT_NUM small_font; int state; STYLE new_style;
static OBJECT font_change_word = nilobj;
assert( is_word(type(x)), "MapSmallCaps: !is_word(type(x))" );
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 456,464 ****
{ *q++ = uc[*p];
! /* work out what the smaller font is going to be, and the vshift */
StyleCopy(new_style, *style);
FontChange(&new_style, font_change_word);
small_font = font(new_style);
- vshift = FontHalfXHeight(word_font(x)) - FontHalfXHeight(small_font);
state = ALL_TRANS;
--- 456,463 ----
{ *q++ = uc[*p];
! /* work out what the smaller font is going to be */
StyleCopy(new_style, *style);
FontChange(&new_style, font_change_word);
small_font = font(new_style);
state = ALL_TRANS;
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 480,484 ****
FontChange(&new_style, font_change_word);
small_font = font(new_style);
- vshift = FontHalfXHeight(word_font(x)) - FontHalfXHeight(small_font);
/* make a new WORD out of the current contents of buff */
--- 479,482 ----
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 511,515 ****
/* make a new @VShift WORD out of the current contents of buff */
tmp = DoWord(buff, q, x, small_font);
! new_y = DoVShift(x, vshift, tmp);
/* construct the skeleton of the result to replace x */
--- 509,513 ----
/* make a new @VShift WORD out of the current contents of buff */
tmp = DoWord(buff, q, x, small_font);
! new_y = DoVShift(x, 0, tmp); /* XXX */
/* construct the skeleton of the result to replace x */
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 561,565 ****
/* make a new @VShift WORD out of the current contents of buff */
tmp = DoWord(buff, q, x, small_font);
! new_y = DoVShift(x, vshift, tmp);
/* link the new word into the growing structure that replaces x */
--- 559,563 ----
/* make a new @VShift WORD out of the current contents of buff */
tmp = DoWord(buff, q, x, small_font);
! new_y = DoVShift(x, 0, tmp); /* XXX */
/* link the new word into the growing structure that replaces x */
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 591,595 ****
/* make a new @VShift WORD and replace x with it */
tmp = DoWord(buff, q, x, small_font);
! new_x = DoVShift(x, vshift, tmp);
ReplaceNode(new_x, x);
Dispose(x);
--- 589,593 ----
/* make a new @VShift WORD and replace x with it */
tmp = DoWord(buff, q, x, small_font);
! new_x = DoVShift(x, 0, tmp); /* XXX */
ReplaceNode(new_x, x);
Dispose(x);
*************** OBJECT MapSmallCaps(OBJECT x, STYLE *sty
*** 613,617 ****
/* make a new @VShift WORD, add to new_acat, and replace x */
tmp = DoWord(buff, q, x, small_font);
! new_y = DoVShift(x, vshift, tmp);
Link(new_acat, new_y);
ReplaceNode(new_x, x);
--- 611,615 ----
/* make a new @VShift WORD, add to new_acat, and replace x */
tmp = DoWord(buff, q, x, small_font);
! new_y = DoVShift(x, 0, tmp); /* XXX */
Link(new_acat, new_y);
ReplaceNode(new_x, x);
--
Chip Salzenberg - a.k.a. - <address@hidden>
"When do you work?" "Whenever I'm not busy."
- 3.13: Word baselines,
Chip Salzenberg <=