Disabling auto-refresh of game list by default, as it is causing bugs sometimes
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / pfr / pfrdrivr.c
blob15cca9854e4838384eac296d1d6589e335534e49
1 /***************************************************************************/
2 /* */
3 /* pfrdrivr.c */
4 /* */
5 /* FreeType PFR driver interface (body). */
6 /* */
7 /* Copyright 2002, 2003, 2004, 2006, 2008 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
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. */
15 /* */
16 /***************************************************************************/
19 #include <ft2build.h>
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
24 #include "pfrdrivr.h"
25 #include "pfrobjs.h"
27 #include "pfrerror.h"
30 FT_CALLBACK_DEF( FT_Error )
31 pfr_get_kerning( FT_Face pfrface, /* PFR_Face */
32 FT_UInt left,
33 FT_UInt right,
34 FT_Vector *avector )
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 );
54 return PFR_Err_Ok;
59 * PFR METRICS SERVICE
63 FT_CALLBACK_DEF( FT_Error )
64 pfr_get_advance( FT_Face pfrface, /* PFR_Face */
65 FT_UInt gindex,
66 FT_Pos *anadvance )
68 PFR_Face face = (PFR_Face)pfrface;
69 FT_Error error = PFR_Err_Invalid_Argument;
72 *anadvance = 0;
74 if ( !gindex )
75 goto Exit;
77 gindex--;
79 if ( face )
81 PFR_PhyFont phys = &face->phy_font;
84 if ( gindex < phys->num_chars )
86 *anadvance = phys->chars[gindex].advance;
87 error = 0;
91 Exit:
92 return error;
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;
115 x_scale = 0x10000L;
116 y_scale = 0x10000L;
118 if ( size )
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;
133 return PFR_Err_Ok;
137 FT_CALLBACK_TABLE_DEF
138 const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
140 pfr_get_metrics,
141 pfr_face_get_kerning,
142 pfr_get_advance
147 * SERVICE LIST
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 },
155 { NULL, NULL }
159 FT_CALLBACK_DEF( FT_Module_Interface )
160 pfr_get_service( FT_Module module,
161 const FT_String* service_id )
163 FT_UNUSED( module );
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 ),
178 "pfr",
179 0x10000L,
180 0x20000L,
182 NULL,
186 pfr_get_service
189 sizeof( PFR_FaceRec ),
190 sizeof( PFR_SizeRec ),
191 sizeof( PFR_SlotRec ),
193 pfr_face_init,
194 pfr_face_done,
195 0, /* FT_Size_InitFunc */
196 0, /* FT_Size_DoneFunc */
197 pfr_slot_init,
198 pfr_slot_done,
200 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
201 ft_stub_set_char_sizes,
202 ft_stub_set_pixel_sizes,
203 #endif
204 pfr_slot_load,
206 pfr_get_kerning,
207 0, /* FT_Face_AttachFunc */
208 0, /* FT_Face_GetAdvancesFunc */
209 0, /* FT_Size_RequestFunc */
210 0, /* FT_Size_SelectFunc */
214 /* END */