freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] CID CMap support


From: 山内 英敏
Subject: Re: [Freetype] CID CMap support
Date: Fri, 13 Jun 2003 22:26:32 +0900 (JST)

Hi Werner,

From: Werner LEMBERG <address@hidden>
Subject: Re: [Freetype] CID CMap support
Date: Thu, 12 Jun 2003 14:09:09 +0200 (CEST)

> > The CID font support in FreeType doesn't seem to include the ability
> > to read Adobe CMaps to create FreeType charmaps; num_charmaps is
> > always zero when a CIDFont with CMaps is read.
> 
> Correct.
> 
> > If so, is there a plan to support CID CMaps in the future?
> 
> It is planned to add it -- Hidetoshi, anything new?

I rewrite my code, but I have not finished yet because I am busy now.
I am sorry for waiting for a long time.

> Shall we wait for
> your code (in case you are working on it) or shall we try it
> ourselves?

I want to wait for a while but....

Here are patches to read CID CMaps.  But it is still alpha quality.
So there are so many bugs and the public API may be changed in near
future.

* We cannot use the usecmap operator because I rewrite this part now.
* We cannot use CID CMaps with 32bit range.
....

Any comments are welcomed.

Attachment: ft2_20030713_cidcmap_work_in_progress.diff.bz2
Description: Binary data

diff -ur /usr/local/work/FreeType/ft2demos/src/ftcommon.i 
ft2demos/src/ftcommon.i
--- /usr/local/work/FreeType/ft2demos/src/ftcommon.i    Sun Apr 27 13:00:39 2003
+++ ft2demos/src/ftcommon.i     Sun Apr 27 15:28:27 2003
@@ -183,6 +183,11 @@
 
   FT_Encoding  encoding = FT_ENCODING_NONE;
 
+#define MAXFILENAME 128
+#define MAXCMAPFILES 5
+  char cmapfiles[MAXCMAPFILES][MAXFILENAME];
+  int num_cmapfiles = 0;
+
   int  hinted    = 1;         /* is glyph hinting active?    */
   int  antialias = 1;         /* is anti-aliasing active?    */
   int  use_sbits = 1;         /* do we use embedded bitmaps? */
@@ -328,6 +333,27 @@
         }
       }
 
+      if ( num_cmapfiles )
+      {
+        int j;
+
+        for(j=0;j<num_cmapfiles;j++)
+        {
+          error = FT_Attach_File( face, cmapfiles[j] );
+          if ( error )
+          goto Bail_CMapFiles;
+        }
+
+        error = FT_Set_Charmap( face, face->charmaps[face->num_charmaps - 1] );
+        if ( error )
+        {
+        Bail_CMapFiles:
+          FT_Done_Face( face );
+          continue;
+        }
+        encoding = face->charmap->encoding;
+      }
+
       font = (PFont)malloc( sizeof ( *font ) );
       font->filepathname = (char*)malloc( strlen( filename ) + 1 );
       font->face_index   = i;
@@ -354,7 +380,7 @@
       default:
         font->num_indices = 0x10000L;
       }
-       
+        
       strcpy( (char*)font->filepathname, filename );
 
       FT_Done_Face( face );
@@ -400,9 +426,21 @@
                          font->filepathname,
                          font->face_index,
                          aface );
-    if ( encoding == FT_ENCODING_NONE || error )
+    if ( num_cmapfiles == 0 || encoding == FT_ENCODING_NONE || error )
       return error;
 
+    if ( num_cmapfiles )
+    {
+      int j;
+
+      for (j=0;j<num_cmapfiles;j++)
+      {
+        error = FT_Attach_File( *aface, cmapfiles[j] );
+        if (error)
+          return error;
+      }
+      return FT_Set_Charmap( *aface, (*aface)->charmaps[(*aface)->num_charmaps 
- 1]);
+    }
     return FT_Select_Charmap( *aface, encoding );
   }
 
@@ -507,9 +545,24 @@
 
     desc.face_id    = current_font.font.face_id;
 
-    desc.type       = FTC_CMAP_BY_ENCODING;
-    desc.u.encoding = encoding != FT_ENCODING_NONE ? encoding
-                                                   : FT_ENCODING_UNICODE;
+    if (num_cmapfiles)
+    {
+      FT_Error error;
+      FT_Face face;
+
+      error = FTC_Manager_Lookup_Face( cache_manager, desc.face_id, &face );
+      if (error)
+        return error;
+
+      desc.type       = FTC_CMAP_BY_INDEX;
+      desc.u.index = face->num_charmaps - 1;
+    }
+    else
+    {
+      desc.type       = FTC_CMAP_BY_ENCODING;
+      desc.u.encoding = encoding != FT_ENCODING_NONE ? encoding
+                                                     : FT_ENCODING_UNICODE;
+    }
 
     return FTC_CMapCache_Lookup( cmap_cache, &desc, charcode );
   }
diff -ur /usr/local/work/FreeType/ft2demos/src/ftview.c ft2demos/src/ftview.c
--- /usr/local/work/FreeType/ft2demos/src/ftview.c      Sun Apr 27 13:00:39 2003
+++ ft2demos/src/ftview.c       Sun Apr 27 15:28:34 2003
@@ -506,7 +506,7 @@
 
     while ( 1 )
     {
-      option = getopt( argc, argv, "Dde:f:l:r:" );
+      option = getopt( argc, argv, "Dde:f:l:r:C:" );
 
       if ( option == -1 )
         break;
@@ -539,6 +539,19 @@
         res = atoi( optarg );
         if ( res < 1 )
           usage( execname );
+        break;
+      case 'C':
+        if ( num_cmapfiles < MAXCMAPFILES )
+        {
+          if ( strlen( optarg ) > MAXFILENAME )
+            PanicZ( "cmap file name is too long" );
+
+          strcpy( cmapfiles[num_cmapfiles], optarg );
+        }
+        else
+          PanicZ( "too much cmap files" );
+
+        num_cmapfiles++;
         break;
 
       default:

reply via email to

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