PLplot  5.10.0
plfreetype.h
Go to the documentation of this file.
00001 //    Header file for Support routines for freetype font engine
00002 //
00003 //    See plfreetype.c for more details
00004 //
00005 //  Copyright (C) 2004  Andrew Roach
00006 //
00007 //  This file is part of PLplot.
00008 //
00009 //  PLplot is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Library General Public License as published
00011 //  by the Free Software Foundation; either version 2 of the License, or
00012 //  (at your option) any later version.
00013 //
00014 //  PLplot is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Library General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Library General Public License
00020 //  along with PLplot; if not, write to the Free Software
00021 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00022 //
00023 //
00024 //
00025 
00026 #ifndef __PLFREETY_H__
00027 #define __PLFREETY_H__
00028 
00029 #ifdef PL_HAVE_FREETYPE
00030 
00031 #include <ft2build.h>
00032 #include FT_FREETYPE_H
00033 #include FT_GLYPH_H
00034 #include FT_OUTLINE_H
00035 #include FT_MODULE_H
00036 
00037 #define FT_Data    _FT_Data_
00038 
00039 #ifndef GetGValue
00040 #define GetGValue( rgb )    ( (unsigned char) ( ( (unsigned short) ( rgb ) ) >> 8 ) )
00041 #endif
00042 #ifndef GetRValue
00043 #define GetRValue( rgb )    ( (unsigned char) ( rgb ) )
00044 #endif
00045 #ifndef GetBValue
00046 #define GetBValue( rgb )    ( (unsigned char) ( ( rgb ) >> 16 ) )
00047 #endif
00048 #ifndef RGB
00049 #define RGB( r, g, b )      ( ( ( r ) |          \
00050                                 ( ( g ) << 8 ) | \
00051                                 ( b ) << 16 ) )
00052 #endif
00053 
00054 typedef void ( *plD_pixel_fp )( PLStream *, PLINT, PLINT );
00055 typedef PLINT ( *plD_read_pixel_fp )( PLStream *, PLINT, PLINT );
00056 typedef PLINT ( *plD_set_pixel_fp )( PLStream *, PLINT, PLINT, PLINT );
00057 
00058 //--------------------------------------------------------------------------
00059 // Define the FT_Data data structure.
00060 //
00061 // These are the "globalish" variables used by Freetype
00062 // They are kept here so they are moderately thread safe, and stream specific
00063 //--------------------------------------------------------------------------
00064 
00065 typedef struct FT_Data
00066 {
00067     short x;
00068     short y;
00069 
00070     char  *textbuf;             // temporary string buffer
00071 
00072 //
00073 //  If set to 1, scale won't do anything, but this is an "arbitrary" scale
00074 //  factor for the transformation between virtual and real coordinates. This
00075 //  is included to fix up the problem with the "hidden line removal bug" of
00076 //  the 3D plots, which is fixed by providing a super-scaled image. This
00077 //  should be a mirror, for example, of dev->scale in the PNG driver. If I
00078 //  was thinking 12 months ahead, I would have put that scale factor in
00079 //  "pls", not "dev", but at this late stage, we can just live with it
00080 //  now...
00081 //
00082     PLFLT scale;
00083 
00084     //
00085     // If different scales are used for x and y, set the next variables instead
00086     // of scale.
00087     //
00088     PLFLT         scalex;
00089     PLFLT         scaley;
00090 
00091     unsigned char greek;
00092 
00093 //
00094 //  Set "invert_y" to 1 if the y coordinates need to be inverted for
00095 //  plotting. Most bitmaps will need this.
00096 //
00097     unsigned char invert_y;
00098 
00099 //
00100 //  ymax should be equal to, what it says - the maximum y coordinate of the
00101 //  bitmap. This is used in the process of calculating the inversion of the
00102 //  bitmap when invert_y is set to 1. If invert_y isn't set, this setting is
00103 //  ignored.
00104 //
00105     short             ymax;
00106 
00107 
00108     plD_pixel_fp      pixel;            // pointer to a function which draws a single pixel
00109     plD_set_pixel_fp  set_pixel;        // pointer to a function which draws a single pixel directly
00110     plD_read_pixel_fp read_pixel;       // pointer to a function which reads the RGB value of a pixel and returns it
00111 
00112 
00113     int want_smooth_text;               // flag to request text smoothing (won't
00114                                         // necessarily get it though
00115     int smooth_text;                    // Flag to indicate type of anti-aliasing used, if freetype text is active
00116 
00117 
00118 //
00119 //  List of font names and paths corresponding to the "predefined" fonts of
00120 //  plplot. 1024 chars is presumably generous for each one's length, but at
00121 //  least we probably won't get in trouble this way.
00122 //
00123 
00124     // 30 = five families * 3 styles * 2 weights = N_TrueTypeLookup
00125     char font_name[30][1024];
00126 
00127 //
00128 //  This is a mirror of pls->fci and is basically used for detecting when
00129 //  fonts have been changed .
00130 //
00131 
00132     PLUNICODE fci;
00133     PLFLT     chrht;                    // Mirror of pls's copy so we can detect when the font SIZE has been changed
00134     PLFLT     xdpi, ydpi;               // Mirror of pls's copy, so that we can detect, if resolution was changed
00135 
00136     FT_Matrix matrix;                   // used for rotating etc... the font.
00137     FT_Vector pos;                      // used for calculating offsets of text boxes/sizes
00138 
00139 
00140 //
00141 //  The next few variables hold the original size of CMAP0, the number of
00142 //  extra slots added for anti-aliasing, and the "width" of the table used
00143 //  for anti-aliasing.
00144 //
00145 
00146     PLINT ncol0_org;            // Original number of colours in CMAP0
00147     PLINT ncol0_xtra;           // number of extra colours defined in CMAP0 for anti-aliasing
00148     PLINT ncol0_width;          // Number of greyscale levels for each of the original colours
00149     PLINT last_icol0;           // Last colour in cmap0, which should be one of the originals
00150 
00151 
00152 //
00153 //  The rest of the variables should be considered very much PRIVATE, and
00154 //  more to the point, subject to change.
00155 //
00156 //  Don't rely on them existing in future versions of plplot's freetype
00157 //  support. If/when the Freetype cache manager is added to plplot, most, if
00158 //  not all, of these variables will move elsewhere.
00159 //
00160 
00161     FT_Library   library;               // pointer to freetype library
00162     FT_Face      face;                  // pointer to a font face
00163     FT_GlyphSlot slot;                  // pointer to a glyph slot
00164     FT_Glyph     image;                 // bitmap or outline image of font
00165 
00166     short        colour;                // depreciated ?? must check code
00167 
00168     PLINT        shade, col_idx;        // Used for antialiasing
00169 
00170 //
00171 //  If a driver is 24Bit, and supports reading pixel values as well as writing,
00172 //  we can use a more advanced antialiasing algorithm, which blends the text
00173 //  with the background. Set to 1 if you have this.
00174 //
00175     unsigned char BLENDED_ANTIALIASING;
00176 } FT_Data;
00177 
00178 
00179 #endif
00180 
00181 #endif // __PLFREETY_H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines