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 #ifndef __BCC2GRX_TEXT_H__
26 #define __BCC2GRX_TEXT_H__
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <ctype.h>
31 
32 typedef unsigned char  uchar;
33 typedef   signed char  schar;
34 typedef unsigned short _ushort;
35 
36 #if defined(__TURBOC__) || (defined(_MSC_VER) && defined(_WIN32))
37 #include <io.h>
38 #else
39 #include <unistd.h>
40 #endif
41 #include "bccgrx00.h"
42 
43 #define FirstUserFont    11
44 #define LastUserFont     (FirstUserFont+9)
45 #define FirstGrxFont     (LastUserFont+1)
46 #define LastGrxFont      (FirstGrxFont+9)
47 #define NrFonts          (LastGrxFont+1)
48 #define PreSkip          0x080
49 
50 #ifdef __GNUC__
51 #define ZERO2ONE(chrsze) ((chrsze) ? : 1)
52 #else
53 #define ZERO2ONE(chrsze) ((chrsze) ? (chrsze) : 1)
54 #endif
55 
56 #define BITMAP(f) ((f)==DEFAULT_FONT || ((f)>=FirstGrxFont && (f)<=LastGrxFont))
57 
58 typedef struct {
59   uchar width;
60   _ushort *cmd;
61 } CharInfo;
62 
63 /* -------------------------------------------------------------- */
64 
65 typedef char FontNameTyp[4];
66 
67 #ifdef __GNUC__
68 #define PACKED __attribute ((packed))
69 #elif defined(_MSC_VER)
70 #pragma pack(push,1)
71 #endif
72 
73 #ifndef PACKED
74 #define PACKED
75 #endif
76 
77 typedef struct FontFileHeader {
78   _ushort     header_size PACKED;   /* Version 2.0 Header Format   */
79   FontNameTyp font_name   PACKED;   /* Font Internal Name          */
80   _ushort     font_size   PACKED;   /* filesize in byte            */
81   uchar       font_major  PACKED,   /* Driver Version Information  */
82 		  font_minor  PACKED;
83   uchar       min_major   PACKED,   /* BGI Revision Information    */
84 		  min_minor   PACKED;
85 } FontFileHeader;
86 
87 typedef struct FontHeaderTyp {
88   char    sig PACKED;            /* SIGNATURE byte                        */
89   _ushort nchrs PACKED;          /* number of characters in file          */
90   char    unused1 PACKED;        /* Currently Undefined                   */
91   uchar   firstch PACKED;        /* first character in file               */
92   _ushort cdefs PACKED;          /* offset to char definitions            */
93   uchar   scan_flag PACKED;      /* <> 0 if set is scanable               */
94   uchar   org_to_cap PACKED;     /* Height from origin to top of capitol  */
95   uchar   org_to_base PACKED;    /* Height from origin to baseline        */
96   schar   org_to_dec PACKED;     /* Height from origin to bot of decender */
97   uchar   unused2[0x5] PACKED;   /* Currently undefined                   */
98 } FontHeaderTyp;
99 
100 #undef PACKED
101 #if defined(_MSC_VER)
102 #pragma pack(pop)
103 #endif
104 
105 extern int  __gr_text_height;
106 extern int  __gr_text_multx, __gr_text_divx,
107 		__gr_text_multy, __gr_text_divy;
108 extern int  __gr_text_usr_multx, __gr_text_usr_divx,
109 		__gr_text_usr_multy, __gr_text_usr_divy;
110 
111 extern void *__gr_text_Fonts[];
112 #define Fonts __gr_text_Fonts
113 extern CharInfo *__gr_text_fntptr;
114 #define fntptr __gr_text_fntptr
115 extern char *__gr_text_StdFonts[];
116 #define StdFonts __gr_text_StdFonts
117 
118 extern GrTextOption __gr_text_style;
119 #define Style __gr_text_style
120 
121 extern struct textsettingstype __gr_text_setting;
122 #define TXT __gr_text_setting
123 
124 #ifdef GRX_VERSION
125 extern GrFont *__gr_text_DefaultFonts[11];
126 #define DefaultFonts __gr_text_DefaultFonts
127 #endif
128 
129 extern void __gr_text_init(void);
130 extern void __gr_text_vec(int *xx, int *yy, int XX, int YY, int len, uchar *textstring);
131 extern void __gr_text_bit(GrFont *fnt, int *xx, int *yy, int XX, int YY, int len, uchar *txt);
132 extern int  __gr_text_ChrFontInfo(void *Font, CharInfo *fntptr, int *height);
133 extern int  __gr_text_registerfont( int start, int stop, void *font);
134 extern int  __gr_text_installfont( int start, int stop, const char *name);
135 
136 extern int __gr_text_Width(int len, const char  *txt);
137 extern int __gr_text_Height(int len, const char *txt);
138 
139 #endif
140