Still confused. What's wrong with an outline with 0 contours and points. Ie. empty?
On Thu, Aug 25, 2016 at 2:26 AM, Werner LEMBERG <[email protected]> wrote: > >>> I found a .ttf file on the web whose outline->n_points and >>> outline->n_contours are zero. FT_Outline_Check() reports success >>> because of this condition: >>> >>> /* empty glyph? */ >>> if ( n_points == 0 && n_contours == 0 ) >>> return FT_Err_Ok; >>> >>> However, the for loop in FT_Outline_Decompose() >>> >>> for ( n = 0; n < outline->n_contours; n++ ) >>> >>> is never executed which implies that the if condition should >>> return failure. I gather that FT_Outline_Decompose() should be >>> called only if FT_Outline_Check() returns success, but, according >>> to current code and one of my test files, FT_Outline_Decompose() >>> should not be called at all. >>> >>> If you agree, can you fix the if statement in the next release? >>> And, maybe, you even need to change "and" to "or" as well. >>> >>> I'm inclined to do that, also clarifying the documentation to >>> explicitly explain what a valid outline means. >> >> I don't understand what the problem is. What am I missing? > > Ah, ok. Here's the contributor's code snippet, part of a new tutorial > example that will demonstrate the `FT_Outline_Decompose' function to > print a single character's outline in SVG format. > > // This function is a work around a minor bug in FT_Outline_Check() > // in FreeType 2.6.5 (see comment below). It's better to check an > // outline and display an error message for some .ttf files that we > // don't know how handle than to generate an empty path element. > > bool OutlinePrinter::CheckOutline() const > { > FT_Face face = m_face.m_ftFace; > FT_GlyphSlot slot = face->glyph; > FT_Outline &outline = slot->outline; > > > if (slot->format != FT_GLYPH_FORMAT_OUTLINE) > return false; // Should never happen. Just an extra check > > // We need to perform this check because FT_Outline_Check() in > // FreeType 2.6.5 returns success for outlines with n_contours and > // n_points equal to zero. There are such *.ttf files and in this > // case FT_Outline_Decompose() will return success too without > // doing anything because it iterates over the contours. > > if (outline.n_contours <= 0 || outline.n_points <= 0) > return false; // This happens for some *.ttf files > > FT_Error error = FT_Outline_Check(&outline); > > return error == 0; > } > > > Werner -- behdad http://behdad.org/ _______________________________________________ Freetype-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype-devel
