After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 310700 - Support for aliases in win32 load_font() implementation
Support for aliases in win32 load_font() implementation
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: win32
1.9.x
Other All
: Normal normal
: Small fix
Assigned To: gtk-win32 maintainers
pango-maint
Depends on:
Blocks:
 
 
Reported: 2005-07-18 06:30 UTC by Tor Lillqvist
Modified: 2008-05-27 01:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Suggested patch (1.30 KB, patch)
2005-07-18 06:32 UTC, Tor Lillqvist
needs-work Details | Review

Description Tor Lillqvist 2005-07-18 06:30:51 UTC
The function pango_layout_line_get_empty_extents() is called for instance with a
layout that has a font description that uses the name "sans". With a
fontconfig-based Pango backend, "sans" apparently works also as a font name, but
isn't a name like that supposed to be used to load a fontset? Or am I confused?

Currently there is a rather odd piece of code in pangowin32-fontmap.c that makes
pango_layout_line_get_empty_extents() find a font "sans" also on Win32. (Look
for the comment "Thought pango.aliases would make this code unnecessart, but
no".) There is an entry in ChangeLog.pre-1-2 that says:

        * pango/pangowin32-fontmap.c (pango_win32_insert_font): Revert
	change from 2002-09-21: Don't bypass the code that automatically
	adds fonts to the families "monospace", "serif" and "sans". I
	thought it would be unnecessary if you have a pango.aliases that
	sets up aliases for these family names, but apparently
	not. Without this code, pango_layout_line_get_empty_extents()
	thinks empty lines have zero height, as it tries to use a font
	called "sans" for instance, and no aliases get used.

If I change pango_layoyt_line_get_empty_extents() to use a fontset instead of a
font, the odd piece of crap in pangowin32-fontmap.c can be removed, which is
nice. Patch attached.
Comment 1 Tor Lillqvist 2005-07-18 06:32:04 UTC
Created attachment 49340 [details] [review]
Suggested patch
Comment 2 Owen Taylor 2005-07-21 22:38:19 UTC
I think we really do want font metrics here not fontset metrics ... fontset
metrics tend to be bigger (all scripts that could be used), while here we
really want the extents of an empty line to be the same of a line with
just a single space in them.

What I'd suggest is that you make the win32 backend perform similarly to
what the fontconfig backend does and make load_font() return the first font
that load_fontset() would return.

The code I have in pangofc-fontmap.c isn't immediately 
reusable, since it has load_font()
call load_fontset(), and the default implementation of that in turn calls 
load_font()... you may need to cut-and-paste 
pango_fontmap_real_load_fontset() into pangowin32-fontmap.c, but perhaps
there is some other way it could be organized.
Comment 3 Behdad Esfahbod 2006-01-16 09:34:25 UTC
Marking patches...
Comment 4 Behdad Esfahbod 2006-02-13 03:54:40 UTC
How about changing pango_font_map_load_font to return the first font of the fontset, and load_fontset calling .->load_font directly?
Comment 5 Tor Lillqvist 2008-05-26 11:11:23 UTC
Another related issue is that the font picker on Windows does show the "sans", "serif" and "monospace" pseudo-fonts, as it presumably should. *But*, it shows several copies of "Normal", "Italic", "Bold" and "Bold Italic" in the Style widget for these pseudo-fonts. And the Preview widget indeed shows a different actual font for each "Normal"... Apparently they correspond to the fonts added to the font families for these pseudo-font names by the "odd code" in pango_win32_insert_font() mentioned in the initial comment.

(If I ifdef out that "odd code" snippet, then the "sans" etc pseudo-fonts don't show up at all in the font selector, and also I get critical errors "_pango_engine_shape_covers: assertion `PANGO_IS_FONT (font)' failed". Sigh.)
Comment 6 Tor Lillqvist 2008-05-27 01:15:27 UTC
The issue mentioned in comment #5 is fixed now. The odd piece of code mentioned in the initial description is now gone, and the "sans", "serif" and "monospace" font families are now instead added in what I think is a somewhat cleaner way, and they refer to only the first font of the corresponding alias list (fontset) that exists on the machine. I think this bug can be closed. There are still a couple of other bugs open against pangowin32 that describe valid issue.