1 /***************************************************************************/
5 /* FreeType PFR driver interface (body). */
7 /* Copyright 2002, 2003, 2004, 2006, 2008 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_SERVICE_PFR_H
23 #include FT_SERVICE_XFREE86_NAME_H
30 FT_CALLBACK_DEF( FT_Error
)
31 pfr_get_kerning( FT_Face pfrface
, /* PFR_Face */
36 PFR_Face face
= (PFR_Face
)pfrface
;
37 PFR_PhyFont phys
= &face
->phy_font
;
40 pfr_face_get_kerning( pfrface
, left
, right
, avector
);
42 /* convert from metrics to outline units when necessary */
43 if ( phys
->outline_resolution
!= phys
->metrics_resolution
)
45 if ( avector
->x
!= 0 )
46 avector
->x
= FT_MulDiv( avector
->x
, phys
->outline_resolution
,
47 phys
->metrics_resolution
);
49 if ( avector
->y
!= 0 )
50 avector
->y
= FT_MulDiv( avector
->x
, phys
->outline_resolution
,
51 phys
->metrics_resolution
);
63 FT_CALLBACK_DEF( FT_Error
)
64 pfr_get_advance( FT_Face pfrface
, /* PFR_Face */
68 PFR_Face face
= (PFR_Face
)pfrface
;
69 FT_Error error
= PFR_Err_Invalid_Argument
;
81 PFR_PhyFont phys
= &face
->phy_font
;
84 if ( gindex
< phys
->num_chars
)
86 *anadvance
= phys
->chars
[gindex
].advance
;
96 FT_CALLBACK_DEF( FT_Error
)
97 pfr_get_metrics( FT_Face pfrface
, /* PFR_Face */
98 FT_UInt
*anoutline_resolution
,
99 FT_UInt
*ametrics_resolution
,
100 FT_Fixed
*ametrics_x_scale
,
101 FT_Fixed
*ametrics_y_scale
)
103 PFR_Face face
= (PFR_Face
)pfrface
;
104 PFR_PhyFont phys
= &face
->phy_font
;
105 FT_Fixed x_scale
, y_scale
;
106 FT_Size size
= face
->root
.size
;
109 if ( anoutline_resolution
)
110 *anoutline_resolution
= phys
->outline_resolution
;
112 if ( ametrics_resolution
)
113 *ametrics_resolution
= phys
->metrics_resolution
;
120 x_scale
= FT_DivFix( size
->metrics
.x_ppem
<< 6,
121 phys
->metrics_resolution
);
123 y_scale
= FT_DivFix( size
->metrics
.y_ppem
<< 6,
124 phys
->metrics_resolution
);
127 if ( ametrics_x_scale
)
128 *ametrics_x_scale
= x_scale
;
130 if ( ametrics_y_scale
)
131 *ametrics_y_scale
= y_scale
;
137 FT_CALLBACK_TABLE_DEF
138 const FT_Service_PfrMetricsRec pfr_metrics_service_rec
=
141 pfr_face_get_kerning
,
151 static const FT_ServiceDescRec pfr_services
[] =
153 { FT_SERVICE_ID_PFR_METRICS
, &pfr_metrics_service_rec
},
154 { FT_SERVICE_ID_XF86_NAME
, FT_XF86_FORMAT_PFR
},
159 FT_CALLBACK_DEF( FT_Module_Interface
)
160 pfr_get_service( FT_Module module
,
161 const FT_String
* service_id
)
165 return ft_service_list_lookup( pfr_services
, service_id
);
169 FT_CALLBACK_TABLE_DEF
170 const FT_Driver_ClassRec pfr_driver_class
=
173 FT_MODULE_FONT_DRIVER
|
174 FT_MODULE_DRIVER_SCALABLE
,
176 sizeof( FT_DriverRec
),
189 sizeof( PFR_FaceRec
),
190 sizeof( PFR_SizeRec
),
191 sizeof( PFR_SlotRec
),
195 0, /* FT_Size_InitFunc */
196 0, /* FT_Size_DoneFunc */
200 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
201 ft_stub_set_char_sizes
,
202 ft_stub_set_pixel_sizes
,
207 0, /* FT_Face_AttachFunc */
208 0, /* FT_Face_GetAdvancesFunc */
209 0, /* FT_Size_RequestFunc */
210 0, /* FT_Size_SelectFunc */