summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParth Wazurkar <parthwazurkar@gmail.com>2018-08-15 02:01:12 +0530
committerParth Wazurkar <parthwazurkar@gmail.com>2018-08-15 02:01:12 +0530
commit08a8e43fb4b12da756a2dd5e675354dc3d60a5c8 (patch)
tree29e86a4a32ed8f900d96a2bc77d8ae4fde558a46
parent96db629b8e95bdbca51942f5ebade989505f1daf (diff)
downloadfreetype2-08a8e43fb4b12da756a2dd5e675354dc3d60a5c8.tar.gz
[gf] Resolve failing of `GF_CMap'.
* src/gf/gfdrivr.c(gf_cmap_char_{index, next}): Use `linear search' instead of `binary search' in the encoding table as it will always be unsorted.
-rw-r--r--src/gf/gfdrivr.c54
1 files changed, 11 insertions, 43 deletions
diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index c44c35c28..fd65cd65d 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -81,33 +81,21 @@
{
GF_CMap cmap = (GF_CMap)gfcmap;
GF_Encoding encodings = cmap->encodings;
- FT_ULong min, max, mid;
- FT_UInt result = 0;
+ FT_UInt max, code, result = 0, i;
- min = 0;
max = cmap->num_encodings;
- while ( min < max )
+ for( i = 0; i < max; i++ )
{
- FT_ULong code;
-
-
- mid = ( min + max ) >> 1;
- code = (FT_ULong)encodings[mid].enc;
-
+ code = (FT_ULong)encodings[i].enc;
if ( charcode == code )
{
- result = encodings[mid].glyph;
- break;
+ result = encodings[i].glyph;
+ goto Exit;
}
-
- if ( charcode < code )
- max = mid;
- else
- min = mid + 1;
}
-
- return result;
+ Exit:
+ return result;
}
FT_CALLBACK_DEF( FT_UInt )
@@ -116,39 +104,19 @@
{
GF_CMap cmap = (GF_CMap)gfcmap;
GF_Encoding encodings = cmap->encodings;
- FT_ULong min, max, mid;
+ FT_UInt result = 0, i, code, max;
FT_ULong charcode = *acharcode + 1;
- FT_UInt result = 0;
-
- min = 0;
max = cmap->num_encodings;
- while ( min < max )
+ for( i = 0; i < max; i++ )
{
- FT_ULong code;
-
-
- mid = ( min + max ) >> 1;
- code = (FT_ULong)encodings[mid].enc;
-
+ code = (FT_ULong)encodings[i].enc;
if ( charcode == code )
{
- result = encodings[mid].glyph + 1;
+ result = encodings[i].glyph + 1;
goto Exit;
}
-
- if ( charcode < code )
- max = mid;
- else
- min = mid + 1;
- }
-
- charcode = 0;
- if ( min < cmap->num_encodings )
- {
- charcode = (FT_ULong)encodings[min].enc;
- result = encodings[min].glyph ;
}
Exit: