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