freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] sdf 21c287f 6/9: [ftsdf] Add main function.


From: Werner LEMBERG
Subject: [freetype2-demos] sdf 21c287f 6/9: [ftsdf] Add main function.
Date: Tue, 22 Dec 2020 12:07:37 -0500 (EST)

branch: sdf
commit 21c287f72b89950d69d8740fdd3e1ea0dc7da616
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: Werner Lemberg <wl@gnu.org>

    [ftsdf] Add main function.
    
    * src/ftsdf.c (main): New function.
---
 ChangeLog   |  6 ++++++
 src/ftsdf.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 5cdffbe..34a0607 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-08-22  Anuj Verma  <anujv@iitbhilai.ac.in>
 
+       [ftsdf] Add main function.
+
+       * src/ftsdf.c (main): New function.
+
+2020-08-22  Anuj Verma  <anujv@iitbhilai.ac.in>
+
        [ftsdf] Draw SDF to display.
 
        * src/ftsdf.c (clamp, smoothstep, draw): New function.
diff --git a/src/ftsdf.c b/src/ftsdf.c
index 03e64fc..9842832 100644
--- a/src/ftsdf.c
+++ b/src/ftsdf.c
@@ -634,4 +634,68 @@
   }
 
 
+  int
+  main( int     argc,
+        char**  argv )
+  {
+    FT_Error  err = FT_Err_Ok;
+
+
+    if ( argc != 3 )
+    {
+      printf( "Usage: [ptsize] [font file]\n" );
+      exit( -1 );
+    }
+
+    status.ptsize = atoi( argv[1] );
+
+    handle = FTDemo_New();
+    if ( !handle )
+    {
+      printf( "Failed to create FTDemo_Handle\n" );
+      goto Exit;
+    }
+
+    display = FTDemo_Display_New( NULL, "800x600" );
+    if ( !display )
+    {
+      printf( "Failed to create FTDemo_Display\n" );
+      goto Exit;
+    }
+
+#ifdef __linux__
+    int  flip_y = 1;
+
+    FT_CALL( FT_Property_Set( handle->library, "sdf", "flip_y", &flip_y ) );
+    FT_CALL( FT_Property_Set( handle->library, "bsdf", "flip_y", &flip_y ) );
+#endif
+
+    grSetTitle( display->surface, "Signed Distance Field Viewer" );
+    event_color_change();
+
+    FT_CALL( FT_New_Face( handle->library, argv[2], 0, &status.face ) );
+    FT_CALL( event_font_update() );
+
+    do
+    {
+      FTDemo_Display_Clear( display );
+
+      draw();
+      write_header();
+
+      grRefreshSurface( display->surface );
+
+    } while ( !Process_Event() );
+
+  Exit:
+    if ( status.face )
+      FT_Done_Face( status.face );
+    if ( display )
+      FTDemo_Display_Done( display );
+    if ( handle )
+      FTDemo_Done( handle );
+
+    exit( err );
+  }
+
 /* END */



reply via email to

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