Sync to trunk (r46918)
[reactos.git] / lib / 3rdparty / freetype / src / base / ftpfr.c
1 /***************************************************************************/
2 /* */
3 /* ftpfr.c */
4 /* */
5 /* FreeType API for accessing PFR-specific data (body). */
6 /* */
7 /* Copyright 2002, 2003, 2004 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 /***************************************************************************/
17
18 #include <ft2build.h>
19 #include FT_INTERNAL_OBJECTS_H
20 #include FT_SERVICE_PFR_H
21
22
23 /* check the format */
24 static FT_Service_PfrMetrics
25 ft_pfr_check( FT_Face face )
26 {
27 FT_Service_PfrMetrics service;
28
29
30 FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
31
32 return service;
33 }
34
35
36 /* documentation is in ftpfr.h */
37
38 FT_EXPORT_DEF( FT_Error )
39 FT_Get_PFR_Metrics( FT_Face face,
40 FT_UInt *aoutline_resolution,
41 FT_UInt *ametrics_resolution,
42 FT_Fixed *ametrics_x_scale,
43 FT_Fixed *ametrics_y_scale )
44 {
45 FT_Error error = FT_Err_Ok;
46 FT_Service_PfrMetrics service;
47
48
49 service = ft_pfr_check( face );
50 if ( service )
51 {
52 error = service->get_metrics( face,
53 aoutline_resolution,
54 ametrics_resolution,
55 ametrics_x_scale,
56 ametrics_y_scale );
57 }
58 else if ( face )
59 {
60 FT_Fixed x_scale, y_scale;
61
62
63 /* this is not a PFR font */
64 *aoutline_resolution = face->units_per_EM;
65 *ametrics_resolution = face->units_per_EM;
66
67 x_scale = y_scale = 0x10000L;
68 if ( face->size )
69 {
70 x_scale = face->size->metrics.x_scale;
71 y_scale = face->size->metrics.y_scale;
72 }
73 *ametrics_x_scale = x_scale;
74 *ametrics_y_scale = y_scale;
75 }
76 else
77 error = FT_Err_Invalid_Argument;
78
79 return error;
80 }
81
82
83 /* documentation is in ftpfr.h */
84
85 FT_EXPORT_DEF( FT_Error )
86 FT_Get_PFR_Kerning( FT_Face face,
87 FT_UInt left,
88 FT_UInt right,
89 FT_Vector *avector )
90 {
91 FT_Error error;
92 FT_Service_PfrMetrics service;
93
94
95 service = ft_pfr_check( face );
96 if ( service )
97 error = service->get_kerning( face, left, right, avector );
98 else if ( face )
99 error = FT_Get_Kerning( face, left, right,
100 FT_KERNING_UNSCALED, avector );
101 else
102 error = FT_Err_Invalid_Argument;
103
104 return error;
105 }
106
107
108 /* documentation is in ftpfr.h */
109
110 FT_EXPORT_DEF( FT_Error )
111 FT_Get_PFR_Advance( FT_Face face,
112 FT_UInt gindex,
113 FT_Pos *aadvance )
114 {
115 FT_Error error;
116 FT_Service_PfrMetrics service;
117
118
119 service = ft_pfr_check( face );
120 if ( service )
121 {
122 error = service->get_advance( face, gindex, aadvance );
123 }
124 else
125 /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
126 error = FT_Err_Invalid_Argument;
127
128 return error;
129 }
130
131
132 /* END */