[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetype-devel
Subject:    [Devel] Radix numbers in type1 format
From:       Martin Muskens <mmuskens () aurelon ! com>
Date:       2001-08-30 11:37:29
[Download RAW message or body]

Hi all,

in the file psobjs.c the routine t1_toint is not (yet) suited for the use of
numbers in the radix format.
Instead of decimal number some fonts define their numbers in a radix format.
We have encountered a few.
For this purpose the next routine can be used to assist t1_toint. The
modification to t1_toint is also inbetween #ifdef AURELON:

Best regards
Martin Muskens

#ifdef AURELON
static FT_Long	T1Radix( FT_Long radixBase, FT_Byte** cur, FT_Byte* limit )
{
	FT_Long	result = 0;
	FT_Byte	radixEndChar0 = (FT_Byte)( radixBase > 10 ? '9' + 1 : '0' +
radixBase );
	FT_Byte	radixEndChar1 = (FT_Byte)( 'A' + radixBase - 10 );
	FT_Byte	radixEndChar2 = (FT_Byte)( 'a' + radixBase - 10 );
	while( *cur < limit )
	{
		if( (*cur)[0] >= '0' && (*cur)[0] < radixEndChar0 )
			result = result * radixBase + (*cur)[0] - '0';
		else if( radixBase > 10 && (*cur)[0] >= 'A' && (*cur)[0] <
radixEndChar1 )
			result = result * radixBase + ( (*cur)[0] - 'A' + 10
);
		else if( radixBase > 10 && (*cur)[0] >= 'a' && (*cur)[0] <
radixEndChar2 )
			result = result * radixBase + ( (*cur)[0] - 'a' + 10
);
		else
			return result;
		++(*cur);
	}
	return result;
}
#endif


  static FT_Long
  t1_toint( FT_Byte**  cursor,
            FT_Byte*   limit )
  {
    FT_Long   result = 0;
    FT_Byte*  cur    = *cursor;
    FT_Byte   c = '\0', d;


    for ( ; cur < limit; cur++ )
    {
      c = *cur;
      d = (FT_Byte)( c - '0' );
      if ( d < 10 )
        break;

      if ( c == '-' )
      {
        cur++;
        break;
      }
    }

    if ( cur < limit )
    {
      do
      {
        d = (FT_Byte)( cur[0] - '0' );
#ifdef AURELON
			if( d >= 10 )
			{
				if( cur[0] == '#' )
				{
					++cur;
					result = T1Radix( result, &cur,
limit );
				}
				break;
			}

#else
        if ( d >= 10 )
          break;
#endif

        result = result * 10 + d;
        cur++;

      } while ( cur < limit );

      if ( c == '-' )
        result = -result;
    }

    *cursor = cur;
    return result;
  }

_______________________________________________
Devel mailing list
Devel@freetype.org
http://www.freetype.org/mailman/listinfo/devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic