Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
pfrdrivr.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* pfrdrivr.c */
4 /* */
5 /* FreeType PFR driver interface (body). */
6 /* */
7 /* Copyright 2002-2004, 2006, 2008, 2010, 2011, 2013 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 
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"
26 
27 #include "pfrerror.h"
28 
29 
31  pfr_get_kerning( FT_Face pfrface, /* PFR_Face */
32  FT_UInt left,
33  FT_UInt right,
34  FT_Vector *avector )
35  {
36  PFR_Face face = (PFR_Face)pfrface;
37  PFR_PhyFont phys = &face->phy_font;
38 
39 
40  pfr_face_get_kerning( pfrface, left, right, avector );
41 
42  /* convert from metrics to outline units when necessary */
43  if ( phys->outline_resolution != phys->metrics_resolution )
44  {
45  if ( avector->x != 0 )
46  avector->x = FT_MulDiv( avector->x, phys->outline_resolution,
47  phys->metrics_resolution );
48 
49  if ( avector->y != 0 )
50  avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
51  phys->metrics_resolution );
52  }
53 
54  return FT_Err_Ok;
55  }
56 
57 
58  /*
59  * PFR METRICS SERVICE
60  *
61  */
62 
64  pfr_get_advance( FT_Face pfrface, /* PFR_Face */
65  FT_UInt gindex,
66  FT_Pos *anadvance )
67  {
68  PFR_Face face = (PFR_Face)pfrface;
69  FT_Error error = FT_ERR( Invalid_Argument );
70 
71 
72  *anadvance = 0;
73 
74  if ( !gindex )
75  goto Exit;
76 
77  gindex--;
78 
79  if ( face )
80  {
81  PFR_PhyFont phys = &face->phy_font;
82 
83 
84  if ( gindex < phys->num_chars )
85  {
86  *anadvance = phys->chars[gindex].advance;
87  error = FT_Err_Ok;
88  }
89  }
90 
91  Exit:
92  return error;
93  }
94 
95 
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 )
102  {
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;
107 
108 
109  if ( anoutline_resolution )
110  *anoutline_resolution = phys->outline_resolution;
111 
112  if ( ametrics_resolution )
113  *ametrics_resolution = phys->metrics_resolution;
114 
115  x_scale = 0x10000L;
116  y_scale = 0x10000L;
117 
118  if ( size )
119  {
120  x_scale = FT_DivFix( size->metrics.x_ppem << 6,
121  phys->metrics_resolution );
122 
123  y_scale = FT_DivFix( size->metrics.y_ppem << 6,
124  phys->metrics_resolution );
125  }
126 
127  if ( ametrics_x_scale )
128  *ametrics_x_scale = x_scale;
129 
130  if ( ametrics_y_scale )
131  *ametrics_y_scale = y_scale;
132 
133  return FT_Err_Ok;
134  }
135 
136 
138  const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
139  {
143  };
144 
145 
146  /*
147  * SERVICE LIST
148  *
149  */
150 
151  static const FT_ServiceDescRec pfr_services[] =
152  {
155  { NULL, NULL }
156  };
157 
158 
161  const FT_String* service_id )
162  {
163  FT_UNUSED( module );
164 
165  return ft_service_list_lookup( pfr_services, service_id );
166  }
167 
168 
171  {
172  {
175 
176  sizeof ( FT_DriverRec ),
177 
178  "pfr",
179  0x10000L,
180  0x20000L,
181 
182  NULL,
183 
184  0, /* FT_Module_Constructor */
185  0, /* FT_Module_Destructor */
187  },
188 
189  sizeof ( PFR_FaceRec ),
190  sizeof ( PFR_SizeRec ),
191  sizeof ( PFR_SlotRec ),
192 
195  0, /* FT_Size_InitFunc */
196  0, /* FT_Size_DoneFunc */
199 
200 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
201  ft_stub_set_char_sizes,
202  ft_stub_set_pixel_sizes,
203 #endif
205 
207  0, /* FT_Face_AttachFunc */
208  0, /* FT_Face_GetAdvancesFunc */
209  0, /* FT_Size_RequestFunc */
210  0, /* FT_Size_SelectFunc */
211  };
212 
213 
214 /* END */
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
Definition: ftobjs.c:58
int FT_Error
Definition: fttypes.h:296
pfr_get_advance(FT_Face pfrface, FT_UInt gindex, FT_Pos *anadvance)
Definition: pfrdrivr.c:64
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:586
#define FT_XF86_FORMAT_PFR
Definition: svxf86nm.h:43
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
pfr_face_get_kerning(FT_Face pfrface, FT_UInt glyph1, FT_UInt glyph2, FT_Vector *kerning)
Definition: pfrobjs.c:465
#define NULL
Definition: ftobjs.h:61
pfr_slot_init(FT_GlyphSlot pfrslot)
Definition: pfrobjs.c:290
#define FT_UNUSED(arg)
Definition: ftconfig.h:76
pfr_slot_load(FT_GlyphSlot pfrslot, FT_Size pfrsize, FT_UInt gindex, FT_Int32 load_flags)
Definition: pfrobjs.c:313
pfr_face_init(FT_Stream stream, FT_Face pfrface, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
Definition: pfrobjs.c:67
#define FT_MODULE_DRIVER_SCALABLE
Definition: ftmodapi.h:87
return FT_Err_Ok
Definition: ftbbox.c:645
pfr_face_done(FT_Face pfrface)
Definition: pfrobjs.c:43
GLenum GLuint GLint GLenum face
#define const
Definition: zconf.h:91
pfr_get_metrics(FT_Face pfrface, FT_UInt *anoutline_resolution, FT_UInt *ametrics_resolution, FT_Fixed *ametrics_x_scale, FT_Fixed *ametrics_y_scale)
Definition: pfrdrivr.c:97
FT_UInt metrics_resolution
Definition: pfrtypes.h:229
GLdouble GLdouble right
pfr_get_kerning(FT_Face pfrface, FT_UInt left, FT_UInt right, FT_Vector *avector)
Definition: pfrdrivr.c:31
GLint left
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:412
#define FT_ERR(e)
Definition: fttypes.h:582
FT_Error error
Definition: cffdrivr.c:411
#define FT_SERVICE_ID_PFR_METRICS
Definition: svpfr.h:29
#define FT_SERVICE_ID_XF86_NAME
Definition: svxf86nm.h:34
char FT_String
Definition: fttypes.h:183
FT_Pointer FT_Module_Interface
Definition: ftmodapi.h:106
PFR_Char chars
Definition: pfrtypes.h:256
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:323
pfr_get_service(FT_Module module, const FT_String *service_id)
Definition: pfrdrivr.c:160
FT_UShort x_ppem
Definition: freetype.h:1369
#define FT_MODULE_FONT_DRIVER
Definition: ftmodapi.h:82
pfr_slot_done(FT_GlyphSlot pfrslot)
Definition: pfrobjs.c:303
#define FT_CALLBACK_TABLE_DEF
Definition: ftconfig.h:333
struct PFR_SizeRec_ PFR_SizeRec
signed long FT_Fixed
Definition: fttypes.h:284
FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec pfr_driver_class
Definition: pfrdrivr.c:170
unsigned int FT_UInt
Definition: fttypes.h:227
FT_Int advance
Definition: pfrtypes.h:175
typedefFT_BEGIN_HEADER struct PFR_FaceRec_ * PFR_Face
Definition: pfrobjs.h:27
FT_CALLBACK_TABLE_DEF const FT_Service_PfrMetricsRec pfr_metrics_service_rec
Definition: pfrdrivr.c:138
struct FT_DriverRec_ FT_DriverRec
FT_UInt outline_resolution
Definition: pfrtypes.h:228
GLsizeiptr size
FT_Size_Metrics metrics
Definition: freetype.h:1406
FT_UShort y_ppem
Definition: freetype.h:1370