GNOME Bugzilla – Bug 455940
empty lines have height 0
Last modified: 2018-05-22 12:30:46 UTC
Please describe the problem: When I lay out text that contains empty lines and the layout object has a font description with more than one font familiy, the empty lines will have height zero. Steps to reproduce: /* create and init caito_t *cr, PangoLayout *layout ... */ PangoFontDescription *desc = pango_font_description_from_string("Times,Arial 20"); pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); pango_layout_set_text(layout,"LINE 1\n\nLINE 3",-1); pango_cairo_show_layout(cr,layout); Actual results: The layout's font description contains 2 fonts (Times and Arial) with size 20. The output is: LINE 1 LINE 3 Expected results: The output should be: LINE 1 LINE 3 Does this happen every time? Yes, it happens every time when more than one font family is given. It does not happen at all when only one font family is given. Other information: I am using Pango 1.17.3 on Windows.
Works on Linux. Bug 457990 may be relevant.
Peter, is this still a problem? If it is, could you please provide a *complete* and *minimal* test program, thanks.
*** Bug 559014 has been marked as a duplicate of this bug. ***
There was a nice test program in bug #559014, attaching it here, slightly simplified.
Created attachment 146903 [details] Test program Run with a font family name as the command-line argument. Try with "Courier", "Courier New" and "Arial" for instance. Note that for "Courier" the blank lines have zero height, but not for "Courier New" not. (This is on WS2008R2, i.e. Windows 7, at least.) Interesting. OTOH in the Windows 7 Control Panel's Fonts thingie, I don't even see any font called just "Courier", but instead "Courier Regular", in addition to "Courier New". Hmmm.
Actually I am not sure whether bug #559014 is a duplicate or not. The code is different, here you use pango_font_description_from_string() and then pango_layout_set_font_description() while the test program above, from that other bug, uses pango attribute lists. Probably this just eventually ends up in the same code paths, though. Anyway, Peter, part of your problem is presumably that you assume there is a font called "Times" while it actually is called "Times New Roman". Does it help for you if you use "times new roman,arial 20" instead of "times,arial 20" ? Also, it is a known problem that the Windows font code in Pango doesn't accept lists of font families in the same situations where the fontconfig-based one used on X11 does. There is some separate bug already filed for that.
The font name "courier" is taken care of by the built-in aliases list "builtin_aliases" in pango-utils.c, used on Windows. It has "courier = \"courier new\"", I still don't understand why this causes the effect described in comment #5, though. Also interesting is that the aliases list has both "mono = \"dejavu sans mono,courier new,lucida console,courier monothai,mingliu,simsun,gulimche,ms gothic,sylfaen,kartika,latha,mangal,raavi\"", and "monospace = \"dejavu sans mono,courier new,lucida console,courier monothai,mingliu,simsun,gulimche,ms gothic,sylfaen,kartika,latha,mangal,raavi\"" i.e. exactly the same list as alias for "mono" and "monospace". Still running the test program with "mono" and "monospace" produces different results. Weird.
Created attachment 146932 [details] minimal testcase example: main.exe out.png "Times New Roman,Courier New 20" console output: Test case for Pango Bug 455940 Pango version: 1.26.0 using font description "Times New Roman,Courier New 20" with text: "LINE 1 LINE 3" height (pango units): 63488
#6: The second line has heigt zero in both cases "Times,Arial 20" and "Times New Roman,Arial 20" #7: With "mono 20" the second line also has height zero, but with "monospace 20" it has the correct dimensions (I am currently using Windows Vista SP 1)
Reopening as the requested information has been provided.
This bug appears to be still outstanding as of 2016-02-15, using pango 1.39.0 under Windows (at least 7 through to 10). I observe exactly the same symptoms as the original reporter, downstream bug report at https://gna.org/bugs/?21649 Stack trace is below: libpangowin32-1.0-0.dll!pango_win32_font_map_load_font(_PangoFontMap * fontmap, _PangoContext * context, const _PangoFontDescription * description) Line 882 C libpango-1.0-0.dll!pango_font_map_load_font(_PangoFontMap * fontmap, _PangoContext * context, const _PangoFontDescription * desc) Line 95 C libpango-1.0-0.dll!pango_context_load_font(_PangoContext * context, const _PangoFontDescription * desc) Line 319 C libpango-1.0-0.dll!pango_layout_get_empty_extents_at_index(_PangoLayout * layout, int index, _PangoRectangle * logical_rect) Line 4550 C libpango-1.0-0.dll!pango_layout_line_get_empty_extents(_PangoLayoutLine * line, _PangoRectangle * logical_rect) Line 4590 C libpango-1.0-0.dll!pango_layout_line_get_extents(_PangoLayoutLine * line, _PangoRectangle * ink_rect, _PangoRectangle * logical_rect) Line 4819 C libpango-1.0-0.dll!get_line_extents_layout_coords(_PangoLayout * layout, _PangoLayoutLine * line, int layout_width, int y_offset, int * baseline, _PangoRectangle * line_ink_layout, _PangoRectangle * line_logical_layout) Line 2550 C libpango-1.0-0.dll!pango_layout_get_extents_internal(_PangoLayout * layout, _PangoRectangle * ink_rect, _PangoRectangle * logical_rect, _GSList * * line_extents) Line 2661 C libpango-1.0-0.dll!pango_layout_get_extents(_PangoLayout * layout, _PangoRectangle * ink_rect, _PangoRectangle * logical_rect) Line 2785 C libpango-1.0-0.dll!pango_layout_get_pixel_extents(_PangoLayout * layout, _PangoRectangle * ink_rect, _PangoRectangle * logical_rect) Line 2811 C We are using font family "DejaVu Sans,Andagii,Droid Sans Japanese,Droid Sans Fallback,Junicode", where all except Junicode are provided as part of the software package. Is there a work around available? I'm not sure about the last paragraph of comment 6 - is this a situation where we should not be using a list of font families under Windows? Thanks for your time and help.
Ouch! I don't have access to Windows. Anyone who can debug this? Thanks.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/84.