Crash when setting empty font family

Bug #805238 reported by Andreas Becker
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
High
Andreas Becker

Bug Description

Version: Inkscape 0.48+devel r10413 and the official 0.48.1
pango 1.28.4-3
OS: Arch Linux 2.6.39-ARCH on x86_64

When the font family is set to an empty string in the user interface, Inkscape crashes. I used the text tool from the toolbox (shortcut F8) to write the text.

The crash occurs, because the return value of "pango_font_description_get_family(fontDescr)" is not checked. When the font family in fontDescr is empty, the return value is NULL, and this causes an error when assigning NULL to the "Glib:ustring family" variable.

The attached patch solves the problem. An empty font family is now always changed to the default "Sans".

Tags: crash fonts
Revision history for this message
Andreas Becker (abecker) wrote :
Revision history for this message
Alvin Penner (apenner) wrote :

the crash is confirmed on Windows XP, bzr rev 10356
However, the use of Sans as a default may not be appropriate on a Windows machine. In my case, if I choose Sans I get the following DOS message:
** (inkscape.exe:3376): WARNING **: Ignoring font without family that will crash Pango

After choosing Sans, this choice is ignored, and instead I get Tunga which is the next in line.
- if at all possible, would it be appropriate to revert back to the previous (presumably valid) choice rather than specifying a hard-coded default?

Changed in inkscape:
status: New → Confirmed
Revision history for this message
su_v (suv-lp) wrote :

<off-topic>
Alvin Penner wrote
> However, the use of Sans as a default may not be appropriate on
> a Windows machine. In my case, if I choose Sans I get the
> following DOS message:
> ** (inkscape.exe:3376): WARNING **: Ignoring font without
> family that will crash Pango

Could it be that you migrated your preferences file from 0.47 without completely resetting it? Based on other reports, this happens if the default font in Inkscape (stored in the preferences) is not installed on the local machine. Older Inkscape version used 'Vera Bitstream Sans' as default font, 0.48 and later uses the generic 'Sans' as default font [1] (it is up to the font backend to choose a matching font - AFAIK on Windows, the font backend uses 'Arial' for rendering the generic family 'Sans').

Please test this: open 'Text > Text and Font...' dialog, select 'Sans' and make it the default font (button in the lower left corner). If you still can't choose other font families, try setting a known installed font as new default font in Inkscape.

(see also bug #667091)

[1] <http://wiki.inkscape.org/wiki/index.php/Release_notes/0.48#Notable_bug_fixes>
<off-topic>

Revision history for this message
su_v (suv-lp) wrote :

Crash reproduced with Inkscape 0.48.1 and 0.48+devel r10412 on Mac OS X 10.5.8 (i386)

Steps to reproduce:
1) switch to text tool ('T')
2) click on canvas and enter a text
3) switch focus to font family selector ('Alt+X')
4) delete current family name (<Del> or <Backspace>)
5) confirm empty string with <Return>

-> crash

Changed in inkscape:
importance: Undecided → High
status: Confirmed → Triaged
Revision history for this message
su_v (suv-lp) wrote :

@Alvin - sorry, nevermind my previous comment #3.

I can reproduce the console warning, but only if I change the font family name without having an active text object on-canvas (no blinking text cursor) - it doesn't seem to matter whether an existing/installed font (e.g. Arial), a non-existent font (e.g. Arialx) or a generic font family (Sans) is entered. This message occurs whether the patch has been applied or not, in 0.48.1 and current trunk.

IIUC changing the font without active text object sets the default font - the cause for the warning might be elsewhere in the code.

The patch tests ok in r10413 on OS X 10.5.8 (i386), both with the X11 backend as well as with GTK+/Quartz, installed pango version is 1.28.4 (for both backends).

Revision history for this message
Alvin Penner (apenner) wrote :

no problem, I didn't realize that Sans might be the equivalent of Arial on Windows. My default font in Inkscape is actually Arial, just to be safe. My main concern was that normally it is preferable to revert back to the last valid choice rather than reverting back to a factory default.

Revision history for this message
su_v (suv-lp) wrote :

> it is preferable to revert back to the last valid choice
> rather than reverting back to a factory default.

Might also depend on the tool preferences set for the text tool ('This tool's own style' (default setting) or 'Last style used')?

jazzynico (jazzynico)
tags: added: crash fonts
Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

Patch applied in trunk. Thanks Andreas

Revision history for this message
su_v (suv-lp) wrote :

Inkscape trunk: r10487

Changed in inkscape:
assignee: nobody → Andreas Becker (abecker)
milestone: none → 0.49
status: Triaged → Fix Committed
Revision history for this message
su_v (suv-lp) wrote :

The changes from r10487 merge cleanly into <lp:inkscape/0.48.x>, and fix the crash otherwise easily reproducible with current stable 0.48.4 (tested with 0.48.x r9963 on OS X 10.7.5).

Proposing to include the fix in 0.48.5.

tags: added: backport-proposed
Revision history for this message
jazzynico (jazzynico) wrote :

Fix confirmed on Windows XP, branch revision 9663.

Revision history for this message
su_v (suv-lp) wrote :

Backport committed in lp:inkscape/0.48.x r9964.

Changed in inkscape:
milestone: 0.49 → 0.48.5
Revision history for this message
su_v (suv-lp) wrote :

Backport reverted in r9969, needs more investigation:

Current trunk crashes when editing text with empty font family created with 0.48.x r9964. Unlike trunk, stable 0.48.x does not seem insert the default fallback font name, but leaves the font family undefined:

       style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:;-inkscape-font-specification:;font-stretch:normal;font-variant:normal"

Changed in inkscape:
milestone: 0.48.5 → 0.49
Revision history for this message
jazzynico (jazzynico) wrote :

Backporting to 0.48.x would need a separate patch. Tag removed.

tags: removed: backport-proposed
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.