Skip to content

Add test showing segfault when getting glyph range for Osaka#110

Closed
programmarchy wants to merge 1 commit intomapbox:masterfrom
programmarchy:osaka-range-segfault
Closed

Add test showing segfault when getting glyph range for Osaka#110
programmarchy wants to merge 1 commit intomapbox:masterfrom
programmarchy:osaka-range-segfault

Conversation

@programmarchy
Copy link
Contributor

fontnik.range segfaults for the Osaka font included on OS X

Possibly related #13?

@mikemorris
Copy link
Contributor

Thanks for the test case @programmarchy, I'll probably get a chance to look at this more closely in a few days.

@mikemorris mikemorris self-assigned this Mar 10, 2016
@springmeyer
Copy link
Contributor

Proposed fix:

diff --git a/src/glyphs.cpp b/src/glyphs.cpp
index 0525ff0..10400a3 100644
--- a/src/glyphs.cpp
+++ b/src/glyphs.cpp
@@ -548,10 +548,6 @@ void RenderSDF(glyph_info &glyph,
         return;
     }

-    FT_Glyph ft_glyph = nullptr;
-    ft_glyph_guard glyph_guard(&ft_glyph);
-    if (FT_Get_Glyph(ft_face->glyph, &ft_glyph)) return;
-
     int advance = ft_face->glyph->metrics.horiAdvance / 64;
     int ascender = ft_face->size->metrics.ascender / 64;
     int descender = ft_face->size->metrics.descender / 64;
@@ -572,16 +568,22 @@ void RenderSDF(glyph_info &glyph,

     User user;

-    // Decompose outline into bezier curves and line segments
-    FT_Outline outline = ((FT_OutlineGlyph)ft_glyph)->outline;
-    if (FT_Outline_Decompose(&outline, &func_interface, &user)) return;
+    if (ft_face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
+        // Decompose outline into bezier curves and line segments
+        FT_Outline outline = ft_face->glyph->outline;
+        if (FT_Outline_Decompose(&outline, &func_interface, &user)) return;

-    if (!user.ring.empty()) {
-        CloseRing(user.ring);
-        user.rings.push_back(user.ring);
-    }
+        if (!user.ring.empty()) {
+            CloseRing(user.ring);
+            user.rings.push_back(user.ring);
+        }

-    if (user.rings.empty()) return;
+        if (user.rings.empty()) {
+            return;
+        }
+    } else {
+        return;
+    }

     // Calculate the real glyph bbox.
     double bbox_xmin = std::numeric_limits<double>::infinity(),

@springmeyer springmeyer mentioned this pull request Oct 21, 2016
@mikemorris
Copy link
Contributor

Fixed in #116!

@mikemorris mikemorris closed this Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants