diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2015-11-02 07:10:28 +0400 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2015-11-03 16:21:10 +0000 |
commit | dba44cd4e5754b579f2184a864ffe7b79b0a7e56 (patch) | |
tree | c8829051b16c8a78f049fb05bae9322293143c91 /src/3rdparty/freetype/src/bdf/bdflib.c | |
parent | e056be144a0207699b42a01b6d4cb6f19be474d7 (diff) |
Update bundled FreeType to 2.6.1
Change-Id: Ic489f8aa8ad42da3922f542e6c9064afe44f3799
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/3rdparty/freetype/src/bdf/bdflib.c')
-rw-r--r-- | src/3rdparty/freetype/src/bdf/bdflib.c | 160 |
1 files changed, 101 insertions, 59 deletions
diff --git a/src/3rdparty/freetype/src/bdf/bdflib.c b/src/3rdparty/freetype/src/bdf/bdflib.c index abcfdee7be..414deb58ad 100644 --- a/src/3rdparty/freetype/src/bdf/bdflib.c +++ b/src/3rdparty/freetype/src/bdf/bdflib.c @@ -243,7 +243,7 @@ /* Mocklisp hash function. */ while ( *kp ) - res = ( res << 5 ) - res + *kp++; + res = ( res << 5 ) - res + (unsigned long)*kp++; ndp = bp + ( res % ht->size ); while ( *ndp ) @@ -264,9 +264,9 @@ hash_rehash( hashtable* ht, FT_Memory memory ) { - hashnode* obp = ht->table, *bp, *nbp; - int i, sz = ht->size; - FT_Error error = FT_Err_Ok; + hashnode* obp = ht->table, *bp, *nbp; + unsigned int i, sz = ht->size; + FT_Error error = FT_Err_Ok; ht->size <<= 1; @@ -294,8 +294,8 @@ hash_init( hashtable* ht, FT_Memory memory ) { - int sz = INITIAL_HT_SIZE; - FT_Error error = FT_Err_Ok; + unsigned int sz = INITIAL_HT_SIZE; + FT_Error error = FT_Err_Ok; ht->size = sz; @@ -316,8 +316,8 @@ { if ( ht != 0 ) { - int i, sz = ht->size; - hashnode* bp = ht->table; + unsigned int i, sz = ht->size; + hashnode* bp = ht->table; for ( i = 0; i < sz; i++, bp++ ) @@ -570,10 +570,11 @@ char* line, unsigned long linelen ) { - int mult, final_empty; - char *sp, *ep, *end; - char seps[32]; - FT_Error error = FT_Err_Ok; + unsigned long final_empty; + int mult; + char *sp, *ep, *end; + char seps[32]; + FT_Error error = FT_Err_Ok; /* Initialize the list. */ @@ -682,7 +683,7 @@ unsigned long lineno, buf_size; int refill, hold, to_skip; ptrdiff_t bytes, start, end, cursor, avail; - char* buf = 0; + char* buf = NULL; FT_Memory memory = stream->memory; FT_Error error = FT_Err_Ok; @@ -715,7 +716,7 @@ { bytes = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor, - (FT_ULong)( buf_size - cursor ) ); + buf_size - (unsigned long)cursor ); avail = cursor + bytes; cursor = 0; refill = 0; @@ -760,7 +761,7 @@ if ( FT_RENEW_ARRAY( buf, buf_size, new_size ) ) goto Exit; - cursor = buf_size; + cursor = (ptrdiff_t)buf_size; buf_size = new_size; } else @@ -858,9 +859,9 @@ /* Routine to convert an ASCII string into an unsigned long integer. */ static unsigned long - _bdf_atoul( char* s, - char** end, - int base ) + _bdf_atoul( char* s, + char** end, + unsigned int base ) { unsigned long v; const unsigned char* dmap; @@ -903,7 +904,7 @@ } - /* Routine to convert an ASCII string into an signed long integer. */ + /* Routine to convert an ASCII string into a signed long integer. */ static long _bdf_atol( char* s, char** end, @@ -958,7 +959,54 @@ } - /* Routine to convert an ASCII string into an signed short integer. */ + /* Routine to convert an ASCII string into an unsigned short integer. */ + static unsigned short + _bdf_atous( char* s, + char** end, + unsigned int base ) + { + unsigned short v; + const unsigned char* dmap; + + + if ( s == 0 || *s == 0 ) + return 0; + + /* Make sure the radix is something recognizable. Default to 10. */ + switch ( base ) + { + case 8: + dmap = odigits; + break; + case 16: + dmap = hdigits; + break; + default: + base = 10; + dmap = ddigits; + break; + } + + /* Check for the special hex prefix. */ + if ( *s == '0' && + ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) ) + { + base = 16; + dmap = hdigits; + s += 2; + } + + for ( v = 0; sbitset( dmap, *s ); s++ ) + v = (unsigned short)( v * base + a2i[(int)*s] ); + + if ( end != 0 ) + *end = s; + + return v; + } + + + /* Routine to convert an ASCII string into a signed short integer. */ static short _bdf_atos( char* s, char** end, @@ -1115,20 +1163,20 @@ /* Parse flags. */ -#define _BDF_START 0x0001 -#define _BDF_FONT_NAME 0x0002 -#define _BDF_SIZE 0x0004 -#define _BDF_FONT_BBX 0x0008 -#define _BDF_PROPS 0x0010 -#define _BDF_GLYPHS 0x0020 -#define _BDF_GLYPH 0x0040 -#define _BDF_ENCODING 0x0080 -#define _BDF_SWIDTH 0x0100 -#define _BDF_DWIDTH 0x0200 -#define _BDF_BBX 0x0400 -#define _BDF_BITMAP 0x0800 - -#define _BDF_SWIDTH_ADJ 0x1000 +#define _BDF_START 0x0001U +#define _BDF_FONT_NAME 0x0002U +#define _BDF_SIZE 0x0004U +#define _BDF_FONT_BBX 0x0008U +#define _BDF_PROPS 0x0010U +#define _BDF_GLYPHS 0x0020U +#define _BDF_GLYPH 0x0040U +#define _BDF_ENCODING 0x0080U +#define _BDF_SWIDTH 0x0100U +#define _BDF_DWIDTH 0x0200U +#define _BDF_BBX 0x0400U +#define _BDF_BITMAP 0x0800U + +#define _BDF_SWIDTH_ADJ 0x1000U #define _BDF_GLYPH_BITS ( _BDF_GLYPH | \ _BDF_ENCODING | \ @@ -1703,7 +1751,7 @@ glyph->encoding = p->glyph_enc; /* Reset the initial glyph info. */ - p->glyph_name = 0; + p->glyph_name = NULL; } else { @@ -1724,14 +1772,14 @@ glyph = font->unencoded + font->unencoded_used; glyph->name = p->glyph_name; - glyph->encoding = font->unencoded_used++; + glyph->encoding = (long)font->unencoded_used++; } else /* Free up the glyph name if the unencoded shouldn't be */ /* kept. */ FT_FREE( p->glyph_name ); - p->glyph_name = 0; + p->glyph_name = NULL; } /* Clear the flags that might be added when width and height are */ @@ -1864,8 +1912,8 @@ if ( error ) goto Exit; - glyph->bbx.width = _bdf_atos( p->list.field[1], 0, 10 ); - glyph->bbx.height = _bdf_atos( p->list.field[2], 0, 10 ); + glyph->bbx.width = _bdf_atous( p->list.field[1], 0, 10 ); + glyph->bbx.height = _bdf_atous( p->list.field[2], 0, 10 ); glyph->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 ); glyph->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 ); @@ -2225,8 +2273,8 @@ if ( error ) goto Exit; - p->font->bbx.width = _bdf_atos( p->list.field[1], 0, 10 ); - p->font->bbx.height = _bdf_atos( p->list.field[2], 0, 10 ); + p->font->bbx.width = _bdf_atous( p->list.field[1], 0, 10 ); + p->font->bbx.height = _bdf_atous( p->list.field[2], 0, 10 ); p->font->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 ); p->font->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 ); @@ -2298,29 +2346,23 @@ /* Check for the bits per pixel field. */ if ( p->list.used == 5 ) { - unsigned short bitcount, i, shift; + unsigned short bpp; - p->font->bpp = (unsigned short)_bdf_atos( p->list.field[4], 0, 10 ); + bpp = (unsigned short)_bdf_atos( p->list.field[4], 0, 10 ); - /* Only values 1, 2, 4, 8 are allowed. */ - shift = p->font->bpp; - bitcount = 0; - for ( i = 0; shift > 0; i++ ) - { - if ( shift & 1 ) - bitcount = i; - shift >>= 1; - } - - shift = (short)( ( bitcount > 3 ) ? 8 : ( 1 << bitcount ) ); + /* Only values 1, 2, 4, 8 are allowed for greymap fonts. */ + if ( bpp > 4 ) + p->font->bpp = 8; + else if ( bpp > 2 ) + p->font->bpp = 4; + else if ( bpp > 1 ) + p->font->bpp = 2; + else + p->font->bpp = 1; - if ( p->font->bpp > shift || p->font->bpp != shift ) - { - /* select next higher value */ - p->font->bpp = (unsigned short)( shift << 1 ); + if ( p->font->bpp != bpp ) FT_TRACE2(( "_bdf_parse_start: " ACMSG11, p->font->bpp )); - } } else p->font->bpp = 1; |