1 /***************************************************************************/
5 /* FreeType PFR driver interface (body). */
7 /* Copyright 2002 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
20 #include FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_STREAM_H
22 #include FT_INTERNAL_PFR_H
28 pfr_get_kerning( PFR_Face face,
35 error = pfr_face_get_kerning( face, left, right, avector );
38 PFR_PhyFont phys = &face->phy_font;
40 /* convert from metrics to outline units when necessary */
41 if ( phys->outline_resolution != phys->metrics_resolution )
43 if ( avector->x != 0 )
44 avector->x = FT_MulDiv( avector->x, phys->outline_resolution,
45 phys->metrics_resolution );
47 if ( avector->y != 0 )
48 avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
49 phys->metrics_resolution );
57 pfr_get_advance( PFR_Face face,
61 FT_Error error = FT_Err_Bad_Argument;
66 PFR_PhyFont phys = &face->phy_font;
68 if ( gindex < phys->num_chars )
70 *aadvance = phys->chars[ gindex ].advance;
80 pfr_get_metrics( PFR_Face face,
81 FT_UInt *aoutline_resolution,
82 FT_UInt *ametrics_resolution,
83 FT_Fixed *ametrics_x_scale,
84 FT_Fixed *ametrics_y_scale )
86 PFR_PhyFont phys = &face->phy_font;
87 FT_Fixed x_scale, y_scale;
88 FT_Size size = face->root.size;
90 if ( aoutline_resolution )
91 *aoutline_resolution = phys->outline_resolution;
93 if ( ametrics_resolution )
94 *ametrics_resolution = phys->metrics_resolution;
101 x_scale = FT_DivFix( size->metrics.x_ppem << 6,
102 phys->metrics_resolution );
104 y_scale = FT_DivFix( size->metrics.y_ppem << 6,
105 phys->metrics_resolution );
108 if ( ametrics_x_scale )
109 *ametrics_x_scale = x_scale;
111 if ( ametrics_y_scale )
112 *ametrics_y_scale = y_scale;
118 FT_CALLBACK_TABLE_DEF
119 const FT_PFR_ServiceRec pfr_service_rec =
121 (FT_PFR_GetMetricsFunc) pfr_get_metrics,
122 (FT_PFR_GetKerningFunc) pfr_get_kerning,
123 (FT_PFR_GetAdvanceFunc) pfr_get_advance
127 FT_CALLBACK_TABLE_DEF
128 const FT_Driver_ClassRec pfr_driver_class =
131 ft_module_font_driver |
132 ft_module_driver_scalable,
134 sizeof( FT_DriverRec ),
140 (FT_PFR_Service) &pfr_service_rec, /* format interface */
142 (FT_Module_Constructor)NULL,
143 (FT_Module_Destructor) NULL,
144 (FT_Module_Requester) NULL
147 sizeof( PFR_FaceRec ),
148 sizeof( PFR_SizeRec ),
149 sizeof( PFR_SlotRec ),
151 (FT_Face_InitFunc) pfr_face_init,
152 (FT_Face_DoneFunc) pfr_face_done,
153 (FT_Size_InitFunc) NULL,
154 (FT_Size_DoneFunc) NULL,
155 (FT_Slot_InitFunc) pfr_slot_init,
156 (FT_Slot_DoneFunc) pfr_slot_done,
158 (FT_Size_ResetPointsFunc) NULL,
159 (FT_Size_ResetPixelsFunc) NULL,
160 (FT_Slot_LoadFunc) pfr_slot_load,
162 (FT_Face_GetKerningFunc) pfr_get_kerning,
163 (FT_Face_AttachFunc) 0,
164 (FT_Face_GetAdvancesFunc) 0