• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

plfreetype.h

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

Generated on Wed Oct 12 2011 20:42:22 for PLplot by  doxygen 1.7.1