1 /**
2  ** BCC2GRX  -  Interfacing Borland based graphics programs to LIBGRX
3  ** Copyright (C) 1993-97 by Hartmut Schirmer
4  **
5  **
6  ** Contact :                Hartmut Schirmer
7  **                          Feldstrasse 118
8  **                  D-24105 Kiel
9  **                          Germany
10  **
11  ** e-mail : hsc@techfak.uni-kiel.de
12  **
13  ** This file is part of the GRX graphics library.
14  **
15  ** The GRX graphics library is free software; you can redistribute it
16  ** and/or modify it under some conditions; see the "copying.grx" file
17  ** for details.
18  **
19  ** This library is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22  **
23  **/
24 
25 #include "text.h"
26 
__gr_text_ChrFontInfo(void * Font,CharInfo * fntptr,int * height)27 int __gr_text_ChrFontInfo(void *Font, CharInfo *fntptr, int *height) {
28   int i, LstChar;
29   char *cp;
30   _ushort *Offsets;
31   uchar *Widths;
32   char *Data;
33   FontFileHeader *ffh;
34   FontHeaderTyp *fht;
35 
36   cp = (char *)Font;
37   i = 256;
38   while (*cp != '\x1a' ) { /* \x1a = ^Z */
39     ++cp;
40     --i;
41     if (i == 0)   /* Error, no ^Z at end of copyright */
42       return FALSE;
43   }
44   ++cp;
45   ffh = (FontFileHeader *)cp;
46   fht = (FontHeaderTyp *)((char *)Font + ffh->header_size);
47   if (fht->sig != '+')
48     return FALSE; /* Magic failed */
49   if (fht->scan_flag) {
50     /* font may have DO_SCAN op, anything we should do ? */
51   }
52   Offsets = (_ushort *)((char *)fht + sizeof(FontHeaderTyp));
53   Widths  = (uchar *)Offsets + 2 * (int)fht->nchrs;
54   Data    = (char *)Font + fht->cdefs + ffh->header_size;
55   LstChar = fht->firstch + fht->nchrs - 1;
56 
57   *height = (int)fht->org_to_cap - (int)fht->org_to_dec;
58   for (i=fht->firstch; i <= LstChar; ++i) {
59     fntptr[i].width = Widths[i - fht->firstch];
60     fntptr[i].cmd   = (_ushort *)(Data + Offsets[i - fht->firstch]);
61   }
62   return TRUE;
63 }
64 
65