From 179538a2098fe6ae701bdb20e538b92ff7a4ffe7 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 23 Sep 2017 20:01:24 +0200 Subject: Do not crash if no fonts are available Usually we fall back to "sans-serif" but if not a single fallback was available (this happens for example if the fontconfig configuration is invalid) Inkscape crashed. Fixed bug: - https://bugs.launchpad.net/inkscape/+bug/1716516 --- src/libnrtype/FontFactory.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 5c6a96694..40e5d4ba1 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -689,9 +689,12 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) pango_font_description_set_family(descr,"sans-serif"); res = Face(descr,false); pango_font_description_free(descr); + } else { + g_critical("Could not load any face for font '%s'.", pango_font_description_to_string(descr)); } } + if (res) { // Extract which OpenType tables are in the font. We'll make a list of all tables // regardless of which script and langauge they are in. This Harfbuzz code replaces // an earlier Pango version as the Pango functions are deprecated. @@ -836,6 +839,7 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) hb_face_destroy (face); g_free(scripts_hb); + } } else { // already here res = loadedFaces[descr]; -- cgit v1.2.3