xref: /inferno-os/libfreetype/fttype1.c (revision 37da2899f40661e3e9631e497da8dc59b971cbd0)
1 /***************************************************************************/
2 /*                                                                         */
3 /*  fttype1.c                                                              */
4 /*                                                                         */
5 /*    FreeType utility file for PS names support (body).                   */
6 /*                                                                         */
7 /*  Copyright 2002 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_TYPE1_TYPES_H
21 #include FT_INTERNAL_TYPE42_TYPES_H
22 #include FT_INTERNAL_OBJECTS_H
23 
24 
25   /* documentation is in t1tables.h */
26 
27   FT_EXPORT_DEF( FT_Error )
FT_Get_PS_Font_Info(FT_Face face,PS_FontInfoRec * afont_info)28   FT_Get_PS_Font_Info( FT_Face          face,
29                        PS_FontInfoRec*  afont_info )
30   {
31     PS_FontInfo  font_info = NULL;
32     FT_Error     error     = FT_Err_Invalid_Argument;
33     const char*  driver_name;
34 
35 
36     if ( face && face->driver && face->driver->root.clazz )
37     {
38       driver_name = face->driver->root.clazz->module_name;
39       if ( ft_strcmp( driver_name, "type1" ) == 0 )
40         font_info = &((T1_Face)face)->type1.font_info;
41       else if ( ft_strcmp( driver_name, "t1cid" ) == 0 )
42         font_info = &((CID_Face)face)->cid.font_info;
43       else if ( ft_strcmp( driver_name, "type42" ) == 0 )
44         font_info = &((T42_Face)face)->type1.font_info;
45     }
46     if ( font_info != NULL )
47     {
48       *afont_info = *font_info;
49       error = FT_Err_Ok;
50     }
51 
52     return error;
53   }
54 
55 
56   /* XXX: Bad hack, but I didn't want to change several drivers here. */
57 
58   /* documentation is in t1tables.h */
59 
60   FT_EXPORT_DEF( FT_Int )
FT_Has_PS_Glyph_Names(FT_Face face)61   FT_Has_PS_Glyph_Names( FT_Face  face )
62   {
63     FT_Int       result = 0;
64     const char*  driver_name;
65 
66 
67     if ( face && face->driver && face->driver->root.clazz )
68     {
69       /* Currently, only the type1, type42, and cff drivers provide */
70       /* reliable glyph names...                                    */
71 
72       /* We could probably hack the TrueType driver to recognize    */
73       /* certain cases where the glyph names are most certainly     */
74       /* correct (e.g. using a 20 or 22 format `post' table), but   */
75       /* this will probably happen later...                         */
76 
77       driver_name = face->driver->root.clazz->module_name;
78       result      = ( ft_strcmp( driver_name, "type1"  ) == 0 ||
79                       ft_strcmp( driver_name, "type42" ) == 0 ||
80                       ft_strcmp( driver_name, "cff"    ) == 0 );
81     }
82 
83     return result;
84   }
85 
86 
87 /* END */
88