[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] parthw-cleaned 0fc1a64 21/21: [gf] Fixes.
From: |
Parth Wazurkar |
Subject: |
[freetype2] parthw-cleaned 0fc1a64 21/21: [gf] Fixes. |
Date: |
Thu, 5 Jul 2018 10:50:41 -0400 (EDT) |
branch: parthw-cleaned
commit 0fc1a64b83bc578d84f7d7c8365e4335ae20e699
Author: Parth Wazurkar <address@hidden>
Commit: Parth Wazurkar <address@hidden>
[gf] Fixes.
---
src/gf/gf.h | 1 +
src/gf/gfdrivr.c | 69 +++++++++++++++++++++++++++++---------------------------
src/gf/gflib.c | 3 ++-
3 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/src/gf/gf.h b/src/gf/gf.h
index e624b95..54d066e 100644
--- a/src/gf/gf.h
+++ b/src/gf/gf.h
@@ -59,6 +59,7 @@ FT_BEGIN_HEADER
#define GF_YYY 243
#define GF_NO_OP 244
+#define toint(x) (int)(((x)>0)?(x+0.5):(x-0.5))
typedef char INT1;
typedef unsigned char UINT1;
diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index de156c4..8596d61 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -142,7 +142,7 @@
memory = FT_FACE_MEMORY( face );
- gf_free_font( gfface, memory );
+ /*gf_free_font( gfface, memory );*/
}
@@ -234,26 +234,27 @@
{
FT_Bitmap_Size* bsize = gfface->available_sizes;
+ FT_UShort x_res, y_res;
- bsize->width = (FT_Short) face->gf_glyph->font_bbx_w ;
bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ;
- bsize->size = (FT_Pos) face->gf_glyph->ds ; /* Preliminary
to be checked for 26.6 fractional points*/
+ bsize->width = (FT_Short) face->gf_glyph->font_bbx_w ;
+ bsize->size = (FT_Pos) face->gf_glyph->ds << 6 ;
- /*x_res = ; To be Checked for x_resolution and y_resolution
- y_res = ;*/
+ x_res = toint( go->hppp * 72.27 );
+ y_res = toint( go->vppp * 72.27 );
- bsize->y_ppem = (FT_Pos)face->gf_glyph->font_bbx_yoff ;
- bsize->x_ppem = (FT_Pos)face->gf_glyph->font_bbx_xoff ;
+ bsize->y_ppem = (FT_Pos)(bsize->size/10) << 6 ;
+ bsize->x_ppem = (FT_Pos)bsize->y_ppem ;
}
/* Charmaps */
{
FT_CharMapRec charmap;
- charmap.encoding = FT_ENCODING_NONE;
- /* initial platform/encoding should indicate unset status? */
- charmap.platform_id = TT_PLATFORM_APPLE_UNICODE; /*Preliminary */
- charmap.encoding_id = TT_APPLE_ID_DEFAULT;
+ /* Unicode Charmap */
+ charmap.encoding = FT_ENCODING_UNICODE;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.face = FT_FACE( face );
error = FT_CMap_New( &gf_cmap_class, NULL, &charmap, NULL );
@@ -279,16 +280,15 @@
GF_Size_Select( FT_Size size,
FT_ULong strike_index )
{
- GF_Face face = (GF_Face)size->face;
-
+ GF_Face face = (GF_Face)size->face;
+ GF_Glyph go = face->gf_glyph;
FT_UNUSED( strike_index );
-
FT_Select_Metrics( size->face, 0 );
- size->metrics.ascender = face->gf_glyph->font_bbx_xoff * 64;
- size->metrics.descender = face->gf_glyph->font_bbx_yoff * 64;
- size->metrics.max_advance = face->gf_glyph->font_bbx_w * 64;
+ size->metrics.ascender = (go->font_bbx_h - go->font_bbx_yoff) * 64;
+ size->metrics.descender = -go->font_bbx_yoff * 64;
+ size->metrics.max_advance = go->font_bbx_w * 64;
return FT_Err_Ok;
@@ -315,7 +315,7 @@
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
- if ( height == face->gf_glyph->font_bbx_h ) /* Preliminary */
+ if ( height == face->gf_glyph->font_bbx_h )
error = FT_Err_Ok;
break;
@@ -343,13 +343,14 @@
FT_Error error = FT_Err_Ok;
FT_Bitmap* bitmap = &slot->bitmap;
GF_BitmapRec bm ;
- GF_Glyph go;
+ GF_Glyph go;
+ FT_Int ascent;
go = gf->gf_glyph;
FT_UNUSED( load_flags );
-
+ printf("Hi I reached GF_Load_Glyph\n");
if ( !face )
{
error = FT_THROW( Invalid_Face_Handle );
@@ -382,11 +383,12 @@
goto Exit;
}
- /* slot, bitmap => freetype, glyph => gflib */
+ /* slot, bitmap => freetype, bm => gflib */
bm = gf->gf_glyph->bm_table[glyph_index];
- bitmap->rows = bm.mv_y ; /* Prelimiary */
- bitmap->width = bm.mv_x ; /* Prelimiary */
+ bitmap->rows = bm.bbx_height / go->vppp;
+ bitmap->width = bm.bbx_width / go->hppp;
+ bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
if ( !bm.raster )
{
@@ -395,21 +397,22 @@
goto Exit;
}
- bitmap->pitch = bm.raster ; /* Prelimiary */
+ bitmap->pitch = (int)bm.raster ;
/* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */
- ft_glyphslot_set_bitmap( slot, bm.bitmap ); /* TO CHECK for column and
row? like winfont.*/
+ ft_glyphslot_set_bitmap( slot, bm.bitmap );
+ ascent = (bm.bbx_height + bm.off_y) / go->vppp;
slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = bm.off_x ; /* Prelimiary */
- slot->bitmap_top = bm.off_y ; /* Prelimiary */
-
- slot->metrics.horiAdvance = (FT_Pos) bm.bbx_width - bm.off_x ; /*
Prelimiary */
- slot->metrics.horiBearingX = (FT_Pos) bm.off_x ; /*
Prelimiary */
- slot->metrics.horiBearingY = (FT_Pos) bm.off_y ; /*
Prelimiary */
- slot->metrics.width = (FT_Pos) ( bitmap->width * 64 ) ; /*
Prelimiary */
- slot->metrics.height = (FT_Pos) ( bitmap->rows * 64 ) ; /*
Prelimiary */
+ slot->bitmap_left = bm.off_x / go->hppp;
+ slot->bitmap_top = ascent ;
+
+ slot->metrics.horiAdvance = (FT_Pos) bm.mv_x * 64;
+ slot->metrics.horiBearingX = (FT_Pos) bm.off_x * 64;
+ slot->metrics.horiBearingY = (FT_Pos) ascent * 64;
+ slot->metrics.width = (FT_Pos) ( bitmap->width * 64 );
+ slot->metrics.height = (FT_Pos) ( bitmap->rows * 64 );
ft_synthesize_vertical_metrics( &slot->metrics, bm.bbx_height * 64 );
diff --git a/src/gf/gflib.c b/src/gf/gflib.c
index c97c190..4bc8285 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflib.c
@@ -160,6 +160,7 @@ unsigned char bit_table[] = {
return -1;
}
+ /* allocate and build bitmap */
if ((bm->bitmap = (unsigned char*)malloc(h*((w+7)/8))) == NULL)
{
error = FT_THROW( Invalid_File_Format );
@@ -167,7 +168,7 @@ unsigned char bit_table[] = {
}
memset(bm->bitmap, 0, h*((w+7)/8));
- bm->raster = (w+7)/8;
+ bm->raster = (FT_UInt)(w+7)/8;
bm->bbx_width = w;
bm->bbx_height = h;
bm->off_x = -min_m;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] parthw-cleaned 0fc1a64 21/21: [gf] Fixes.,
Parth Wazurkar <=