PLplot: plfreetype.h Source File

PLplot 5.10.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
plfreetype.h
Go to the documentation of this file.
1 // $Id: plfreetype.h 12334 2013-05-04 16:43:33Z airwin $
2 //
3 // Header file for Support routines for freetype font engine
4 //
5 // See plfreetype.c for more details
6 //
7 // Copyright (C) 2004 Andrew Roach
8 //
9 // This file is part of PLplot.
10 //
11 // PLplot is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published
13 // by the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
15 //
16 // PLplot is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with PLplot; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 //
26 //
27
28 #ifndef __PLFREETY_H__
29 #define __PLFREETY_H__
30
31 #ifdef PL_HAVE_FREETYPE
32
33 #include <ft2build.h>
34 #include FT_FREETYPE_H
35 #include FT_GLYPH_H
36 #include FT_OUTLINE_H
37 #include FT_MODULE_H
38
39 #define FT_Data _FT_Data_
40
41 #ifndef GetGValue
42 #define GetGValue( rgb ) ( (unsigned char) ( ( (unsigned short) ( rgb ) ) >> 8 ) )
43 #endif
44 #ifndef GetRValue
45 #define GetRValue( rgb ) ( (unsigned char) ( rgb ) )
46 #endif
47 #ifndef GetBValue
48 #define GetBValue( rgb ) ( (unsigned char) ( ( rgb ) >> 16 ) )
49 #endif
50 #ifndef RGB
51 #define RGB( r, g, b ) ( ( ( r ) | \
52 ( ( g ) << 8 ) | \
53 ( b ) << 16 ) )
54 #endif
55
56 typedef void ( *plD_pixel_fp )( PLStream *, PLINT, PLINT );
57 typedef PLINT ( *plD_read_pixel_fp )( PLStream *, PLINT, PLINT );
58 typedef PLINT ( *plD_set_pixel_fp )( PLStream *, PLINT, PLINT, PLINT );
59
60 //--------------------------------------------------------------------------
61 // Define the FT_Data data structure.
62 //
63 // These are the "globalish" variables used by Freetype
64 // They are kept here so they are moderately thread safe, and stream specific
65 //--------------------------------------------------------------------------
66
67 typedef struct FT_Data
68 {
69 short x;
70 short y;
71
72 char *textbuf; // temporary string buffer
73
74 //
75 // If set to 1, scale won't do anything, but this is an "arbitrary" scale
76 // factor for the transformation between virtual and real coordinates. This
77 // is included to fix up the problem with the "hidden line removal bug" of
78 // the 3D plots, which is fixed by providing a super-scaled image. This
79 // should be a mirror, for example, of dev->scale in the PNG driver. If I
80 // was thinking 12 months ahead, I would have put that scale factor in
81 // "pls", not "dev", but at this late stage, we can just live with it
82 // now...
83 //
84 PLFLT scale;
85
86 //
87 // If different scales are used for x and y, set the next variables instead
88 // of scale.
89 //
90 PLFLT scalex;
91 PLFLT scaley;
92
93 unsigned char greek;
94
95 //
96 // Set "invert_y" to 1 if the y coordinates need to be inverted for
97 // plotting. Most bitmaps will need this.
98 //
99 unsigned char invert_y;
100
101 //
102 // ymax should be equal to, what it says - the maximum y coordinate of the
103 // bitmap. This is used in the process of calculating the inversion of the
104 // bitmap when invert_y is set to 1. If invert_y isn't set, this setting is
105 // ignored.
106 //
107 short ymax;
108
109
110 plD_pixel_fp pixel; // pointer to a function which draws a single pixel
111 plD_set_pixel_fp set_pixel; // pointer to a function which draws a single pixel directly
112 plD_read_pixel_fp read_pixel; // pointer to a function which reads the RGB value of a pixel and returns it
113
114
115 int want_smooth_text; // flag to request text smoothing (won't
116 // necessarily get it though
117 int smooth_text; // Flag to indicate type of anti-aliasing used, if freetype text is active
118
119
120 //
121 // List of font names and paths corresponding to the "predefined" fonts of
122 // plplot. 1024 chars is presumably generous for each one's length, but at
123 // least we probably won't get in trouble this way.
124 //
125
126 // 30 = five families * 3 styles * 2 weights = N_TrueTypeLookup
127 char font_name[30][1024];
128
129 //
130 // This is a mirror of pls->fci and is basically used for detecting when
131 // fonts have been changed .
132 //
133
134 PLUNICODE fci;
135 PLFLT chrht; // Mirror of pls's copy so we can detect when the font SIZE has been changed
136 PLFLT xdpi, ydpi; // Mirror of pls's copy, so that we can detect, if resolution was changed
137
138 FT_Matrix matrix; // used for rotating etc... the font.
139 FT_Vector pos; // used for calculating offsets of text boxes/sizes
140
141
142 //
143 // The next few variables hold the original size of CMAP0, the number of
144 // extra slots added for anti-aliasing, and the "width" of the table used
145 // for anti-aliasing.
146 //
147
148 PLINT ncol0_org; // Original number of colours in CMAP0
149 PLINT ncol0_xtra; // number of extra colours defined in CMAP0 for anti-aliasing
150 PLINT ncol0_width; // Number of greyscale levels for each of the original colours
151 PLINT last_icol0; // Last colour in cmap0, which should be one of the originals
152
153
154 //
155 // The rest of the variables should be considered very much PRIVATE, and
156 // more to the point, subject to change.
157 //
158 // Don't rely on them existing in future versions of plplot's freetype
159 // support. If/when the Freetype cache manager is added to plplot, most, if
160 // not all, of these variables will move elsewhere.
161 //
162
163 FT_Library library; // pointer to freetype library
164 FT_Face face; // pointer to a font face
165 FT_GlyphSlot slot; // pointer to a glyph slot
166 FT_Glyph image; // bitmap or outline image of font
167
168 short colour; // depreciated ?? must check code
169
170 PLINT shade, col_idx; // Used for antialiasing
171
172 //
173 // If a driver is 24Bit, and supports reading pixel values as well as writing,
174 // we can use a more advanced antialiasing algorithm, which blends the text
175 // with the background. Set to 1 if you have this.
176 //
177 unsigned char BLENDED_ANTIALIASING;
178 } FT_Data;
179
180
181 #endif
182
183 #endif // __PLFREETY_H__