1 {*
2  * fontconfig/fontconfig/fontconfig.h
3  *
4  * Copyright © 2001 Keith Packard
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of Keith Packard not be used in
11  * advertising or publicity pertaining to distribution of the software without
12  * specific, written prior permission.  Keith Packard makes no
13  * representations about the suitability of this software for any purpose.  It
14  * is provided "as is" without express or implied warranty.
15  *
16  * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  *}
24 unit fontconfig;
25 
26 {$mode objfpc}{$H+}
27 {$packrecords c}
28 
29 interface
30 
31 uses
32   Classes, SysUtils, X, XLib, Xutil, ctypes;
33 
34 const
35   {$IF Defined(DARWIN)}
36     fclib = 'libfontconfig.dylib';
37     {$LINKLIB libfontconfig}
38   {$ELSE}
39     fclib = 'libfontconfig.so';
40   {$IFEND}
41 
42 //#define FcPublic
43 
44 type
45   FcChar8 = cuchar;
46   PFcChar8 = ^FcChar8;
47   FcChar16 = cushort;
48   FcChar32 = cuint;
49   FcBool = cint;
50 
51 const
52 {*
53  * Current Fontconfig version number.  This same number
54  * must appear in the fontconfig configure.in file. Yes,
55  * it'a a pain to synchronize version numbers like this.
56  *}
57 
58   FC_MAJOR	= 2;
59   FC_MINOR	= 8;
60   FC_REVISION = 0;
61 
62   FC_VERSION = ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION));
63 
64 {*
65  * Current font cache file format version
66  * This is appended to the cache files so that multiple
67  * versions of the library will peacefully coexist
68  *
69  * Change this value whenever the disk format for the cache file
70  * changes in any non-compatible way.  Try to avoid such changes as
71  * it means multiple copies of the font information.
72  *}
73 
74   FC_CACHE_VERSION   = '3';
75 
76   FcTrue	=	1;
77   FcFalse	=	0;
78 
79 const
80   FC_FAMILY =          'family';	//* String */
81   FC_STYLE =           'style';		//* String */
82   FC_SLANT =           'slant';		//* Int */
83   FC_WEIGHT =	       'weight';	//* Int */
84   FC_SIZE =	           'size';      //* Double */
85   FC_ASPECT =	       'aspect';	//* Double */
86   FC_PIXEL_SIZE =      'pixelsize';     //* Double */
87   FC_SPACING =	       'spacing';	//* Int */
88   FC_FOUNDRY =	       'foundry';	//* String */
89   FC_ANTIALIAS =       'antialias';	//* Bool (depends) */
90   FC_HINTING =	       'hinting';	//* Bool (true) */
91   FC_HINT_STYLE	=      'hintstyle';	//* Int */
92   FC_VERTICAL_LAYOUT = 'verticallayout';//* Bool (false) */
93   FC_AUTOHINT =	       'autohint';	//* Bool (false) */
94   FC_GLOBAL_ADVANCE =  'globaladvance';	//* Bool (true) */
95   FC_WIDTH=	       'width';		//* Int */
96   FC_FILE =	       'file';		//* String */
97   FC_INDEX =	       'index';		//* Int */
98   FC_FT_FACE =	       'ftface';	//* FT_Face */
99   FC_RASTERIZER =      'rasterizer';	//* String */
100   FC_OUTLINE =	       'outline';	//* Bool */
101   FC_SCALABLE =	       'scalable';	//* Bool */
102   FC_SCALE =	       'scale';		//* double */
103   FC_DPI =             'dpi';		//* double */
104   FC_RGBA =            'rgba';		//* Int */
105   FC_MINSPACE =	       'minspace';	//* Bool use minimum line spacing */
106   FC_SOURCE =	       'source';	//* String (X11, freetype) */
107   FC_CHARSET =	       'charset';	//* CharSet */
108   FC_LANG =            'lang';		//* String RFC 3066 langs */
109   FC_FONTVERSION =     'fontversion';	//* Int from 'head' table */
110   FC_FULLNAME =	       'fullname';	//* String */
111   FC_FAMILYLANG =      'familylang';	//* String RFC 3066 langs */
112   FC_STYLELANG =       'stylelang';	//* String RFC 3066 langs */
113   FC_FULLNAMELANG =    'fullnamelang';	//* String RFC 3066 langs */
114   FC_CAPABILITY =      'capability';	//* String */
115   FC_FONTFORMAT =      'fontformat';	//* String */
116   FC_EMBOLDEN =	       'embolden';	//* Bool - true if emboldening needed*/
117   FC_EMBEDDED_BITMAP = 'embeddedbitmap';//* Bool - true to enable embedded bitmaps */
118   FC_DECORATIVE =      'decorative';	//* Bool - true if style is a decorative variant */
119   FC_LCD_FILTER =      'lcdfilter';	//* Int */
120 
121   //FC_CACHE_SUFFIX		    ".cache-"FC_CACHE_VERSION
122   //FC_DIR_CACHE_FILE	    "fonts.cache-"FC_CACHE_VERSION
123   //FC_USER_CACHE_FILE	    ".fonts.cache-"FC_CACHE_VERSION
124 
125   // Adjust outline rasterizer */
126   FC_CHAR_WIDTH =      'charwidth'; // Int */
127   FC_CHAR_HEIGHT =      'charheight'; // Int */
128   FC_MATRIX =          'matrix';    //* FcMatrix */
129 
130   FC_WEIGHT_THIN = 0;
131   FC_WEIGHT_EXTRALIGHT =    40;
132   FC_WEIGHT_ULTRALIGHT =    FC_WEIGHT_EXTRALIGHT;
133   FC_WEIGHT_LIGHT =	    50;
134   FC_WEIGHT_BOOK =	    75;
135   FC_WEIGHT_REGULAR =	    80;
136   FC_WEIGHT_NORMAL =	    FC_WEIGHT_REGULAR;
137   FC_WEIGHT_MEDIUM =	    100;
138   FC_WEIGHT_DEMIBOLD =	    180;
139   FC_WEIGHT_SEMIBOLD =	    FC_WEIGHT_DEMIBOLD;
140   FC_WEIGHT_BOLD = 200;
141   FC_WEIGHT_EXTRABOLD =	    205;
142   FC_WEIGHT_ULTRABOLD =	    FC_WEIGHT_EXTRABOLD;
143   FC_WEIGHT_BLACK =	    210;
144   FC_WEIGHT_HEAVY =	    FC_WEIGHT_BLACK;
145   FC_WEIGHT_EXTRABLACK =    215;
146   FC_WEIGHT_ULTRABLACK =    FC_WEIGHT_EXTRABLACK;
147 
148   FC_SLANT_ROMAN =	    0;
149   FC_SLANT_ITALIC =	    100;
150   FC_SLANT_OBLIQUE =	    110;
151 
152   FC_WIDTH_ULTRACONDENSED =    50;
153   FC_WIDTH_EXTRACONDENSED =    63;
154   FC_WIDTH_CONDENSED =	    75;
155   FC_WIDTH_SEMICONDENSED =    87;
156   FC_WIDTH_NORMAL =	    100;
157   FC_WIDTH_SEMIEXPANDED =   113;
158   FC_WIDTH_EXPANDED =	    125;
159   FC_WIDTH_EXTRAEXPANDED =  150;
160   FC_WIDTH_ULTRAEXPANDED =  200;
161 
162   FC_PROPORTIONAL =	    0;
163   FC_DUAL =		    90;
164   FC_MONO = 100;
165   FC_CHARCELL =	    110;
166 
167   //* sub-pixel order */
168   FC_RGBA_UNKNOWN =	    0;
169   FC_RGBA_RGB =	    1;
170   FC_RGBA_BGR =	    2;
171   FC_RGBA_VRGB =	    3;
172   FC_RGBA_VBGR =	    4;
173   FC_RGBA_NONE =	    5;
174 
175   // hinting style */
176   FC_HINT_NONE =        0;
177   FC_HINT_SLIGHT =      1;
178   FC_HINT_MEDIUM =      2;
179   FC_HINT_FULL =        3;
180 
181   // LCD filter */
182   FC_LCD_NONE =	    0;
183   FC_LCD_DEFAULT =	    1;
184   FC_LCD_LIGHT =	    2;
185   FC_LCD_LEGACY =	    3;
186 
187 type
188   TFcType = Byte; // In C was a enum
189 
190 const
191   FcTypeVoid         = 0;
192   FcTypeInteger      = 1;
193   FcTypeDouble       = 2;
194   FcTypeString       = 3;
195   FcTypeBool         = 4;
196   FcTypeMatrix       = 5;
197   FcTypeCharSet      = 6;
198   FcTypeFTFace       = 7;
199   FcTypeLangSet      = 8;
200 
201 type
202   TFcMatrix = record
203     xx, xy, yx, yy: double;
204   end;
205 
206 //#define FcMatrixInit(m)	((m)->xx = (m)->yy = 1, \
207 //			 (m)->xy = (m)->yx = 0)
208 
209 {*
210  * A data structure to represent the available glyphs in a font.
211  * This is represented as a sparse boolean btree.
212  *}
213 
214   TFcCharSet = record
215     dummy : integer;
216   end;
217   PFcCharSet = ^TFcCharSet;
218 
219   TFcObjectType = record
220     object_: PChar;
221     type_: TFcType;
222   end;
223 
224   TFcConstant = record
225     name: PFcChar8;
226     object_: PChar;
227     value: cint;
228   end;
229 
230   TFcResult = (
231     FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId,
232     FcResultOutOfMemory);
233 
234   TFcPattern = record
235     dummy : integer;
236   end;
237 
238   PFcPattern = ^TFcPattern;
239   PPFcPattern = ^PFcPattern;
240 
241   TFcLangSet = record
242     dummy : integer;
243   end;
244 
245   TFcValue = record
246     type_: TFcType;
247     (*union {
248 	const FcChar8	*s;
249 	int		i;
250 	FcBool		b;
251 	double		d;
252 	const FcMatrix	*m;
253 	const FcCharSet	*c;
254 	void		*f;
255 	const FcLangSet	*l;
256     } u;*)
257   end;
258 
259   TFcFontSet = packed record
260     nfont : integer;
261     sfont : integer;
262     fonts : PPFcPattern;
263   end;
264   PFcFontSet = ^TFcFontSet;
265 
266 implementation
267 
268 end.
269 
270