Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27bb05f2 authored by Raph Levien's avatar Raph Levien
Browse files

Fix native crash when typeface is missing

Creating a typeface from a missing file crashes when it tries to extract
the style from the font. This patch just uses default style when the
resulting font object is NULL.

Bug: 15930808
Change-Id: I9438687100026f336db7aa204fe3a0232eee2db6
parent 6c09004e
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -146,10 +146,14 @@ TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size
        const FontStyle defaultStyle;
        FontFamily* firstFamily = reinterpret_cast<FontFamily*>(families[0]);
        MinikinFont* mf = firstFamily->getClosestMatch(defaultStyle).font;
        if (mf != NULL) {
            SkTypeface* skTypeface = reinterpret_cast<MinikinFontSkia*>(mf)->GetSkTypeface();
            // TODO: probably better to query more precise style from family, will be important
            // when we open up API to access 100..900 weights
            result->fStyle = styleFromSkiaStyle(skTypeface->style());
        } else {
            result->fStyle = defaultStyle;
        }
    }
    return result;
}