mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
295 stars 28 forks source link

add checks for return value of FT_Load_Glyph #207

Closed the-shank closed 1 year ago

the-shank commented 1 year ago

FT_Load_Glyph returns a non-zero value if there was any error. This PR adds checks to handle the non-zero return values from FT_Load_Glyph.

mgieseki commented 1 year ago

Thank you for providing the patch. Would you mind to change the conditional blocks so that the return 0 statement at the end of the functions is used in all cases in order to avoid the additional returns? For example:

int FontEngine::getHAdvance (const Character &c) const {
    if (_currentFace) {
        if (FT_Load_Glyph(_currentFace, charIndex(c), FT_LOAD_NO_SCALE) == 0)
            return _currentFace->glyph->metrics.horiAdvance;
    }
    return 0;
}

Please also use tabs instead of spaces to indent the code. I could also adapt the patch accordingly if you prefer that.

the-shank commented 1 year ago

Both good points. My apologies that I missed the tab convention. I will update the PR as per your comments.

the-shank commented 1 year ago

I have updated as per the comments. Please let me know if this looks right now. Thanks.

mgieseki commented 1 year ago

Thank you for the update. Your changes will be part of the next release.