summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParth Wazurkar <parthwazurkar@gmail.com>2018-08-10 20:23:28 +0530
committerParth Wazurkar <parthwazurkar@gmail.com>2018-08-10 20:23:28 +0530
commitb54503a256e1db45b253a9fb762430280a2cce16 (patch)
tree06bbe0ffa1a92057aeff34d103cf2e74c935f239
parent7ea68ac9f3bfc20f2c6408f21ae82c880c217ba2 (diff)
downloadfreetype2-b54503a256e1db45b253a9fb762430280a2cce16.tar.gz
[gf] Allocate bitmap in `GF_Glyph_Load' itself.
-rw-r--r--src/gf/gfdrivr.c24
-rw-r--r--src/gf/gflib.c24
-rw-r--r--src/pk/pkdrivr.c1
-rw-r--r--src/tfm/tfmobjs.c15
4 files changed, 34 insertions, 30 deletions
diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index 50de121a8..8723f26a7 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -189,10 +189,10 @@
memory = FT_FACE_MEMORY( face );
- gf_free_font( face );
-
FT_FREE( gfface->available_sizes );
-
+ FT_FREE( face->gf_glyph->encodings );
+ FT_FREE( face->gf_glyph->metrics );
+ gf_free_font( face );
}
@@ -429,7 +429,6 @@
GF_MetricRec metric;
GF_Glyph go;
FT_ULong bytes;
- FT_Byte *bitmp;
go = gf->gf_glyph;
@@ -470,12 +469,7 @@
bitmap->width = metric.bbx_width;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
- bitmap->pitch = (int)( metric.raster );
-
- /* note: we don't allocate a new array to hold the bitmap; */
- /* we can simply point to it */
- ft_glyphslot_set_bitmap( slot, metric.bitmap );
-
+ bitmap->pitch = (int)( ( bitmap->width + 7 ) >> 3 );
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = metric.off_x ;
@@ -489,7 +483,13 @@
ft_synthesize_vertical_metrics( &slot->metrics, metric.bbx_height * 64 );
- /* XXX: to do: are there cases that need repadding the bitmap? */
+ if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
+ goto Exit;
+
+ bytes = (FT_ULong)bitmap->pitch * bitmap->rows;
+
+ error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes );
+ memset( slot->bitmap.buffer, 0, bytes );
Exit:
return error;
@@ -567,7 +567,6 @@
if ( !error )
{
- printf("Hi I reached here\n");
/* Modify GF_Glyph data according to TFM metric values */
/*face->gf_glyph->font_bbx_w = fi->font_bbx_w;
@@ -575,7 +574,6 @@
*/
face->tfm_data = fi;
- fi = NULL;
}
Exit:
diff --git a/src/gf/gflib.c b/src/gf/gflib.c
index 9e922a34d..960f7000e 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflib.c
@@ -195,6 +195,7 @@ FT_Byte bit_table[] = {
}
FT_FREE(metric);
+ FT_FREE(tosort);
go->nencodings = k;
go->encodings = encoding;
@@ -283,14 +284,14 @@ FT_Byte bit_table[] = {
BOC:
if(error != FT_Err_Ok)
- return -1;
+ return error;
w = max_m - min_m + 1;
h = max_n - min_n + 1;
if ((w < 0) || (h < 0))
{
FT_ERROR(( "gf_read_glyph: invalid w and h values\n" ));
error = FT_THROW( Invalid_File_Format );
- return -1;
+ return error;
}
/* FT_TRACE2(( "w is %ld\n"
@@ -300,14 +301,21 @@ FT_Byte bit_table[] = {
*/
/* allocate and build bitmap */
+ /*
if ((metrics->bitmap = (FT_Byte*)malloc(h*((w+7)/8))) == NULL)
{
error = FT_THROW( Invalid_File_Format );
- return -1;
+ return error;
}
+ */
+ /* if( FT_ALLOC( metrics->bitmap, (h*((w+7)/8)) ) )
+ return error;
+ */
+ /*
memset(metrics->bitmap, 0, h*((w+7)/8));
metrics->raster = (FT_UInt)(w+7)/8;
+ */
metrics->bbx_width = w;
metrics->bbx_height = h;
metrics->off_x = -min_m;
@@ -596,6 +604,12 @@ FT_Byte bit_table[] = {
go->metrics[code - bc].mv_y = dy;
go->metrics[code - bc].char_offset = (FT_ULong)ptr;
go->metrics[code - bc].code = (FT_UShort)code;
+ go->metrics[code - bc].bbx_width = 0; /* Initialize other metrics here */
+ go->metrics[code - bc].bbx_height = 0;
+ go->metrics[code - bc].off_x = 0;
+ go->metrics[code - bc].off_y = 0;
+ go->metrics[code - bc].raster = 0;
+ go->metrics[code - bc].bitmap = NULL;
go->nglyphs += 1;
}
@@ -628,10 +642,6 @@ FT_Byte bit_table[] = {
if ( !go )
return;
- if(go->metrics != NULL)
- {
- FT_FREE(go->metrics);
- }
FT_FREE(go);
}
diff --git a/src/pk/pkdrivr.c b/src/pk/pkdrivr.c
index 8dc0dd3bd..3844d8b34 100644
--- a/src/pk/pkdrivr.c
+++ b/src/pk/pkdrivr.c
@@ -517,7 +517,6 @@
*/
face->tfm_data = fi;
- fi = NULL;
}
Exit:
diff --git a/src/tfm/tfmobjs.c b/src/tfm/tfmobjs.c
index 75e2b4620..63fd08990 100644
--- a/src/tfm/tfmobjs.c
+++ b/src/tfm/tfmobjs.c
@@ -131,9 +131,9 @@
FT_LOCAL( void )
tfm_close( TFM_Parser parser )
{
- FT_Memory memory = parser->memory;
+ FT_UNUSED( parser );
- FT_FREE( parser->stream );
+ /* nothing */
}
@@ -346,13 +346,10 @@
fi->slant = (FT_ULong)((double)fi->slant/(double)(1<<20));
Exit:
- if( !ci || !w || !h || !d )
- {
- FT_FREE(ci);
- FT_FREE(w);
- FT_FREE(h);
- FT_FREE(d);
- }
+ FT_FREE(ci);
+ FT_FREE(w);
+ FT_FREE(h);
+ FT_FREE(d);
return error;
}