summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-05-10 22:22:53 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-05-10 22:22:53 +0000
commitfedd7b75fa6002dbd170d54a3d26042e086c9264 (patch)
tree9922b9b5ccb8606784d9e34a911fc6917e62fb2d /src/libnrtype
parentFix for Wayland. (diff)
downloadinkscape-fedd7b75fa6002dbd170d54a3d26042e086c9264.tar.gz
inkscape-fedd7b75fa6002dbd170d54a3d26042e086c9264.zip
Fix crash with fonts containing illegal characters in family name.
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)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/FontFactory.cpp6
1 files changed, 6 insertions, 0 deletions
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<PangoFontFamily *>& 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));
}