ftpfr.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftpfr.c                                                                */
00004 /*                                                                         */
00005 /*    FreeType API for accessing PFR-specific data (body).                 */
00006 /*                                                                         */
00007 /*  Copyright 2002, 2003, 2004, 2008 by                                    */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 #include <ft2build.h>
00019 #include FT_INTERNAL_OBJECTS_H
00020 #include FT_SERVICE_PFR_H
00021 
00022 
00023   /* check the format */
00024   static FT_Service_PfrMetrics
00025   ft_pfr_check( FT_Face  face )
00026   {
00027     FT_Service_PfrMetrics  service;
00028 
00029 
00030     FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
00031 
00032     return service;
00033   }
00034 
00035 
00036   /* documentation is in ftpfr.h */
00037 
00038   FT_EXPORT_DEF( FT_Error )
00039   FT_Get_PFR_Metrics( FT_Face    face,
00040                       FT_UInt   *aoutline_resolution,
00041                       FT_UInt   *ametrics_resolution,
00042                       FT_Fixed  *ametrics_x_scale,
00043                       FT_Fixed  *ametrics_y_scale )
00044   {
00045     FT_Error               error = FT_Err_Ok;
00046     FT_Service_PfrMetrics  service;
00047 
00048 
00049     if ( !face )
00050       return FT_Err_Invalid_Argument;
00051 
00052     service = ft_pfr_check( face );
00053     if ( service )
00054     {
00055       error = service->get_metrics( face,
00056                                     aoutline_resolution,
00057                                     ametrics_resolution,
00058                                     ametrics_x_scale,
00059                                     ametrics_y_scale );
00060     }
00061     else
00062     {
00063       FT_Fixed  x_scale, y_scale;
00064 
00065 
00066       /* this is not a PFR font */
00067       if ( aoutline_resolution )
00068         *aoutline_resolution = face->units_per_EM;
00069 
00070       if ( ametrics_resolution )
00071         *ametrics_resolution = face->units_per_EM;
00072 
00073       x_scale = y_scale = 0x10000L;
00074       if ( face->size )
00075       {
00076         x_scale = face->size->metrics.x_scale;
00077         y_scale = face->size->metrics.y_scale;
00078       }
00079 
00080       if ( ametrics_x_scale )
00081         *ametrics_x_scale = x_scale;
00082 
00083       if ( ametrics_y_scale )
00084         *ametrics_y_scale = y_scale;
00085 
00086       error = FT_Err_Unknown_File_Format;
00087     }
00088 
00089     return error;
00090   }
00091 
00092 
00093   /* documentation is in ftpfr.h */
00094 
00095   FT_EXPORT_DEF( FT_Error )
00096   FT_Get_PFR_Kerning( FT_Face     face,
00097                       FT_UInt     left,
00098                       FT_UInt     right,
00099                       FT_Vector  *avector )
00100   {
00101     FT_Error               error;
00102     FT_Service_PfrMetrics  service;
00103 
00104 
00105     if ( !face )
00106       return FT_Err_Invalid_Argument;
00107 
00108     service = ft_pfr_check( face );
00109     if ( service )
00110       error = service->get_kerning( face, left, right, avector );
00111     else
00112       error = FT_Get_Kerning( face, left, right,
00113                               FT_KERNING_UNSCALED, avector );
00114 
00115     return error;
00116   }
00117 
00118 
00119   /* documentation is in ftpfr.h */
00120 
00121   FT_EXPORT_DEF( FT_Error )
00122   FT_Get_PFR_Advance( FT_Face   face,
00123                       FT_UInt   gindex,
00124                       FT_Pos   *aadvance )
00125   {
00126     FT_Error               error;
00127     FT_Service_PfrMetrics  service;
00128 
00129 
00130     service = ft_pfr_check( face );
00131     if ( service )
00132     {
00133       error = service->get_advance( face, gindex, aadvance );
00134     }
00135     else
00136       /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
00137       error = FT_Err_Invalid_Argument;
00138 
00139     return error;
00140   }
00141 
00142 
00143 /* END */

Generated on Tue Jul 5 14:13:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1