Hi Werner,

3 patches, one for freetype2, and two for freetype2-demos (the rsvg one is a 
re-post).

None of them are anything critical. I think I'd really like the rsvg one to go 
in, if only to stay sync with the corresponding python code in  
freetype-py/examples. I am also very sure you do not want it to go in as 
currently is; you most likely want to code the same idea in a different way - 
but it is a start.

The freetype2 one is a discovery from rebasing the Fontval diff. The 3rd one in 
ft2-demos is sort of in the same area, and recent thoughts on RendererHook's 
and DebugHook's signatures.

One thing I'd like to suggest, if FreeType 3 is ever happening, is for the 
DebugHook to move a bit earlier in the Library struct, and especially before 
any of the variable/adjustable sized sub-structures. It makes implementing 
interactive font debuggers / font editors with FreeType 3, and things like 
Fontval, in a non-C language, a bit easier.

Yes, I briefly thought of expanding freetype-py, and re-writing ttdebug in 
python. It cannot happen (easily... alway a matter of how much pain/trouble one 
wants to bear...) for the reason above :-). And same with FontVal-RX - the next 
stage of FontVal, with dual freetype and microsoft backends.

Hin-Tak




From 1aecf30b9ff9ef75a7a3cb1957a0c452ac92da74 Mon Sep 17 00:00:00 2001
From: Hin-Tak Leung <ht...@users.sourceforge.net>
Date: Fri, 7 Jul 2023 19:24:48 +0100
Subject: [PATCH] * src/truetype/ttgload.c (TT_Hint_Glyph): More mostly
 cosmetic update.

This is a follow-up to 49c74ac021f8139e83bbd65df75217d0de284eea,
which creates a new local variable "exec  = loader->exec", and
shortening a lot of "loader->exec". This commit does two more
such changes missed in that first commit.

Signed-off-by: Hin-Tak Leung <ht...@users.sourceforge.net>
---
 src/truetype/ttgload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 238e9533d..430323926 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -820,7 +820,7 @@
       FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
 
     /* Reset graphics state. */
-    loader->exec->GS = loader->size->GS;
+    exec->GS = loader->size->GS;
 
     /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
     /*      completely refer to the (already) hinted subglyphs.     */
@@ -863,7 +863,7 @@
 #ifdef FT_DIAGNOSTICS
       loader->exec->nested_IF_level = 0;
 #endif
-      error = TT_Run_Context( loader->exec );
+      error = TT_Run_Context( exec );
       if ( error && exec->pedantic_hinting )
         return error;
 
-- 
2.41.0

From f0e543f90a7350261d83a6a5a1dfadefd3533ad7 Mon Sep 17 00:00:00 2001
From: Hin-Tak Leung <ht...@users.sourceforge.net>
Date: Fri, 7 Jul 2023 19:54:21 +0100
Subject: [PATCH] [ttdebug] Signature fixes.

A somewhat similar change to what happened in freetype2, in commit
95d635eab1b08a0051de07b6c33067d2c1984848.

commit 95d635eab1b08a0051de07b6c33067d2c1984848
Author: Werner Lemberg <w...@gnu.org>
Date:   Sun May 7 08:34:32 2023 +0200

    [truetype] Signature fixes.

Signed-off-by: Hin-Tak Leung <ht...@users.sourceforge.net>
---
 src/ttdebug.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/ttdebug.c b/src/ttdebug.c
index 188a213..37342be 100644
--- a/src/ttdebug.c
+++ b/src/ttdebug.c
@@ -1978,8 +1978,10 @@
 
 
   static FT_Error
-  RunIns( TT_ExecContext  exc )
+  RunIns( void*  exec )
   {
+    TT_ExecContext  exc = (TT_ExecContext)exec;
+
     FT_Int  key;
 
     FT_Bool  really_leave;
@@ -3052,7 +3054,7 @@
 
     FT_Set_Debug_Hook( library,
                        FT_DEBUG_HOOK_TRUETYPE,
-                       (FT_DebugHook_Func)RunIns );
+                       RunIns );
 
     printf( "%s\n"
             "press key `h' or `?' for help\n"
-- 
2.41.0

From 216f39cec1fe8719762aad593568015bd01622cb Mon Sep 17 00:00:00 2001
From: Hin-Tak Leung <ht...@users.sourceforge.net>
Date: Fri, 30 Jun 2023 02:45:38 +0100
Subject: [PATCH] * src/rsvg-port.c (rsvg_port_preset_slot): simplify usage of
 rsvg_handle_render_*

* src/rsvg-port.c (rsvg_port_preset_slot): Remove usage of `rsvg_handle_render_document'
(and `rsvg_handle_render_cairo'). They are functionally the same as
`rsvg_handle_render_layer' (and `rsvg_handle_render_cairo_sub') with argument
id set to NULL.

Signed-off-by: Hin-Tak Leung <ht...@users.sourceforge.net>
---
 src/rsvg-port.c | 80 +++++++++++++++++--------------------------------
 1 file changed, 27 insertions(+), 53 deletions(-)

diff --git a/src/rsvg-port.c b/src/rsvg-port.c
index 16faa14..5861e19 100644
--- a/src/rsvg-port.c
+++ b/src/rsvg-port.c
@@ -334,69 +334,43 @@
     /* If the document contains only one glyph, `start_glyph_id` and */
     /* `end_glyph_id` have the same value.  Otherwise `end_glyph_id` */
     /* is larger.                                                    */
-    if ( start_glyph_id == end_glyph_id )
-    {
-      /* Render the whole document to the recording surface. */
-#if LIBRSVG_CHECK_VERSION( 2, 52, 0 )
-      {
-        RsvgRectangle  viewport =
-        {
-          .x = 0,
-          .y = 0,
-          .width  = (double)dimension_svg.width,
-          .height = (double)dimension_svg.height,
-        };
-
-
-        ret = rsvg_handle_render_document( handle,
-                                           rec_cr,
-                                           &viewport,
-                                           NULL );
-      }
-#else
-      ret = rsvg_handle_render_cairo( handle, rec_cr );
-#endif
-
-      if ( ret == FALSE )
-      {
-        error = FT_Err_Invalid_SVG_Document;
-        goto CleanCairo;
-      }
-    }
-    else if ( start_glyph_id < end_glyph_id )
-    {
-      char  str[32] = "#glyph";
 
+    /* NULL = Render the whole document */
+    char  *id      = NULL;
+    char  str[32]  = "#glyph";
 
+    if ( start_glyph_id < end_glyph_id )
+    {
       /* Render only the element with its ID equal to `glyph<ID>`. */
       sprintf( str + 6, "%u", slot->glyph_index );
+      id = str;
+    }
 
 #if LIBRSVG_CHECK_VERSION( 2, 52, 0 )
+    {
+      RsvgRectangle  viewport =
       {
-        RsvgRectangle  viewport =
-        {
-          .x = 0,
-          .y = 0,
-          .width  = (double)dimension_svg.width,
-          .height = (double)dimension_svg.height,
-        };
-
-
-        ret = rsvg_handle_render_layer( handle,
-                                        rec_cr,
-                                        str,
-                                        &viewport,
-                                        NULL );
-      }
+        .x = 0,
+        .y = 0,
+        .width  = (double)dimension_svg.width,
+        .height = (double)dimension_svg.height,
+      };
+
+
+      ret = rsvg_handle_render_layer( handle,
+                                      rec_cr,
+                                      id,
+                                      &viewport,
+                                      NULL );
+    }
 #else
-      ret = rsvg_handle_render_cairo_sub( handle, rec_cr, str );
+    ret = rsvg_handle_render_cairo_sub( handle, rec_cr, id );
 #endif
 
-      if ( ret == FALSE )
-      {
-        error = FT_Err_Invalid_SVG_Document;
-        goto CleanCairo;
-      }
+    if ( ret == FALSE )
+    {
+      error = FT_Err_Invalid_SVG_Document;
+      goto CleanCairo;
     }
 
     /* Get the bounding box of the drawing. */
-- 
2.41.0

Reply via email to