freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] FT_Get_PS_Font_Info()


From: Detlef Würkner
Subject: [Devel] FT_Get_PS_Font_Info()
Date: Thu, 20 Jun 2002 00:04:56 +0200

Hello!

The new function FT_Get_PS_Font_Info() does not work with T1CID and Type42
fonts. It follows a patch for that. Btw, is it necessary to copy the
structure instead of simply returning a pointer?

----8<----
--- freetype2-current/src/base/fttype1.c.ori    Mon Jun 10 23:03:35 2002
+++ freetype2-current/src/base/fttype1.c        Wed Jun 19 21:51:52 2002
@@ -18,49 +18,35 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_TYPE1_TYPES_H
+#include FT_INTERNAL_TYPE42_TYPES_H
 #include FT_INTERNAL_OBJECTS_H
 
 
-  /* Cast a FT_Face to a T1_Face if necessary.                           */
-  /* This implementation sucks, but a lot of things should change in the */
-  /* future anyway...                                                    */
-  /*                                                                     */
-  static T1_Face
-  t1_face_check_cast( FT_Face  face )
-  {
-    FT_Module  driver;
-    T1_Face    result = NULL;
-
-
-    if ( face && face->driver != NULL )
-    {
-      driver = (FT_Module)face->driver;
-
-      if ( driver->clazz && driver->clazz->module_name &&
-           ft_strcmp( driver->clazz->module_name, "type1" ) == 0 )
-      {
-        /* correct typecast! */
-        result = (T1_Face)face;
-      }
-    }
-    return result;
-  }
-
-
   /* documentation is in t1tables.h */
 
   FT_EXPORT_DEF( FT_Error )
   FT_Get_PS_Font_Info( FT_Face          face,
                        PS_FontInfoRec*  afont_info )
   {
-    FT_Error  error   = FT_Err_Invalid_Argument;
-    T1_Face   t1_face = t1_face_check_cast( face );
+    PS_FontInfo  font_info = NULL;
+    FT_Error     error     = FT_Err_Invalid_Argument;
+    const char*  driver_name;
 
 
-    if ( t1_face != NULL )
+    if ( face && face->driver && face->driver->root.clazz )
+    {
+      driver_name = face->driver->root.clazz->module_name;
+      if ( ft_strcmp( driver_name, "type1" ) == 0 )
+        font_info = &((T1_Face)face)->type1.font_info;
+      else if ( ft_strcmp( driver_name, "t1cid" ) == 0 )
+        font_info = &((CID_Face)face)->cid.font_info;
+      else if ( ft_strcmp( driver_name, "type42" ) == 0 )
+        font_info = &((T42_Face)face)->type42.font_info;
+    }
+    if ( font_info != NULL )
     {
-      *afont_info = t1_face->type1.font_info;
-      error       = FT_Err_Ok;
+      *afont_info = *font_info;
+      error = FT_Err_Ok;
     }
 
     return error;
----8<----

Ciao, Detlef
-- 
_ // address@hidden
\X/  Detlef Wuerkner, Langgoens/Germany



reply via email to

[Prev in Thread] Current Thread [Next in Thread]