* modules.cfg: Compile in ftotval.c and ftxf86.c by default for ABI compatibility. * src/sfnt/sfobjs.c (sfnt_done_face): Fix a memory leak. * src/sfnt/ttsbit0.c (tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_byte_aligned) [FT_OPTIMIZE_MEMORY]: Fix sbit loading. (only tested with bit aligned sbit with x_pos == 0) * src/truetype/ttpload.c (tt_face_load_hdmx, tt_face_get_device_metrics) [FT_OPTIMIZE_MEMORY]: hdmx is not actually used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
diff --git a/ChangeLog b/ChangeLog
index fcbc5e9..27f2c3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-02-22 Chia-I Wu <b90201047@ntu.edu.tw>
+
+ * modules.cfg: Compile in ftotval.c and ftxf86.c by default for ABI
+ compatibility.
+
+ * src/sfnt/sfobjs.c (sfnt_done_face): Fix a memory leak.
+
+ * src/sfnt/ttsbit0.c (tt_sbit_decoder_load_bit_aligned,
+ tt_sbit_decoder_load_byte_aligned) [FT_OPTIMIZE_MEMORY]: Fix sbit
+ loading. (only tested with bit aligned sbit with x_pos == 0)
+
+ * src/truetype/ttpload.c (tt_face_load_hdmx,
+ tt_face_get_device_metrics) [FT_OPTIMIZE_MEMORY]: hdmx is not actually
+ used.
+
2006-02-21 David Turner <david@freetype.org>
* include/freetype/ftmodapi.h, include/internal/ftserv.h,
diff --git a/modules.cfg b/modules.cfg
index f251fd8..cf357cf 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -176,7 +176,7 @@ BASE_EXTENSIONS += ftmm.c
# Interface for otvalid module (which is required).
#
# See include/freetype/ftotval.h for the API.
-# BASE_EXTENSIONS += ftotval.c
+BASE_EXTENSIONS += ftotval.c
# Interface for accessing PFR-specific data. Needs PFR font driver.
#
@@ -209,7 +209,7 @@ BASE_EXTENSIONS += ftwinfnt.c
# server.
#
# See include/freetype/ftxf86.h for the API.
-# BASE_EXTENSIONS += ftxf86.c
+BASE_EXTENSIONS += ftxf86.c
####
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 6b780e3..1516806 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -1022,7 +1022,7 @@
}
/* freeing the horizontal metrics */
-#ifdef FT_OPTIMIZE_MEMORY
+#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS
{
FT_Stream stream = FT_FACE_STREAM( face );
diff --git a/src/sfnt/ttsbit0.c b/src/sfnt/ttsbit0.c
index 1ade208..1a5efc9 100644
--- a/src/sfnt/ttsbit0.c
+++ b/src/sfnt/ttsbit0.c
@@ -489,9 +489,18 @@
}
if ( w > 0 )
- wval = (FT_UInt)(wval | ( *p++ & ( 0xFF00U >> w ) ) );
+ wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) );
+
+ /* all bits read and there are ( x_pos + w ) bits to be written */
write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
+
+ if ( x_pos + w > 8 )
+ {
+ write++;
+ wval <<= 8;
+ write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
+ }
}
}
@@ -509,9 +518,9 @@
{
FT_Error error = SFNT_Err_Ok;
FT_Byte* line;
- FT_Int bit_height, bit_width, pitch, width, height, h;
+ FT_Int bit_height, bit_width, pitch, width, height, h, nbits;
FT_Bitmap* bitmap;
- FT_UInt32 rval;
+ FT_UShort rval;
if ( !decoder->bitmap_allocated )
@@ -538,7 +547,7 @@
goto Exit;
}
- if ( p + ( ( width + 7 ) >> 3 ) * height > limit )
+ if ( p + ( ( width * height + 7 ) >> 3 ) > limit )
{
error = SFNT_Err_Invalid_File_Format;
goto Exit;
@@ -547,39 +556,61 @@
/* now do the blit */
line += y_pos * pitch + ( x_pos >> 3 );
x_pos &= 7;
- rval = 0x10000UL;
+
+ /* the higher byte of `rval' is used as a buffer */
+ rval = 0;
+ nbits = 0;
for ( h = height; h > 0; h--, line += pitch )
{
- FT_Byte* write = line;
- FT_UInt32 wval = 0x100 << x_pos;
- FT_Int w;
+ FT_Byte* write = line;
+ FT_Int w = width;
- for ( w = width; w >= 8; w -= 8 )
+ if ( x_pos )
{
- if ( rval & 0x10000UL )
- rval = 0x100 | *p++;
-
- wval |= rval & 0x80;
-
- wval <<= 1;
- rval <<= 1;
+ w = ( width < 8 - x_pos ) ? width : 8 - x_pos;
- if ( wval & 0x10000UL )
+ if ( nbits < w )
{
- write[0] = (FT_Byte)( write[0] | ( wval >> 8 ) );
- write += 1;
- wval = 0x100;
+ rval |= *p++;
+ nbits += 8 - w;
+ }
+ else
+ {
+ rval >>= 8;
+ nbits -= w;
}
+
+ *write++ |= ( ( rval >> nbits ) & 0xFF ) & ~( 0xFF << w );
+ rval <<= 8;
+
+ w = width - w;
}
- if ( wval != 0x100 )
+ for ( ; w >= 8; w -= 8 )
{
- while ( wval > 0x1FF )
- wval >>= 1;
+ rval |= *p++;
+ *write++ |= ( rval >> nbits ) & 0xFF;
- write[0] = (FT_Byte)( write[0] | wval );
+ rval <<= 8;
+ }
+
+ if ( w > 0 )
+ {
+ if ( nbits < w )
+ {
+ rval |= *p++;
+ *write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
+ nbits += 8 - w;
+
+ rval <<= 8;
+ }
+ else
+ {
+ *write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
+ nbits -= w;
+ }
}
}
diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c
index 04c2031..da2677b 100644
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -582,6 +582,7 @@
face->hdmx_record_count = nn;
face->hdmx_table_size = table_size;
+ face->hdmx_record_size = record_size;
Exit:
return error;
@@ -723,7 +724,7 @@
{
gindex += 2;
if ( gindex < record_size )
- result = record + gindex;
+ result = record + nn * record_size + gindex;
break;
}