freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] GSoC-2017-kushal 828e893 53/70: Some Bug Fixes


From: Kushal K S V S
Subject: [freetype2] GSoC-2017-kushal 828e893 53/70: Some Bug Fixes
Date: Sun, 18 Mar 2018 11:21:18 -0400 (EDT)

branch: GSoC-2017-kushal
commit 828e89379d4a8971d061a86f94bdf0a0a9f6595a
Author: Kushal K S V S <address@hidden>
Commit: Kushal K S V S <address@hidden>

    Some Bug Fixes
---
 tests/make_png/Makefile      |  1 -
 tests/make_png/bitmap.h      |  1 +
 tests/make_png/make_sprite.c | 52 +++++++++++++++++++++++++++++++++++++-------
 tests/make_png/runme.sh      | 47 ++++++++++++++++++++++-----------------
 4 files changed, 72 insertions(+), 29 deletions(-)

diff --git a/tests/make_png/Makefile b/tests/make_png/Makefile
index 5e49d58..d7aa2ca 100644
--- a/tests/make_png/Makefile
+++ b/tests/make_png/Makefile
@@ -4,7 +4,6 @@ BUILD_DIR := $(TOP_DIR)/builds/unix
 include $(TOP_DIR)/builds/unix/unix-def.mk
 
 SRC_SPRITE = make_sprite.c bitmap.c murmur3.c
-SRC_LIB = $(libdir)/libfreetype.a
 
 OBJS = $(src:.c=.o)
 
diff --git a/tests/make_png/bitmap.h b/tests/make_png/bitmap.h
index 81094cf..1c206ef 100644
--- a/tests/make_png/bitmap.h
+++ b/tests/make_png/bitmap.h
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <unistd.h>
+#include <string.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/tests/make_png/make_sprite.c b/tests/make_png/make_sprite.c
index 66e8dc0..f51f88c 100644
--- a/tests/make_png/make_sprite.c
+++ b/tests/make_png/make_sprite.c
@@ -13,7 +13,7 @@ int main(int argc, char const *argv[])
   const char*      base_version; 
   const char*      test_version; 
   const char*      font_file;
-  int              size; 
+  int              size;
   int              render_mode;
   int              dpi;
 
@@ -44,7 +44,9 @@ int main(int argc, char const *argv[])
   FT_Error         error;
 
   int alignment = 4;
-  char * output_file_name = ( char * )calloc(100,sizeof(char));
+  int output_file_size = 100 + strlen(argv[3]);
+  char * output_file_name = (char *)calloc( output_file_size,
+                                            sizeof(char));
 
   IMAGE* base_png        = (IMAGE*)malloc(sizeof(IMAGE));
   IMAGE* test_png        = (IMAGE*)malloc(sizeof(IMAGE));
@@ -61,6 +63,7 @@ int main(int argc, char const *argv[])
   int pixel_diff, i;
 
   char glyph_name[50] = ".not-def";
+
 /*******************************************************************/
 
   FT_Error ( *Base_Init_FreeType )( FT_Library* );
@@ -314,10 +317,27 @@ int main(int argc, char const *argv[])
   test_slot = test_face->glyph;
 
   /* Initialising file pointer for the list-view*/
-  sprintf( output_file_name, "./html/pages/%d/%s/%d/%d/index.html",dpi, 
font_file, render_mode, size );
+  if (snprintf( output_file_name,
+            output_file_size,
+            "./html/pages/%d/%s/%d/%d/index.html",
+            dpi,
+            font_file,
+            render_mode,
+            size )
+            > output_file_size )
+  {
+    printf("Buffer overflow. Increase output_file_size\n");
+    exit(1);
+  }
 
   FILE* fp = fopen(output_file_name,"w");
   
+  if (fp == NULL)
+  {
+    printf("Error opening file\n");
+    exit(1);
+  }
+
   Print_Head(fp,base_face->family_name,base_face->style_name,size,dpi);
 
 /* Need to write code to check the values in FT_Face and compare */
@@ -429,13 +449,29 @@ int main(int argc, char const *argv[])
 
       if (FT_HAS_GLYPH_NAMES(base_face))
       {
-        Base_Get_Glyph_Name( base_face,
-                             i,
-                             glyph_name,
-                             50 );
+        error = Base_Get_Glyph_Name( base_face,
+                                     i,
+                                     glyph_name,
+                                     50 );
+        if (error)
+        {
+          printf("Error setting glyph name\n");
+        }
       }
 
-      sprintf( output_file_name, "./html/pages/%d/%s/%d/%d/images/%s.png",dpi, 
font_file, render_mode, size, glyph_name );
+      if (snprintf( output_file_name,
+                    output_file_size,
+                    "./html/pages/%d/%s/%d/%d/images/%s.png",
+                    dpi,
+                    font_file,
+                    render_mode,
+                    size,
+                    glyph_name )
+                    > output_file_size)
+      {
+        printf("Buffer Overflow. Increase size of glyph_name\n");
+        exit(1);
+      }
 
       Generate_PNG ( output, output_file_name, render_mode );
       /* To print table row to HTML file */
diff --git a/tests/make_png/runme.sh b/tests/make_png/runme.sh
index 8137925..819c18c 100755
--- a/tests/make_png/runme.sh
+++ b/tests/make_png/runme.sh
@@ -1,9 +1,16 @@
 rm -rf ./html/pages
 rm -f ./html/top.html
 #####################################################################
-FT_TEST_TEST_DIR=../..
-FT_TEST_BASE_LIB=$FT_TEST_BASE_DIR/objs/.libs/libfreetype.so
-FT_TEST_TEST_LIB=$FT_TEST_TEST_DIR/objs/.libs/libfreetype.so
+FT_TEST_DPI=${FT_TEST_DPI:-72 96};
+FT_TEST_FONT_FILE=${FT_TEST_FONT_FILE:-test.ttf};
+FT_TEST_RENDER_MODE=${FT_TEST_RENDER_MODE:-1 2};
+FT_TEST_PT_SIZE=${FT_TEST_PT_SIZE:-16 20};
+
+FT_TEST_BASE_DIR=${FT_TEST_BASE_DIR:-$HOME/base};
+FT_TEST_TEST_DIR=${FT_TEST_TEST_DIR:-../..};
+
+FT_TEST_BASE_DLL=${FT_TEST_BASE_DLL:-$FT_TEST_BASE_DIR/objs/.libs/libfreetype.so};
+FT_TEST_TEST_DLL=$FT_TEST_TEST_DIR/objs/.libs/libfreetype.so
 #####################################################################
 mkdir ./html/pages
 touch ./html/top.html;
@@ -17,51 +24,51 @@ echo '
     <link rel="stylesheet" type="text/css" href="styles/top.css">
   </head>
   <html>
-    <body>
+    <body onload="change()">
       <iframe id="frame_1" name="frame_1" src="" ></iframe>
       <iframe id="frame_2" name="frame_2" src="diff.html" ></iframe>
       <div class="select">
     '>./html/top.html;
 #####################################################################
 for i in $FT_TEST_DPI; do
-       mkdir ./html/pages/$i
-       for j in $FT_TEST_FONT_FILE; do
-               mkdir ./html/pages/$i/$j
-               for k in $FT_TEST_RENDER_MODE; do
-                       mkdir ./html/pages/$i/$j/$k
-                       for l in $FT_TEST_PT_SIZE; do
-                               mkdir ./html/pages/$i/$j/$k/$l
-                               mkdir ./html/pages/$i/$j/$k/$l/images
-                               ./tests $FT_TEST_BASE_LIB $FT_TEST_TEST_LIB $j 
$l $k $i
-                       done
-               done
-       done
+  mkdir ./html/pages/$i
+  for j in $FT_TEST_FONT_FILE; do
+    mkdir ./html/pages/$i/$j
+    for k in $FT_TEST_RENDER_MODE; do
+      mkdir ./html/pages/$i/$j/$k
+      for l in $FT_TEST_PT_SIZE; do
+        mkdir ./html/pages/$i/$j/$k/$l
+        mkdir ./html/pages/$i/$j/$k/$l/images
+        ./tests $FT_TEST_BASE_DLL $FT_TEST_TEST_DLL $j $l $k $i
+      done
+    done
+  done
 done
 #####################################################################
 echo '<label>DPI&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:<select name="dpi" 
id="dpi" onchange="change()">'>>./html/top.html;
 for i in $FT_TEST_DPI; do
-       echo "  <option value= $i > $i </option>">>./html/top.html;
+  echo "  <option value= $i > $i </option>">>./html/top.html;
 done
 echo '</select>
     </label><br>'>>./html/top.html;
 #####################################################################
 echo '<label>Font&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:<select name="font" 
id="font" onchange="change()">'>>./html/top.html;
 for i in $FT_TEST_FONT_FILE; do
-       echo "  <option value= $i > $i </option>">>./html/top.html;
+  echo "  <option value= $i > $i </option>">>./html/top.html;
 done
 echo '</select>
     </label><br>'>>./html/top.html;
 #####################################################################
 echo '<label>Render Mode:<select name="mode" id="mode" 
onchange="change()">'>>./html/top.html;
 for i in $FT_TEST_RENDER_MODE; do
-       echo "  <option value= $i > $i </option>">>./html/top.html;
+  echo "  <option value= $i > $i </option>">>./html/top.html;
 done
 echo '</select>
     </label><br>'>>./html/top.html;
 #####################################################################
 echo '<label>Size&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:<select name="size" 
id="size" onchange="change()">'>>./html/top.html;
 for i in $FT_TEST_PT_SIZE; do
-       echo "  <option value= $i > $i </option>">>./html/top.html;
+  echo "  <option value= $i > $i </option>">>./html/top.html;
 done
 echo '</select>
     </label><br>'>>./html/top.html;



reply via email to

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