[pk] Add pk services.

This commit is contained in:
Parth Wazurkar 2018-07-19 12:58:44 +05:30
parent e4ec41fc02
commit f909b86c84
6 changed files with 86 additions and 13 deletions

View File

@ -511,6 +511,7 @@ FT_BEGIN_HEADER
#define FT_SERVICE_TT_CMAP_H <freetype/internal/services/svttcmap.h>
#define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h>
#define FT_SERVICE_GF_H <freetype/internal/services/svgf.h>
#define FT_SERVICE_PK_H <freetype/internal/services/svpk.h>
/* */

View File

@ -43,6 +43,7 @@ FT_BEGIN_HEADER
#define FT_FONT_FORMAT_PFR "PFR"
#define FT_FONT_FORMAT_WINFNT "Windows FNT"
#define FT_FONT_FORMAT_GF "GF"
#define FT_FONT_FORMAT_PK "PK"
/* */

View File

@ -0,0 +1,40 @@
/****************************************************************************
*
* svpk.h
*
* The FreeType PK services (specification).
*
* Copyright 2003-2018 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef SVPK_H_
#define SVPK_H_
#include FT_INTERNAL_SERVICE_H
FT_BEGIN_HEADER
#define FT_SERVICE_ID_PK "pk"
/* */
FT_END_HEADER
#endif /* SVPK_H_ */
/* END */

View File

@ -39,6 +39,8 @@ FT_BEGIN_HEADER
#define PK_POST 245
#define PK_NO_OP 246
#define toint(x) (int)(((x)>0)?(x+0.5):(x-0.5))
/* Temporary TO BE REMOVED */
typedef char INT1;

View File

@ -21,6 +21,8 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_PK_H
#include FT_SERVICE_FONT_FORMAT_H
@ -237,17 +239,21 @@
{
FT_Bitmap_Size* bsize = pkface->available_sizes;
/* FT_UShort x_res, y_res; */
FT_UShort x_res, y_res;
bsize->height = (FT_Short) face->pk_glyph->font_bbx_h ;
bsize->width = (FT_Short) face->pk_glyph->font_bbx_w ;
bsize->size = (FT_Pos) face->pk_glyph->ds << 6 ;
bsize->size = (FT_Pos) FT_MulDiv( FT_ABS( face->pk_glyph->ds ),
64 * 7200,
72270L );
/* x_res = toint( go->hppp * 72.27 ); */
/* y_res = toint( go->vppp * 72.27 ); */
x_res = toint( face->pk_glyph->hppp * 72.27 );
y_res = toint( face->pk_glyph->vppp * 72.27 );
bsize->y_ppem = (FT_Pos)(bsize->size/10) << 6 ;
bsize->x_ppem = (FT_Pos)bsize->y_ppem ;
bsize->y_ppem = (FT_Pos) toint((face->pk_glyph->ds * y_res)/ 72.27) << 6 ;
bsize->x_ppem = (FT_Pos)FT_MulDiv( bsize->y_ppem,
x_res,
y_res ); ;
}
/* Charmaps */
@ -423,6 +429,29 @@
return error;
}
/*
*
* SERVICES LIST
*
*/
static const FT_ServiceDescRec pk_services[] =
{
{ FT_SERVICE_ID_PK, NULL },
{ FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PK },
{ NULL, NULL }
};
FT_CALLBACK_DEF( FT_Module_Interface )
pk_driver_requester( FT_Module module,
const char* name )
{
FT_UNUSED( module );
return ft_service_list_lookup( pk_services, name );
}
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pk_driver_class =
@ -440,7 +469,7 @@
NULL, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
NULL /* FT_Module_Requester get_interface */
pk_driver_requester /* FT_Module_Requester get_interface */
},
sizeof ( PK_FaceRec ),

View File

@ -288,7 +288,7 @@ unsigned char bit_table[] = {
{
PK_Glyph go;
UINT1 instr, pre, id;;
UINT4 ds, check_sum, hppp, vppp, k;
unsigned long ds, check_sum, hppp, vppp, k;
unsigned int flag, dny_f, bw, ess, size;
UINT4 cc, tfm, dx, dy, dm, w, h, rs;
INT4 hoff, voff, mv_x, mv_y;
@ -389,9 +389,9 @@ unsigned char bit_table[] = {
for (i = 0; i < nchars; i++)
go->bm_table[i].bitmap = NULL;
go->ds = (double)ds/(1<<20);
go->hppp = (double)hppp/(1<<16);
go->vppp = (double)vppp/(1<<16);
go->ds = (FT_UInt)ds/(1<<20);
go->hppp = (FT_UInt)hppp/(1<<16);
go->vppp = (FT_UInt)vppp/(1<<16);
go->font_bbx_w = 0;
go->font_bbx_h = 0;
go->font_bbx_xoff = 0;
@ -479,8 +479,8 @@ unsigned char bit_table[] = {
h = READ_UINT4( stream );
hoff = READ_INT4( stream );
voff = READ_INT4( stream );
mv_x = (double)dx/(double)(1<<16);
mv_y = (double)dy/(double)(1<<16);
mv_x = (FT_UInt)dx/(FT_UInt)(1<<16);
mv_y = (FT_UInt)dy/(FT_UInt)(1<<16);
}
if ((cc < go->code_min) || (go->code_max < cc))