| 1 | /***************************************************************************/ |
|---|
| 2 | /* */ |
|---|
| 3 | /* ftpfr.c */ |
|---|
| 4 | /* */ |
|---|
| 5 | /* FreeType API for accessing PFR-specific data (body). */ |
|---|
| 6 | /* */ |
|---|
| 7 | /* Copyright 2002, 2003, 2004, 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 | /***************************************************************************/ |
|---|
| 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 | if ( !face ) |
|---|
| 50 | return FT_Err_Invalid_Argument; |
|---|
| 51 | |
|---|
| 52 | service = ft_pfr_check( face ); |
|---|
| 53 | if ( service ) |
|---|
| 54 | { |
|---|
| 55 | error = service->get_metrics( face, |
|---|
| 56 | aoutline_resolution, |
|---|
| 57 | ametrics_resolution, |
|---|
| 58 | ametrics_x_scale, |
|---|
| 59 | ametrics_y_scale ); |
|---|
| 60 | } |
|---|
| 61 | else |
|---|
| 62 | { |
|---|
| 63 | FT_Fixed x_scale, y_scale; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | /* this is not a PFR font */ |
|---|
| 67 | if ( aoutline_resolution ) |
|---|
| 68 | *aoutline_resolution = face->units_per_EM; |
|---|
| 69 | |
|---|
| 70 | if ( ametrics_resolution ) |
|---|
| 71 | *ametrics_resolution = face->units_per_EM; |
|---|
| 72 | |
|---|
| 73 | x_scale = y_scale = 0x10000L; |
|---|
| 74 | if ( face->size ) |
|---|
| 75 | { |
|---|
| 76 | x_scale = face->size->metrics.x_scale; |
|---|
| 77 | y_scale = face->size->metrics.y_scale; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | if ( ametrics_x_scale ) |
|---|
| 81 | *ametrics_x_scale = x_scale; |
|---|
| 82 | |
|---|
| 83 | if ( ametrics_y_scale ) |
|---|
| 84 | *ametrics_y_scale = y_scale; |
|---|
| 85 | |
|---|
| 86 | error = FT_Err_Unknown_File_Format; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | return error; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | /* documentation is in ftpfr.h */ |
|---|
| 94 | |
|---|
| 95 | FT_EXPORT_DEF( FT_Error ) |
|---|
| 96 | FT_Get_PFR_Kerning( FT_Face face, |
|---|
| 97 | FT_UInt left, |
|---|
| 98 | FT_UInt right, |
|---|
| 99 | FT_Vector *avector ) |
|---|
| 100 | { |
|---|
| 101 | FT_Error error; |
|---|
| 102 | FT_Service_PfrMetrics service; |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | if ( !face ) |
|---|
| 106 | return FT_Err_Invalid_Argument; |
|---|
| 107 | |
|---|
| 108 | service = ft_pfr_check( face ); |
|---|
| 109 | if ( service ) |
|---|
| 110 | error = service->get_kerning( face, left, right, avector ); |
|---|
| 111 | else |
|---|
| 112 | error = FT_Get_Kerning( face, left, right, |
|---|
| 113 | FT_KERNING_UNSCALED, avector ); |
|---|
| 114 | |
|---|
| 115 | return error; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | /* documentation is in ftpfr.h */ |
|---|
| 120 | |
|---|
| 121 | FT_EXPORT_DEF( FT_Error ) |
|---|
| 122 | FT_Get_PFR_Advance( FT_Face face, |
|---|
| 123 | FT_UInt gindex, |
|---|
| 124 | FT_Pos *aadvance ) |
|---|
| 125 | { |
|---|
| 126 | FT_Error error; |
|---|
| 127 | FT_Service_PfrMetrics service; |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | service = ft_pfr_check( face ); |
|---|
| 131 | if ( service ) |
|---|
| 132 | { |
|---|
| 133 | error = service->get_advance( face, gindex, aadvance ); |
|---|
| 134 | } |
|---|
| 135 | else |
|---|
| 136 | /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */ |
|---|
| 137 | error = FT_Err_Invalid_Argument; |
|---|
| 138 | |
|---|
| 139 | return error; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | /* END */ |
|---|