freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] GSoC-2019-moazin 1ea63c5 1/8: Reverts the changes made in th


From: Moazin Khatti
Subject: [freetype2] GSoC-2019-moazin 1ea63c5 1/8: Reverts the changes made in the structure of `TT_GlyphSlot'
Date: Sat, 22 Jun 2019 14:05:16 -0400 (EDT)

branch: GSoC-2019-moazin
commit 1ea63c5dd54147e5090af6fd79997b2a4633e117
Author: Moazin Khatti <address@hidden>
Commit: Moazin Khatti <address@hidden>

    Reverts the changes made in the structure of `TT_GlyphSlot'
---
 include/freetype/internal/cffotypes.h |  5 ---
 include/freetype/internal/tttypes.h   | 40 +------------------
 src/cff/cffgload.c                    | 15 -------
 src/truetype/ttgload.c                | 74 ++++++++++++++++-------------------
 src/truetype/ttobjs.h                 | 15 +++++++
 5 files changed, 51 insertions(+), 98 deletions(-)

diff --git a/include/freetype/internal/cffotypes.h 
b/include/freetype/internal/cffotypes.h
index 73cb159..b26893e 100644
--- a/include/freetype/internal/cffotypes.h
+++ b/include/freetype/internal/cffotypes.h
@@ -61,11 +61,6 @@ FT_BEGIN_HEADER
   {
     FT_GlyphSlotRec  root;
 
-    /* (OT-SVG) Added these here so that CFFGlyphSlot can be cast to
-       TT_GlyphSlot */
-    FT_Byte*          svg_document;
-    FT_ULong          svg_document_length;
-
     FT_Bool  hint;
     FT_Bool  scaled;
 
diff --git a/include/freetype/internal/tttypes.h 
b/include/freetype/internal/tttypes.h
index 3539e18..42a921f 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -967,8 +967,8 @@ FT_BEGIN_HEADER
    * This structure/class is defined here because it is common to the
    * following formats: TTF, OpenType-TT, and OpenType-CFF.
    *
-   * Note, however, that the class TT_Size is not shared between font driver,
-   * and is thus defined in `ttobjs.h`.
+   * Note, however, that the classes TT_Size and TT_GlyphSlot are not shared
+   * between font drivers, and are thus defined in `ttobjs.h`.
    *
    */
 
@@ -988,42 +988,6 @@ FT_BEGIN_HEADER
    */
   typedef struct TT_FaceRec_*  TT_Face;
 
-  /**************************************************************************
-   *
-   * @type:
-   *   TT_GlyphSlotRec_
-   *
-   * @description:
-   *   A glyph slot that inherits from FT_GlyphSlotRec_ but adds more fields
-   *
-   * @fields:
-   *   root ::
-   *     Inherits this structure from FT_GlyphSlotRec. See note below.
-   *
-   *   svg_document ::
-   *     A pointer to the SVG Document stream under interest. The stream
-   *     will be in plain text.
-   *
-   *   svg_document_length ::
-   *     The length of the `svg_document' stream.
-   *
-   * @note:
-   *   This structure has been created to accomodate the needs of OT-SVG
-   *   rendering. It inherits from FT_GlyphSlotRect. So that `TT_GlyphSlot'
-   *   can be casted to `FT_GlyphSlot' and behave that way too. It's defined
-   *   here because it is common to OpenType-TTF and OpenType-CFF.
-   */
-  typedef struct TT_GlyphSlotRec_ 
-  {
-    FT_GlyphSlotRec   root;
-    FT_Byte*          svg_document;
-    FT_ULong          svg_document_length;
-  } TT_GlyphSlotRec;
-
-
-  /* A handle to a TrueType glyph slot object. */
-  typedef struct TT_GlyphSlotRec_*  TT_GlyphSlot;
-
 
   /* a function type used for the truetype bytecode interpreter hooks */
   typedef FT_Error
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 95e2fa6..36aa7d1 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -347,21 +347,6 @@
     if ( load_flags & FT_LOAD_SBITS_ONLY )
       return FT_THROW( Invalid_Argument );
 
-    /* check for OT-SVG */
-    if ( ( load_flags & FT_LOAD_COLOR ) &&
-         ( ((TT_Face)glyph->root.face)->svg ) )
-    {
-      SFNT_Service  sfnt = (SFNT_Service)(((TT_Face)glyph->root.face)->sfnt);
-      error = sfnt->load_svg_doc( &(glyph->root), glyph_index );
-      if( error == FT_Err_Ok )
-      {
-        glyph->root.format = FT_GLYPH_FORMAT_SVG;
-        return error;
-      }
-    }
-
-    /* OpenType SVG Support End */
-
     /* if we have a CID subfont, use its matrix (which has already */
     /* been multiplied with the root matrix)                       */
 
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index ac6613e..2aafc9a 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -2204,12 +2204,7 @@
 
     FT_BBox       bbox;
     FT_Fixed      y_scale;
-
-    /* TODO: (OT-SVG) Temporary hack to accomodate the change
-     * in the `TT_GlyphSlot' made. Rewrite properly
-     */
-    TT_GlyphSlot  glyph_ = (TT_GlyphSlot)loader->glyph;
-    FT_GlyphSlot  glyph = (FT_GlyphSlot)glyph_;
+    TT_GlyphSlot  glyph = loader->glyph;
     TT_Size       size  = loader->size;
 
 
@@ -2396,10 +2391,8 @@
     FT_Error            error;
     TT_SBit_MetricsRec  sbit_metrics;
 
-    /* (OT-SVG) face assignment changed to accomodate the change in
-     * the structure of TT_GlyphSlot
-     */
-    face   = (TT_Face)(glyph->root.face);
+
+    face   = (TT_Face)glyph->face;
     sfnt   = (SFNT_Service)face->sfnt;
     stream = face->root.stream;
 
@@ -2408,39 +2401,35 @@
                                    glyph_index,
                                    (FT_UInt)load_flags,
                                    stream,
-                                   &(glyph->root.bitmap),
+                                   &glyph->bitmap,
                                    &sbit_metrics );
-    /* TODO: (OT-SVG) So many `glyph->root' look ugly. Maybe create a new 
variable
-     * to make this look good.
-     */
-
     if ( !error )
     {
-      (glyph->root).outline.n_points   = 0;
-      (glyph->root).outline.n_contours = 0;
+      glyph->outline.n_points   = 0;
+      glyph->outline.n_contours = 0;
 
-      (glyph->root).metrics.width  = (FT_Pos)sbit_metrics.width  * 64;
-      (glyph->root).metrics.height = (FT_Pos)sbit_metrics.height * 64;
+      glyph->metrics.width  = (FT_Pos)sbit_metrics.width  * 64;
+      glyph->metrics.height = (FT_Pos)sbit_metrics.height * 64;
 
-      (glyph->root).metrics.horiBearingX = (FT_Pos)sbit_metrics.horiBearingX * 
64;
-      (glyph->root).metrics.horiBearingY = (FT_Pos)sbit_metrics.horiBearingY * 
64;
-      (glyph->root).metrics.horiAdvance  = (FT_Pos)sbit_metrics.horiAdvance  * 
64;
+      glyph->metrics.horiBearingX = (FT_Pos)sbit_metrics.horiBearingX * 64;
+      glyph->metrics.horiBearingY = (FT_Pos)sbit_metrics.horiBearingY * 64;
+      glyph->metrics.horiAdvance  = (FT_Pos)sbit_metrics.horiAdvance  * 64;
 
-      (glyph->root).metrics.vertBearingX = (FT_Pos)sbit_metrics.vertBearingX * 
64;
-      (glyph->root).metrics.vertBearingY = (FT_Pos)sbit_metrics.vertBearingY * 
64;
-      (glyph->root).metrics.vertAdvance  = (FT_Pos)sbit_metrics.vertAdvance  * 
64;
+      glyph->metrics.vertBearingX = (FT_Pos)sbit_metrics.vertBearingX * 64;
+      glyph->metrics.vertBearingY = (FT_Pos)sbit_metrics.vertBearingY * 64;
+      glyph->metrics.vertAdvance  = (FT_Pos)sbit_metrics.vertAdvance  * 64;
 
-      (glyph->root).format = FT_GLYPH_FORMAT_BITMAP;
+      glyph->format = FT_GLYPH_FORMAT_BITMAP;
 
       if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
       {
-        (glyph->root).bitmap_left = sbit_metrics.vertBearingX;
-        (glyph->root).bitmap_top  = sbit_metrics.vertBearingY;
+        glyph->bitmap_left = sbit_metrics.vertBearingX;
+        glyph->bitmap_top  = sbit_metrics.vertBearingY;
       }
       else
       {
-        (glyph->root).bitmap_left = sbit_metrics.horiBearingX;
-        (glyph->root).bitmap_top  = sbit_metrics.horiBearingY;
+        glyph->bitmap_left = sbit_metrics.horiBearingX;
+        glyph->bitmap_top  = sbit_metrics.horiBearingY;
       }
     }
 
@@ -2449,6 +2438,7 @@
 
 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
 
+
   static FT_Error
   tt_loader_init( TT_Loader     loader,
                   TT_Size       size,
@@ -2464,12 +2454,12 @@
     FT_Bool    pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
 #if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \
     defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
-    TT_Driver  driver = (TT_Driver)FT_FACE_DRIVER( (TT_Face)(glyph->root).face 
);
+    TT_Driver  driver = (TT_Driver)FT_FACE_DRIVER( (TT_Face)glyph->face );
 #endif
 #endif
 
 
-    face   = (TT_Face)(glyph->root.face);
+    face   = (TT_Face)glyph->face;
     stream = face->root.stream;
 
     FT_ZERO( loader );
@@ -2721,7 +2711,7 @@
     /* get face's glyph loader */
     if ( !glyf_table_only )
     {
-      FT_GlyphLoader  gloader = (glyph->root).internal->loader;
+      FT_GlyphLoader  gloader = glyph->internal->loader;
 
 
       FT_GlyphLoader_Rewind( gloader );
@@ -2785,7 +2775,7 @@
    */
   FT_LOCAL_DEF( FT_Error )
   TT_Load_Glyph( TT_Size       size,
-                 TT_GlyphSlot  glyph_,
+                 TT_GlyphSlot  glyph,
                  FT_UInt       glyph_index,
                  FT_Int32      load_flags )
   {
@@ -2793,9 +2783,6 @@
     TT_LoaderRec  loader;
     SFNT_Service  sfnt;
 
-    /* TODO: (OT-SVG) maybe find a proper way to do this */
-    FT_GlyphSlot  glyph = (FT_GlyphSlot)glyph_;
-
     FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
 
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -2809,7 +2796,7 @@
       FT_Fixed  y_scale = size->root.metrics.y_scale;
 
 
-      error = load_sbit_image( size, glyph_, glyph_index, load_flags );
+      error = load_sbit_image( size, glyph, glyph_index, load_flags );
       if ( FT_ERR_EQ( error, Missing_Bitmap ) )
       {
         /* the bitmap strike is incomplete and misses the requested glyph; */
@@ -2876,7 +2863,7 @@
         if ( FT_IS_SCALABLE( glyph->face ) )
         {
           /* for the bbox we need the header only */
-          (void)tt_loader_init( &loader, size, glyph_, load_flags, TRUE );
+          (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
           (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
           tt_loader_done( &loader );
           glyph->linearHoriAdvance = loader.linear;
@@ -2898,6 +2885,13 @@
 
 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
 
+    /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
+    if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
+    {
+      error = FT_THROW( Invalid_Size_Handle );
+      goto Exit;
+    }
+
     /* check for OT-SVG */
     if ( ( load_flags & FT_LOAD_COLOR ) && ( ((TT_Face)glyph->face)->svg ) )
     {
@@ -2916,7 +2910,7 @@
       goto Exit;
     }
 
-    error = tt_loader_init( &loader, size, glyph_, load_flags, FALSE );
+    error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
     if ( error )
       goto Exit;
 
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index d131a9a..9fc654d 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -41,6 +41,21 @@ FT_BEGIN_HEADER
 
   /**************************************************************************
    *
+   * @Type:
+   *   TT_GlyphSlot
+   *
+   * @Description:
+   *   A handle to a TrueType glyph slot object.
+   *
+   * @Note:
+   *   This is a direct typedef of FT_GlyphSlot, as there is nothing
+   *   specific about the TrueType glyph slot.
+   */
+  typedef FT_GlyphSlot  TT_GlyphSlot;
+
+
+  /**************************************************************************
+   *
    * @Struct:
    *   TT_GraphicsState
    *



reply via email to

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