From fedd7b75fa6002dbd170d54a3d26042e086c9264 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Thu, 11 May 2017 00:22:53 +0200 Subject: Fix crash with fonts containing illegal characters in family name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the problem at hand [1] the crash is caused by a font with the name "Æ Systematic -BRK-". However the font family name returned by pango is "\xc6 Systematic - BRK-". "(\xc6" is the character code of "Æ" in Latin-1 encoding, but is not a valid UTF-8 character, so obviously at some point there went something wrong with character encoding conversion) At this time it is unclear to me where in the chain the issue originates, as it's possible that a) the font name is already stored incorrectly in the font file b) fontconfig incorrectly parses the font file when creating the font cache c) pango messes up somehow For now we ignore fonts with illegal characters in file name as they cause a whole lot of issues (even before triggering a crash), but figuring out the above and (if applicable) work around it in Inkscape might make the font available after all. [1] https://answers.launchpad.net/inkscape/+question/630886 (bzr r15687) --- src/libnrtype/FontFactory.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 6865e923e..770616ae7 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -298,6 +298,12 @@ void font_factory::GetUIFamilies(std::vector& out) std::cerr << "font_factory::GetUIFamilies: Missing displayName! " << std::endl; continue; } + if (!g_utf8_validate(displayName, -1, 0)) { + // TODO: can can do anything about this or does it always indicate broken fonts that should not be used? + std::cerr << "font_factory::GetUIFamilies: Illegal characters in displayName. "; + std::cerr << "Ignoring font '" << displayName << "'" << std::endl; + continue; + } sorted.push_back(std::make_pair(families[currentFamily], displayName)); } -- cgit v1.2.3