/[freetype]/freetype2/src/sfnt/ttcmap.c
ViewVC logotype

Diff of /freetype2/src/sfnt/ttcmap.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.59 by olvaffe, Wed Nov 30 02:39:10 2005 UTC revision 1.60 by wl, Wed Nov 30 18:47:49 2005 UTC
# Line 700  Line 700 
700    }    }
701    
702    
703    /* find the index of the charcode next to cmap->cur_charcode; */    /* search the index of the charcode next to cmap->cur_charcode; */
704    /* caller should call tt_cmap4_set_range with proper range    */    /* caller should call tt_cmap4_set_range with proper range      */
705    /* before calling this function                               */    /* before calling this function                                 */
706    /*                                                            */    /*                                                              */
707    static void    static void
708    tt_cmap4_next( TT_CMap4  cmap )    tt_cmap4_next( TT_CMap4  cmap )
709    {    {
# Line 894  Line 894 
894              if ( last_start > start || last_end > end )              if ( last_start > start || last_end > end )
895                error |= TT_CMAP_FLAG_UNSORTED;                error |= TT_CMAP_FLAG_UNSORTED;
896              else              else
897                error |= TT_CMAP_FLAG_OVERLAPPED;                error |= TT_CMAP_FLAG_OVERLAPPING;
898            }            }
899          }          }
900    
# Line 947  Line 947 
947          }          }
948    
949          last_start = start;          last_start = start;
950          last_end = end;          last_end   = end;
951        }        }
952      }      }
953    
# Line 964  Line 964 
964      FT_Int     delta;      FT_Int     delta;
965      FT_UInt    i, num_segs;      FT_UInt    i, num_segs;
966      FT_UInt32  charcode = *pcharcode;      FT_UInt32  charcode = *pcharcode;
967      FT_UInt    gindex    = 0;      FT_UInt    gindex   = 0;
968      FT_Byte*   p;      FT_Byte*   p;
969    
970    
# Line 1029  Line 1029 
1029    
1030    
1031    static FT_UInt    static FT_UInt
1032    tt_cmap4_char_map_binary( TT_CMap     cmap,    tt_cmap4_char_map_binary( TT_CMap   cmap,
1033                              FT_UInt*    pcharcode,                              FT_UInt*  pcharcode,
1034                              FT_Bool     next )                              FT_Bool   next )
1035    {    {
1036      FT_UInt   num_segs2, start, end, offset;      FT_UInt   num_segs2, start, end, offset;
1037      FT_Int    delta;      FT_Int    delta;
1038      FT_UInt   max, min, mid, num_segs;      FT_UInt   max, min, mid, num_segs;
1039      FT_UInt   charcode = *pcharcode;      FT_UInt   charcode = *pcharcode;
1040      FT_UInt   gindex    = 0;      FT_UInt   gindex   = 0;
1041      FT_Byte*  p;      FT_Byte*  p;
1042            
1043    
# Line 1074  Line 1074 
1074          min = mid + 1;          min = mid + 1;
1075        else        else
1076        {        {
1077          p      += num_segs2;          p     += num_segs2;
1078          delta   = TT_PEEK_SHORT( p );          delta  = TT_PEEK_SHORT( p );
1079          p      += num_segs2;          p     += num_segs2;
1080          offset  = TT_PEEK_USHORT( p );          offset = TT_PEEK_USHORT( p );
1081    
1082          /* find the first segment containing `charcode' */          /* search the first segment containing `charcode' */
1083          if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPED )          if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPING )
1084          {          {
1085            FT_UInt  i;            FT_UInt  i;
1086    
# Line 1091  Line 1091 
1091            if ( offset == 0xFFFFU )            if ( offset == 0xFFFFU )
1092              mid = max + 1;              mid = max + 1;
1093    
1094            /* find in segments before the current segment */            /* search in segments before the current segment */
1095            for ( i = max ; i > 0; i-- )            for ( i = max ; i > 0; i-- )
1096            {            {
1097              FT_UInt  prev_end;              FT_UInt  prev_end;
# Line 1103  Line 1103 
1103              if ( charcode > prev_end )              if ( charcode > prev_end )
1104                break;                break;
1105    
1106              end     = prev_end;              end    = prev_end;
1107              p      += 2 + num_segs2;              p     += 2 + num_segs2;
1108              start   = TT_PEEK_USHORT( p );              start  = TT_PEEK_USHORT( p );
1109              p      += num_segs2;              p     += num_segs2;
1110              delta   = TT_PEEK_SHORT( p );              delta  = TT_PEEK_SHORT( p );
1111              p      += num_segs2;              p     += num_segs2;
1112              offset  = TT_PEEK_USHORT( p );              offset = TT_PEEK_USHORT( p );
1113    
1114              if ( offset != 0xFFFFU )              if ( offset != 0xFFFFU )
1115                mid = i - 1;                mid = i - 1;
# Line 1120  Line 1120 
1120            {            {
1121              if ( i != max )              if ( i != max )
1122              {              {
1123                p       = cmap->data + 14 + max * 2;                p      = cmap->data + 14 + max * 2;
1124                end     = TT_PEEK_USHORT( p );                end    = TT_PEEK_USHORT( p );
1125                p      += 2 + num_segs2;                p     += 2 + num_segs2;
1126                start   = TT_PEEK_USHORT( p );                start  = TT_PEEK_USHORT( p );
1127                p      += num_segs2;                p     += num_segs2;
1128                delta   = TT_PEEK_SHORT( p );                delta  = TT_PEEK_SHORT( p );
1129                p      += num_segs2;                p     += num_segs2;
1130                offset  = TT_PEEK_USHORT( p );                offset = TT_PEEK_USHORT( p );
1131              }              }
1132    
1133              mid = max;              mid = max;
1134    
1135              /* find in segments after the current segment */              /* search in segments after the current segment */
1136              for ( i = max + 1; i < num_segs; i++ )              for ( i = max + 1; i < num_segs; i++ )
1137              {              {
1138                FT_UInt  next_end, next_start;                FT_UInt  next_end, next_start;
1139    
1140    
1141                p           = cmap->data + 14 + i * 2;                p          = cmap->data + 14 + i * 2;
1142                next_end    = TT_PEEK_USHORT( p );                next_end   = TT_PEEK_USHORT( p );
1143                p          += 2 + num_segs2;                p         += 2 + num_segs2;
1144                next_start  = TT_PEEK_USHORT( p );                next_start = TT_PEEK_USHORT( p );
1145    
1146                if ( charcode < next_start )                if ( charcode < next_start )
1147                  break;                  break;
1148    
1149                end     = next_end;                end    = next_end;
1150                start   = next_start;                start  = next_start;
1151                p      += num_segs2;                p     += num_segs2;
1152                delta   = TT_PEEK_SHORT( p );                delta  = TT_PEEK_SHORT( p );
1153                p      += num_segs2;                p     += num_segs2;
1154                offset  = TT_PEEK_USHORT( p );                offset = TT_PEEK_USHORT( p );
1155    
1156                if ( offset != 0xFFFFU )                if ( offset != 0xFFFFU )
1157                  mid = i;                  mid = i;
# Line 1167  Line 1167 
1167              }              }
1168            }            }
1169    
1170            /* end, start, delta and offset are for the i'th segment */            /* end, start, delta, and offset are for the i'th segment */
1171            if ( mid != i )            if ( mid != i )
1172            {            {
1173              p       = cmap->data + 14 + mid * 2;              p      = cmap->data + 14 + mid * 2;
1174              end     = TT_PEEK_USHORT( p );              end    = TT_PEEK_USHORT( p );
1175              p      += 2 + num_segs2;              p     += 2 + num_segs2;
1176              start   = TT_PEEK_USHORT( p );              start  = TT_PEEK_USHORT( p );
1177              p      += num_segs2;              p     += num_segs2;
1178              delta   = TT_PEEK_SHORT( p );              delta  = TT_PEEK_SHORT( p );
1179              p      += num_segs2;              p     += num_segs2;
1180              offset  = TT_PEEK_USHORT( p );              offset = TT_PEEK_USHORT( p );
1181            }            }
1182          }          }
1183          else          else
# Line 1247  Line 1247 
1247    tt_cmap4_char_index( TT_CMap    cmap,    tt_cmap4_char_index( TT_CMap    cmap,
1248                         FT_UInt32  char_code )                         FT_UInt32  char_code )
1249    {    {
1250      if ( char_code >= 0x10000U )      if ( char_code >= 0x10000UL )
1251        return 0;        return 0;
1252    
1253      if ( cmap->flags & TT_CMAP_FLAG_UNSORTED )      if ( cmap->flags & TT_CMAP_FLAG_UNSORTED )
# Line 1927  Line 1927 
1927    
1928    FT_CALLBACK_DEF( FT_Error )    FT_CALLBACK_DEF( FT_Error )
1929    tt_cmap12_init( TT_CMap12  cmap,    tt_cmap12_init( TT_CMap12  cmap,
1930                    FT_Byte*  table )                    FT_Byte*   table )
1931    {    {
1932      cmap->cmap.data   = table;      cmap->cmap.data  = table;
1933    
1934      table            += 12;      table           += 12;
1935      cmap->num_groups  = FT_PEEK_ULONG( table );      cmap->num_groups = FT_PEEK_ULONG( table );
1936    
1937      cmap->valid       = 0;      cmap->valid      = 0;
1938    
1939      return SFNT_Err_Ok;      return SFNT_Err_Ok;
1940    }    }
# Line 1992  Line 1992 
1992    }    }
1993    
1994    
1995    /* find the index of the charcode next to cmap->cur_charcode */    /* search the index of the charcode next to cmap->cur_charcode */
1996    /* cmap->cur_group should be set up properly by caller       */    /* cmap->cur_group should be set up properly by caller         */
1997    /*                                                           */    /*                                                             */
1998    static void    static void
1999    tt_cmap12_next( TT_CMap12  cmap )    tt_cmap12_next( TT_CMap12  cmap )
2000    {    {
# Line 2071  Line 2071 
2071      while ( min < max )      while ( min < max )
2072      {      {
2073        mid = ( min + max ) >> 1;        mid = ( min + max ) >> 1;
2074        p = cmap->data + 16 + 12 * mid;        p   = cmap->data + 16 + 12 * mid;
2075    
2076        start    = TT_NEXT_ULONG( p );        start = TT_NEXT_ULONG( p );
2077        end      = TT_NEXT_ULONG( p );        end   = TT_NEXT_ULONG( p );
2078    
2079        if ( char_code < start )        if ( char_code < start )
2080          max = mid;          max = mid;
# Line 2105  Line 2105 
2105            return 0;            return 0;
2106        }        }
2107    
2108        cmap12->valid = 1;        cmap12->valid        = 1;
2109        cmap12->cur_charcode = char_code;        cmap12->cur_charcode = char_code;
2110        cmap12->cur_group = mid;        cmap12->cur_group    = mid;
2111    
2112        if ( !gindex )        if ( !gindex )
2113        {        {
# Line 2304  Line 2304 
2304                FT_CMap  ttcmap;                FT_CMap  ttcmap;
2305    
2306    
2307                if ( !FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, &ttcmap ) )                if ( !FT_CMap_New( (FT_CMap_Class)clazz,
2308                                     cmap, &charmap, &ttcmap ) )
2309                {                {
2310                  /* it is simpler to directly set `flags' than adding */                  /* it is simpler to directly set `flags' than adding */
2311                  /* a parameter to FT_CMap_New                        */                  /* a parameter to FT_CMap_New                        */

Legend:
Removed from v.1.59  
changed lines
  Added in v.1.60

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26