shithub: freetype+ttf2subf

Download patch

ref: b6fa8451461b51cc793a4cd0ab17350e3e6ae9fe
parent: 05bf6877a4b03fa1ea5e2b99f2318104a9de0294
author: Werner Lemberg <[email protected]>
date: Sun Dec 21 04:46:31 EST 2008

* src/autofit/aflatin.c (af_latin_hint_edges),
src/autofit/aflatin2.c (af_latin2_hint_edges), src/autofit/afcjk.c
(af_cjk_hint_edges): Protect against division by zero.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-21  Hongbo Ni  <[email protected]>
+
+	* src/autofit/aflatin.c (af_latin_hint_edges),
+	src/autofit/aflatin2.c (af_latin2_hint_edges), src/autofit/afcjk.c
+	(af_cjk_hint_edges): Protect against division by zero.
+
 2008-12-18  Werner Lemberg  <[email protected]>
 
 	* docs/CHANGES: Updated.
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -1253,10 +1253,15 @@
         else if ( after >= edge_limit )
           af_cjk_align_serif_edge( hints, before, edge );
         else
-          edge->pos = before->pos +
-            FT_MulDiv( edge->fpos - before->fpos,
-                       after->pos - before->pos,
-                       after->fpos - before->fpos );
+        {
+          if ( after->fpos == before->fpos )
+            edge->pos = before->pos;
+          else
+            edge->pos = before->pos +
+                        FT_MulDiv( edge->fpos - before->fpos,
+                                   after->pos - before->pos,
+                                   after->fpos - before->fpos );
+        }
       }
     }
   }
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -2008,7 +2008,10 @@
           if ( before >= edges && before < edge   &&
                after < edge_limit && after > edge )
           {
-            edge->pos = before->pos +
+            if ( after->opos == before->opos )
+              edge->pos = before->pos;
+            else
+              edge->pos = before->pos +
                           FT_MulDiv( edge->opos - before->opos,
                                      after->pos - before->pos,
                                      after->opos - before->opos );
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -2153,7 +2153,10 @@
           if ( before >= edges && before < edge   &&
                after < edge_limit && after > edge )
           {
-            edge->pos = before->pos +
+            if ( after->opos == before->opos )
+              edge->pos = before->pos;
+            else
+              edge->pos = before->pos +
                           FT_MulDiv( edge->opos - before->opos,
                                      after->pos - before->pos,
                                      after->opos - before->opos );