~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/freetype/src/type1/t1driver.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************/
 
2
/*                                                                         */
 
3
/*  t1driver.c                                                             */
 
4
/*                                                                         */
 
5
/*    Type 1 driver interface (body).                                      */
 
6
/*                                                                         */
 
7
/*  Copyright 1996-2001, 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
 
 
19
#include <ft2build.h>
 
20
#include "t1driver.h"
 
21
#include "t1gload.h"
 
22
#include "t1load.h"
 
23
 
 
24
#include "t1errors.h"
 
25
 
 
26
#ifndef T1_CONFIG_OPTION_NO_AFM
 
27
#include "t1afm.h"
 
28
#endif
 
29
 
 
30
#include FT_INTERNAL_DEBUG_H
 
31
#include FT_INTERNAL_STREAM_H
 
32
 
 
33
#include FT_SERVICE_MULTIPLE_MASTERS_H
 
34
#include FT_SERVICE_GLYPH_DICT_H
 
35
#include FT_SERVICE_XFREE86_NAME_H
 
36
#include FT_SERVICE_POSTSCRIPT_NAME_H
 
37
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
 
38
#include FT_SERVICE_POSTSCRIPT_INFO_H
 
39
 
 
40
  /*************************************************************************/
 
41
  /*                                                                       */
 
42
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
 
43
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
 
44
  /* messages during execution.                                            */
 
45
  /*                                                                       */
 
46
#undef  FT_COMPONENT
 
47
#define FT_COMPONENT  trace_t1driver
 
48
 
 
49
 /*
 
50
  *  GLYPH DICT SERVICE
 
51
  *
 
52
  */
 
53
 
 
54
  static FT_Error
 
55
  t1_get_glyph_name( T1_Face     face,
 
56
                     FT_UInt     glyph_index,
 
57
                     FT_Pointer  buffer,
 
58
                     FT_UInt     buffer_max )
 
59
  {
 
60
    FT_String*  gname;
 
61
 
 
62
 
 
63
    gname = face->type1.glyph_names[glyph_index];
 
64
 
 
65
    if ( buffer_max > 0 )
 
66
    {
 
67
      FT_UInt  len = (FT_UInt)( ft_strlen( gname ) );
 
68
 
 
69
 
 
70
      if (len >= buffer_max)
 
71
        len = buffer_max - 1;
 
72
 
 
73
      FT_MEM_COPY( buffer, gname, len );
 
74
      ((FT_Byte*)buffer)[len] = 0;
 
75
    }
 
76
 
 
77
    return T1_Err_Ok;
 
78
  }
 
79
 
 
80
 
 
81
  static FT_UInt
 
82
  t1_get_name_index( T1_Face     face,
 
83
                     FT_String*  glyph_name )
 
84
  {
 
85
    FT_Int      i;
 
86
    FT_String*  gname;
 
87
 
 
88
 
 
89
    for ( i = 0; i < face->type1.num_glyphs; i++ )
 
90
    {
 
91
      gname = face->type1.glyph_names[i];
 
92
 
 
93
      if ( !ft_strcmp( glyph_name, gname ) )
 
94
        return (FT_UInt)i;
 
95
    }
 
96
 
 
97
    return 0;
 
98
  }
 
99
 
 
100
  static const FT_Service_GlyphDictRec  t1_service_glyph_dict =
 
101
  {
 
102
    (FT_GlyphDict_GetNameFunc)  t1_get_glyph_name,
 
103
    (FT_GlyphDict_NameIndexFunc)t1_get_name_index
 
104
  };
 
105
 
 
106
 
 
107
 /*
 
108
  *  POSTSCRIPT NAME SERVICE
 
109
  *
 
110
  */
 
111
 
 
112
  static const char*
 
113
  t1_get_ps_name( T1_Face  face )
 
114
  {
 
115
    return (const char*) face->type1.font_name;
 
116
  }
 
117
 
 
118
  static const FT_Service_PsFontNameRec  t1_service_ps_name =
 
119
  {
 
120
    (FT_PsName_GetFunc)t1_get_ps_name
 
121
  };
 
122
 
 
123
 
 
124
 /*
 
125
  *  MULTIPLE MASTERS SERVICE
 
126
  *
 
127
  */
 
128
 
 
129
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
 
130
  static const FT_Service_MultiMastersRec  t1_service_multi_masters =
 
131
  {
 
132
    (FT_Get_MM_Func)        T1_Get_Multi_Master,
 
133
    (FT_Set_MM_Design_Func) T1_Set_MM_Design,
 
134
    (FT_Set_MM_Blend_Func)  T1_Set_MM_Blend,
 
135
    (FT_Get_MM_Var_Func)    T1_Get_MM_Var,
 
136
    (FT_Set_Var_Design_Func)T1_Set_Var_Design
 
137
  };
 
138
#endif
 
139
 
 
140
 
 
141
 /*
 
142
  *  POSTSCRIPT INFO SERVICE
 
143
  *
 
144
  */
 
145
 
 
146
  static FT_Error
 
147
  t1_ps_get_font_info( FT_Face          face,
 
148
                       PS_FontInfoRec*  afont_info )
 
149
  {
 
150
    *afont_info = ((T1_Face)face)->type1.font_info;
 
151
    return 0;
 
152
  }
 
153
 
 
154
 
 
155
  static FT_Int
 
156
  t1_ps_has_glyph_names( FT_Face  face )
 
157
  {
 
158
    FT_UNUSED( face );
 
159
    return 1;
 
160
  }
 
161
 
 
162
 
 
163
  static const FT_Service_PsInfoRec  t1_service_ps_info =
 
164
  {
 
165
    (PS_GetFontInfoFunc)  t1_ps_get_font_info,
 
166
    (PS_HasGlyphNamesFunc)t1_ps_has_glyph_names
 
167
  };
 
168
 
 
169
 
 
170
 /*
 
171
  *  SERVICE LIST
 
172
  *
 
173
  */
 
174
 
 
175
  static const FT_ServiceDescRec  t1_services[] =
 
176
  {
 
177
    { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name },
 
178
    { FT_SERVICE_ID_GLYPH_DICT,           &t1_service_glyph_dict },
 
179
    { FT_SERVICE_ID_XF86_NAME,            FT_XF86_FORMAT_TYPE_1 },
 
180
    { FT_SERVICE_ID_POSTSCRIPT_INFO,      &t1_service_ps_info },
 
181
 
 
182
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
 
183
    { FT_SERVICE_ID_MULTI_MASTERS,        &t1_service_multi_masters },
 
184
#endif
 
185
    { NULL, NULL }
 
186
  };
 
187
 
 
188
 
 
189
  static FT_Module_Interface
 
190
  Get_Interface( FT_Driver         driver,
 
191
                 const FT_String*  t1_interface )
 
192
  {
 
193
    FT_UNUSED( driver );
 
194
 
 
195
    return ft_service_list_lookup( t1_services, t1_interface );
 
196
  }
 
197
 
 
198
 
 
199
#ifndef T1_CONFIG_OPTION_NO_AFM
 
200
 
 
201
  /*************************************************************************/
 
202
  /*                                                                       */
 
203
  /* <Function>                                                            */
 
204
  /*    Get_Kerning                                                        */
 
205
  /*                                                                       */
 
206
  /* <Description>                                                         */
 
207
  /*    A driver method used to return the kerning vector between two      */
 
208
  /*    glyphs of the same face.                                           */
 
209
  /*                                                                       */
 
210
  /* <Input>                                                               */
 
211
  /*    face        :: A handle to the source face object.                 */
 
212
  /*                                                                       */
 
213
  /*    left_glyph  :: The index of the left glyph in the kern pair.       */
 
214
  /*                                                                       */
 
215
  /*    right_glyph :: The index of the right glyph in the kern pair.      */
 
216
  /*                                                                       */
 
217
  /* <Output>                                                              */
 
218
  /*    kerning     :: The kerning vector.  This is in font units for      */
 
219
  /*                   scalable formats, and in pixels for fixed-sizes     */
 
220
  /*                   formats.                                            */
 
221
  /*                                                                       */
 
222
  /* <Return>                                                              */
 
223
  /*    FreeType error code.  0 means success.                             */
 
224
  /*                                                                       */
 
225
  /* <Note>                                                                */
 
226
  /*    Only horizontal layouts (left-to-right & right-to-left) are        */
 
227
  /*    supported by this function.  Other layouts, or more sophisticated  */
 
228
  /*    kernings are out of scope of this method (the basic driver         */
 
229
  /*    interface is meant to be simple).                                  */
 
230
  /*                                                                       */
 
231
  /*    They can be implemented by format-specific interfaces.             */
 
232
  /*                                                                       */
 
233
  static FT_Error
 
234
  Get_Kerning( T1_Face     face,
 
235
               FT_UInt     left_glyph,
 
236
               FT_UInt     right_glyph,
 
237
               FT_Vector*  kerning )
 
238
  {
 
239
    T1_AFM*  afm;
 
240
 
 
241
 
 
242
    kerning->x = 0;
 
243
    kerning->y = 0;
 
244
 
 
245
    afm = (T1_AFM*)face->afm_data;
 
246
    if ( afm )
 
247
      T1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
 
248
 
 
249
    return T1_Err_Ok;
 
250
  }
 
251
 
 
252
 
 
253
#endif /* T1_CONFIG_OPTION_NO_AFM */
 
254
 
 
255
 
 
256
  FT_CALLBACK_TABLE_DEF
 
257
  const FT_Driver_ClassRec  t1_driver_class =
 
258
  {
 
259
    {
 
260
      FT_MODULE_FONT_DRIVER       |
 
261
      FT_MODULE_DRIVER_SCALABLE   |
 
262
      FT_MODULE_DRIVER_HAS_HINTER,
 
263
 
 
264
      sizeof( FT_DriverRec ),
 
265
 
 
266
      "type1",
 
267
      0x10000L,
 
268
      0x20000L,
 
269
 
 
270
      0,   /* format interface */
 
271
 
 
272
      (FT_Module_Constructor)T1_Driver_Init,
 
273
      (FT_Module_Destructor) T1_Driver_Done,
 
274
      (FT_Module_Requester)  Get_Interface,
 
275
    },
 
276
 
 
277
    sizeof( T1_FaceRec ),
 
278
    sizeof( T1_SizeRec ),
 
279
    sizeof( T1_GlyphSlotRec ),
 
280
 
 
281
    (FT_Face_InitFunc)        T1_Face_Init,
 
282
    (FT_Face_DoneFunc)        T1_Face_Done,
 
283
    (FT_Size_InitFunc)        T1_Size_Init,
 
284
    (FT_Size_DoneFunc)        T1_Size_Done,
 
285
    (FT_Slot_InitFunc)        T1_GlyphSlot_Init,
 
286
    (FT_Slot_DoneFunc)        T1_GlyphSlot_Done,
 
287
 
 
288
    (FT_Size_ResetPointsFunc) T1_Size_Reset,
 
289
    (FT_Size_ResetPixelsFunc) T1_Size_Reset,
 
290
    (FT_Slot_LoadFunc)        T1_Load_Glyph,
 
291
 
 
292
#ifdef T1_CONFIG_OPTION_NO_AFM
 
293
    (FT_Face_GetKerningFunc)  0,
 
294
    (FT_Face_AttachFunc)      0,
 
295
#else
 
296
    (FT_Face_GetKerningFunc)  Get_Kerning,
 
297
    (FT_Face_AttachFunc)      T1_Read_AFM,
 
298
#endif
 
299
    (FT_Face_GetAdvancesFunc) 0
 
300
  };
 
301
 
 
302
 
 
303
/* END */