freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] parthw-pk-vf 8bacbfc: [pk] Add pk services.


From: Parth Wazurkar
Subject: [freetype2] parthw-pk-vf 8bacbfc: [pk] Add pk services.
Date: Thu, 19 Jul 2018 03:32:38 -0400 (EDT)

branch: parthw-pk-vf
commit 8bacbfc33ed026b772745989b3b8ef0f4c798343
Author: Parth Wazurkar <address@hidden>
Commit: Parth Wazurkar <address@hidden>

    [pk] Add pk services.
---
 include/freetype/internal/ftserv.h            |  1 +
 include/freetype/internal/services/svfntfmt.h |  1 +
 include/freetype/internal/services/svpk.h     | 40 +++++++++++++++++++++++++
 src/pk/pk.h                                   |  2 ++
 src/pk/pkdrivr.c                              | 43 ++++++++++++++++++++++-----
 src/pk/pklib.c                                | 12 ++++----
 6 files changed, 86 insertions(+), 13 deletions(-)

diff --git a/include/freetype/internal/ftserv.h 
b/include/freetype/internal/ftserv.h
index 3f493b5..974703d 100644
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -510,6 +510,7 @@ FT_BEGIN_HEADER
 #define FT_SERVICE_TRUETYPE_GLYF_H      <freetype/internal/services/svttglyf.h>
 #define FT_SERVICE_TT_CMAP_H            <freetype/internal/services/svttcmap.h>
 #define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
+#define FT_SERVICE_PK_H                 <freetype/internal/services/svpk.h>
 
  /* */
 
diff --git a/include/freetype/internal/services/svfntfmt.h 
b/include/freetype/internal/services/svfntfmt.h
index 6182362..d5e765c 100644
--- a/include/freetype/internal/services/svfntfmt.h
+++ b/include/freetype/internal/services/svfntfmt.h
@@ -42,6 +42,7 @@ FT_BEGIN_HEADER
 #define FT_FONT_FORMAT_CFF       "CFF"
 #define FT_FONT_FORMAT_PFR       "PFR"
 #define FT_FONT_FORMAT_WINFNT    "Windows FNT"
+#define FT_FONT_FORMAT_PK        "PK"
 
   /* */
 
diff --git a/include/freetype/internal/services/svpk.h 
b/include/freetype/internal/services/svpk.h
new file mode 100644
index 0000000..993cc7c
--- /dev/null
+++ b/include/freetype/internal/services/svpk.h
@@ -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 */
diff --git a/src/pk/pk.h b/src/pk/pk.h
index 92028ca..d9c5a72 100644
--- a/src/pk/pk.h
+++ b/src/pk/pk.h
@@ -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;
diff --git a/src/pk/pkdrivr.c b/src/pk/pkdrivr.c
index 65d58bd..851e5fe 100644
--- a/src/pk/pkdrivr.c
+++ b/src/pk/pkdrivr.c
@@ -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 ),
diff --git a/src/pk/pklib.c b/src/pk/pklib.c
index b612563..e763461 100644
--- a/src/pk/pklib.c
+++ b/src/pk/pklib.c
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]