00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <ft2build.h>
00020 #include FT_INTERNAL_DEBUG_H
00021 #include FT_INTERNAL_STREAM_H
00022 #include FT_SERVICE_PFR_H
00023 #include FT_SERVICE_XFREE86_NAME_H
00024 #include "pfrdrivr.h"
00025 #include "pfrobjs.h"
00026
00027 #include "pfrerror.h"
00028
00029
00030 FT_CALLBACK_DEF( FT_Error )
00031 pfr_get_kerning( FT_Face pfrface,
00032 FT_UInt left,
00033 FT_UInt right,
00034 FT_Vector *avector )
00035 {
00036 PFR_Face face = (PFR_Face)pfrface;
00037 PFR_PhyFont phys = &face->phy_font;
00038
00039
00040 pfr_face_get_kerning( pfrface, left, right, avector );
00041
00042
00043 if ( phys->outline_resolution != phys->metrics_resolution )
00044 {
00045 if ( avector->x != 0 )
00046 avector->x = FT_MulDiv( avector->x, phys->outline_resolution,
00047 phys->metrics_resolution );
00048
00049 if ( avector->y != 0 )
00050 avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
00051 phys->metrics_resolution );
00052 }
00053
00054 return PFR_Err_Ok;
00055 }
00056
00057
00058
00059
00060
00061
00062
00063 FT_CALLBACK_DEF( FT_Error )
00064 pfr_get_advance( FT_Face pfrface,
00065 FT_UInt gindex,
00066 FT_Pos *anadvance )
00067 {
00068 PFR_Face face = (PFR_Face)pfrface;
00069 FT_Error error = PFR_Err_Invalid_Argument;
00070
00071
00072 *anadvance = 0;
00073
00074 if ( !gindex )
00075 goto Exit;
00076
00077 gindex--;
00078
00079 if ( face )
00080 {
00081 PFR_PhyFont phys = &face->phy_font;
00082
00083
00084 if ( gindex < phys->num_chars )
00085 {
00086 *anadvance = phys->chars[gindex].advance;
00087 error = 0;
00088 }
00089 }
00090
00091 Exit:
00092 return error;
00093 }
00094
00095
00096 FT_CALLBACK_DEF( FT_Error )
00097 pfr_get_metrics( FT_Face pfrface,
00098 FT_UInt *anoutline_resolution,
00099 FT_UInt *ametrics_resolution,
00100 FT_Fixed *ametrics_x_scale,
00101 FT_Fixed *ametrics_y_scale )
00102 {
00103 PFR_Face face = (PFR_Face)pfrface;
00104 PFR_PhyFont phys = &face->phy_font;
00105 FT_Fixed x_scale, y_scale;
00106 FT_Size size = face->root.size;
00107
00108
00109 if ( anoutline_resolution )
00110 *anoutline_resolution = phys->outline_resolution;
00111
00112 if ( ametrics_resolution )
00113 *ametrics_resolution = phys->metrics_resolution;
00114
00115 x_scale = 0x10000L;
00116 y_scale = 0x10000L;
00117
00118 if ( size )
00119 {
00120 x_scale = FT_DivFix( size->metrics.x_ppem << 6,
00121 phys->metrics_resolution );
00122
00123 y_scale = FT_DivFix( size->metrics.y_ppem << 6,
00124 phys->metrics_resolution );
00125 }
00126
00127 if ( ametrics_x_scale )
00128 *ametrics_x_scale = x_scale;
00129
00130 if ( ametrics_y_scale )
00131 *ametrics_y_scale = y_scale;
00132
00133 return PFR_Err_Ok;
00134 }
00135
00136
00137 FT_CALLBACK_TABLE_DEF
00138 const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
00139 {
00140 pfr_get_metrics,
00141 pfr_face_get_kerning,
00142 pfr_get_advance
00143 };
00144
00145
00146
00147
00148
00149
00150
00151 static const FT_ServiceDescRec pfr_services[] =
00152 {
00153 { FT_SERVICE_ID_PFR_METRICS, &pfr_metrics_service_rec },
00154 { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_PFR },
00155 { NULL, NULL }
00156 };
00157
00158
00159 FT_CALLBACK_DEF( FT_Module_Interface )
00160 pfr_get_service( FT_Module module,
00161 const FT_String* service_id )
00162 {
00163 FT_UNUSED( module );
00164
00165 return ft_service_list_lookup( pfr_services, service_id );
00166 }
00167
00168
00169 FT_CALLBACK_TABLE_DEF
00170 const FT_Driver_ClassRec pfr_driver_class =
00171 {
00172 {
00173 FT_MODULE_FONT_DRIVER |
00174 FT_MODULE_DRIVER_SCALABLE,
00175
00176 sizeof( FT_DriverRec ),
00177
00178 "pfr",
00179 0x10000L,
00180 0x20000L,
00181
00182 NULL,
00183
00184 0,
00185 0,
00186 pfr_get_service
00187 },
00188
00189 sizeof( PFR_FaceRec ),
00190 sizeof( PFR_SizeRec ),
00191 sizeof( PFR_SlotRec ),
00192
00193 pfr_face_init,
00194 pfr_face_done,
00195 0,
00196 0,
00197 pfr_slot_init,
00198 pfr_slot_done,
00199
00200 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
00201 ft_stub_set_char_sizes,
00202 ft_stub_set_pixel_sizes,
00203 #endif
00204 pfr_slot_load,
00205
00206 pfr_get_kerning,
00207 0,
00208 0,
00209 0,
00210 0,
00211 };
00212
00213
00214