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 600085 - pango_font_find_shaper returns NULL on Mac OS X / Quartz
pango_font_find_shaper returns NULL on Mac OS X / Quartz
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: GUI
1.9.x
Other Mac OS
: Normal normal
: ---
Assigned To: Jody Goldberg
Jody Goldberg
: 601462 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-10-30 00:19 UTC by W. Michael Petullo
Modified: 2010-03-19 15:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot demonstrating cell lables (12.17 KB, image/png)
2009-10-30 00:19 UTC, W. Michael Petullo
  Details
proposed patch (1.76 KB, patch)
2010-03-18 18:09 UTC, Andreas J. Guelzow
none Details | Review
sslightly safer patch (1.78 KB, patch)
2010-03-18 18:13 UTC, Andreas J. Guelzow
none Details | Review
patch with renamed variables (1.72 KB, patch)
2010-03-18 18:39 UTC, Andreas J. Guelzow
committed Details | Review

Description W. Michael Petullo 2009-10-30 00:19:13 UTC
Created attachment 146536 [details]
Screenshot demonstrating cell lables

I have built cairo and pango to use Quartz for rendering on Mac OS X 10.6 (Snow
Leopard). When I build and run gnumeric, I find that the cell labels' text is
not rendered properly. All of gnumeric's other text is rendered properly (e.g.,
menus). I have noticed that libgoffice is linked against
/opt/local/lib/libpangoft2-1.0.0.dylib, while neither pango nor cairo use
Freetype (they use Quartz).
Comment 1 Jean Bréfort 2009-10-30 05:53:07 UTC
Looks like a font issue. Not a libgoffice bug, but a gnumeric one, btw.
Comment 2 Andreas J. Guelzow 2009-10-30 06:22:37 UTC
The symbols in the cell headers indicate that pango is unable to render the necessary glyphs.  The font used is the default Application Font (for example in gnome set in the Appearance Preferences.)

Apparently you have a font set that pango can't handle.
Comment 3 Jean Bréfort 2009-10-30 09:04:05 UTC
Andreas, there is probably something else since in that case, I guess that the menus would not be properly displayed.

If the issue comes from gnumeric, the problem is most likely in item-bar.c. I have no access to any Apple made machine, so it's difficult to guess what happens.

I don't know why goffice is linked against libpangoft2, we have no direct dependency, AFAIK.
Comment 4 Andreas J. Guelzow 2009-10-30 13:09:10 UTC
According to the screenshot he has the missing glyph symbols (including the glyph number rendered).
Comment 5 Jean Bréfort 2009-10-30 14:16:42 UTC
Sure, but clearly we don't get a correct font from gtk+, now I have no idea about why.
Comment 6 Morten Welinder 2009-10-31 20:07:56 UTC
This is going to be hard to debug for anyone not on this system.
Comment 7 Andreas J. Guelzow 2009-11-11 09:07:00 UTC
*** Bug 601462 has been marked as a duplicate of this bug. ***
Comment 8 W. Michael Petullo 2010-03-13 00:15:08 UTC
In response to comment #5, I replaced item-bar.c's

desc = pango_font_description_copy (src_desc);

with

desc = pango_font_description_from_string ("monospace bold 12");

and saw no change. The cell label type was still rendered as mentioned in the original description.
Comment 9 Andreas J. Guelzow 2010-03-13 00:47:41 UTC
It may be more interesting to change 

ib->normal_font = pango_context_load_font (context, desc);

to

ib->normal_font = pango_context_load_font (context, desc);
g_print ("normalfont: %s", pango_font_description_to_string (pango_font_describe (ib->normal_font)));

and then see in the console whether there is any surprising output.

PS: this leaks a fontdescription and a string but it is intended for debugging only.
Comment 10 W. Michael Petullo 2010-03-13 23:46:47 UTC
I did as instructed in comment #9 and received the following output:

1: normalfont: Lucida Grande 12
2: normalfont: Lucida Grande 12
[...]

This font works fine when I enter some text into a cell and change the cell's font to Lucida Grande 12.
Comment 11 Andreas J. Guelzow 2010-03-14 01:02:17 UTC
This is not the output I had expected or hoped for.

While it is annoyting trying to debug this remotely, perhaps you wouldn't mind changing the code back to what it was and in  ib_draw_cell
replace

ib->pango.item->analysis.font = g_object_ref (font);

with

ib->pango.item->analysis.font = g_object_ref (font);
g_print ("font: %s", pango_font_description_to_string (pango_font_describe (font)));

We should get the same output as before (which wouldn't tell us anything).

But perhaps we see something different.
Comment 12 W. Michael Petullo 2010-03-14 01:14:11 UTC
I received the following output after adding the statement in comment #11:

3: font: Lucida Grande Bold 12
3: font: Lucida Grande 12
Comment 13 Andreas J. Guelzow 2010-03-14 07:21:59 UTC
I assume that you got two of the lines with Bold and lots of the other lines. (Of course they are probably only separate lines if you did "font: %s\n".)

That would be as expected.

For the record only, I get:  
font: Bitstream Vera Sans Bold 9.9990234375
font: Bitstream Vera Sans 9.9990234375
Comment 14 Andreas J. Guelzow 2010-03-14 17:55:04 UTC
Would you please change the code at the same place as in comment #11 to:

	ib->pango.item->analysis.font = g_object_ref (font);
	g_print ("font: %s\n", pango_font_description_to_string (pango_font_describe (font)));
	g_print ("PA: %p %p %u %u %u %u %p\n", 
		 ib->pango.item->analysis.shape_engine, ib->pango.item->analysis.lang_engine, 
		 ib->pango.item->analysis.level, ib->pango.item->analysis.gravity, ib->pango.item->analysis.flags, 
		 ib->pango.item->analysis.script, ib->pango.item->analysis.language);


Basically, we seem to have a valid font, so perhaps something is not right with our handcrafted PangoAnalysis.
Comment 15 W. Michael Petullo 2010-03-14 19:44:38 UTC
With the change from comment 14, I see:

font: Lucida Grande Bold 12
PA: 0x0 0x0 0 0 0 0 0x10152f7d8

and

font: Lucida Grande 12
PA: 0x0 0x0 0 0 0 0 0x10152f7d8
Comment 16 Andreas J. Guelzow 2010-03-15 06:26:18 UTC
Now we are getting somewhere:

ib->pango.item->analysis.shape_engine is NULL, so we have no attached engine to render the glyphs. We now need to figure out why it is NULL.

Note that ib->pango.item->analysis.lang_engine is also NULL, but that isn't a problem, you are using an english script.
Comment 17 Andreas J. Guelzow 2010-03-15 06:39:04 UTC
ib->pango.item->analysis.shape_engine should be set in item_bar_calc_size. Perhaps you can add there two g_print code lines to get:

	ib->pango.item->analysis.shape_engine =
		pango_font_find_shaper (ib->normal_font,
					ib->pango.item->analysis.language,
					'A');
	g_print ("font: %s\n", pango_font_description_to_string (pango_font_describe (ib->normal_font)));
	g_print ("shaper: %p\n", ib->pango.item->analysis.shape_engine);

Note that the first line (the pango_font_find_shaper call and assignment) is already in that function.

Thanks
Comment 18 W. Michael Petullo 2010-03-16 04:15:04 UTC
With the change from comment 17, I see:

font: Lucida Grande 12
shaper: 0x0
Comment 19 Andreas J. Guelzow 2010-03-16 06:34:41 UTC
So,

pango_font_find_shaper (ib->normal_font, ib->pango.item->analysis.language, 'A');

returns NULL, while ib->normal_font is a valid font.

I would consider that a Pango bug rather than a Gnumeric one.
Comment 20 Morten Welinder 2010-03-16 12:49:25 UTC
Behdad, why would pango return a NULL shaper?  See comment 19.
Comment 21 Behdad Esfahbod 2010-03-16 16:54:19 UTC
Which version, using which backend?  What's the contents of pango.modules file?
Comment 22 Andreas J. Guelzow 2010-03-16 17:09:11 UTC
Michael, what is your Pango version? Can you answer Behdad's questions?
Comment 23 W. Michael Petullo 2010-03-17 00:00:53 UTC
Version is pango 1.26.0.

Backend is Quartz Cairo 1.8.10, --enable-quartz, --enable-quartz-font & --enable-quartz-image.

pango.modules:

/opt/local/lib/pango/1.6.0/modules/pango-arabic-fc.so ArabicScriptEngineFc PangoEngineShape PangoRenderFc arabic:* nko:*
/opt/local/lib/pango/1.6.0/modules/pango-arabic-lang.so ArabicScriptEngineLang PangoEngineLang PangoRenderNone arabic:*
/opt/local/lib/pango/1.6.0/modules/pango-basic-atsui.so BasicScriptEngineATSUI PangoEngineShape PangoRenderATSUI common:
/opt/local/lib/pango/1.6.0/modules/pango-basic-fc.so BasicScriptEngineFc PangoEngineShape PangoRenderFc latin:* cyrillic:* greek:* armenian:* georgian:* runic:* ogham:* bopomofo:* cherokee:* coptic:* deseret:* ethiopic:* gothic:* han:* hiragana:* katakana:* old-italic:* canadian-aboriginal:* yi:* braille:* cypriot:* limbu:* osmanya:* shavian:* linear-b:* ugaritic:* glagolitic:* cuneiform:* phoenician:* common:
/opt/local/lib/pango/1.6.0/modules/pango-hangul-fc.so HangulScriptEngineFc PangoEngineShape PangoRenderFc hangul:*
/opt/local/lib/pango/1.6.0/modules/pango-hebrew-fc.so HebrewScriptEngineFc PangoEngineShape PangoRenderFc hebrew:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so devaScriptEngineFc PangoEngineShape PangoRenderFc devanagari:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so bengScriptEngineFc PangoEngineShape PangoRenderFc bengali:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so guruScriptEngineFc PangoEngineShape PangoRenderFc gurmukhi:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so gujrScriptEngineFc PangoEngineShape PangoRenderFc gujarati:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so oryaScriptEngineFc PangoEngineShape PangoRenderFc oriya:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so tamlScriptEngineFc PangoEngineShape PangoRenderFc tamil:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so teluScriptEngineFc PangoEngineShape PangoRenderFc telugu:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so kndaScriptEngineFc PangoEngineShape PangoRenderFc kannada:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so mlymScriptEngineFc PangoEngineShape PangoRenderFc malayalam:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-fc.so sinhScriptEngineFc PangoEngineShape PangoRenderFc sinhala:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so devaIndicScriptEngineLang PangoEngineLang PangoRenderNone devanagari:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so bengIndicScriptEngineLang PangoEngineLang PangoRenderNone bengali:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so guruIndicScriptEngineLang PangoEngineLang PangoRenderNone gurmukhi:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so gujrIndicScriptEngineLang PangoEngineLang PangoRenderNone gujarati:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so oryaIndicScriptEngineLang PangoEngineLang PangoRenderNone oriya:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so tamlIndicScriptEngineLang PangoEngineLang PangoRenderNone tamil:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so teluIndicScriptEngineLang PangoEngineLang PangoRenderNone telugu:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so kndaIndicScriptEngineLang PangoEngineLang PangoRenderNone kannada:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so mlymIndicScriptEngineLang PangoEngineLang PangoRenderNone malayalam:*
/opt/local/lib/pango/1.6.0/modules/pango-indic-lang.so sinhIndicScriptEngineLang PangoEngineLang PangoRenderNone sinhala:*
/opt/local/lib/pango/1.6.0/modules/pango-khmer-fc.so KhmerScriptEngineFc PangoEngineShape PangoRenderFc khmer:*
/opt/local/lib/pango/1.6.0/modules/pango-syriac-fc.so SyriacScriptEngineFc PangoEngineShape PangoRenderFc syriac:*
/opt/local/lib/pango/1.6.0/modules/pango-thai-fc.so ThaiScriptEngineFc PangoEngineShape PangoRenderFc thai:* lao:*
/opt/local/lib/pango/1.6.0/modules/pango-tibetan-fc.so TibetanScriptEngineFc PangoEngineShape PangoRenderFc tibetan:*
Comment 24 Behdad Esfahbod 2010-03-17 21:49:48 UTC
Weird.  Can you debug inside and see what's going on?

Regardless, having code like this in gnumeric doesn't look quite right to me.  What are you trying to do, calling such lowlevel pango functions?
Comment 25 Andreas J. Guelzow 2010-03-17 22:11:26 UTC
Behdad,

I didn't write that code, but looking at the "basic pango interface" I see pango_shape (which we use) requiring a PangoAnalysis. The only "basic pango" function that may yield one is pango_itemize which returns a GLIST of PangoAnalyis items. Since we know that we have only one item, using pango_itemize seems overkill, so we are using lower level functionality to build a single pango analyis we can use for all the column and row headers. 

Which high level pango interface would you suggset?
Comment 26 Morten Welinder 2010-03-17 22:45:21 UTC
We are trying to get a lot of little text fragments ("A", "B", ..., and
"1", "2", ...) on the screen in a hurry, bypassing the layout mechanism
since we don't want things line broken anyway.
Comment 27 Behdad Esfahbod 2010-03-18 17:28:32 UTC
I strongly recommend against initializing PangoAnalysis yourself.  Call pango_itemize() even if you only want one item.

Also, the key to speed is in caching.  What I do in vte for example (see vtepangocairo.c) is to use PangoLayout to shape each letter once and then cache the resulting PangoGlyphString or PangoLayoutLine or PangoLayout depending on how complex the resulting glyphs are.  It may be worthwhile to make that code available in pangocairo itself maybe.
Comment 28 Morten Welinder 2010-03-18 17:32:03 UTC
If we shape each letter individually, are we going to miss out on
ligatures or kerning?

(Ligatures aren't likely in this case.  Kerning is for "AV", fo
example.)
Comment 29 Behdad Esfahbod 2010-03-18 17:38:08 UTC
Ah, I thought you want to render individual letters separately.
Comment 30 Andreas J. Guelzow 2010-03-18 17:46:12 UTC
I'll write a patch to use pango_itemize to create the PangoAnalysis rather than initializing it oursleves. We can then try to use the same PangoAnalysis for all other row and column numbers and see whether that changes things. (This will preserve ligatures and kerning since we still call pango_shape.)
Comment 31 Andreas J. Guelzow 2010-03-18 18:09:25 UTC
Created attachment 156495 [details] [review]
proposed patch

This patch replaces our own construction of the PangoAnalysis with one obtained from a call to pango_itemize.

Michael, would you please try out whether this changes anything at your end.
Comment 32 Andreas J. Guelzow 2010-03-18 18:13:26 UTC
Created attachment 156496 [details] [review]
sslightly safer patch

We should probably initialize the pango item in ib to NULL.
Comment 33 Andreas J. Guelzow 2010-03-18 18:39:06 UTC
Created attachment 156499 [details] [review]
patch with renamed variables

In this patch the variables are renamed to not include the "pango_" prefix as requested by Morten.
Comment 34 W. Michael Petullo 2010-03-19 00:32:19 UTC
This patch in comment #33 fixes the problem. The cell labels are now rendered as 1, 2, 3 and A, B, C on Mac OS X with GTK/Quartz. Thank you Andreas and Behdad.
Comment 35 Andreas J. Guelzow 2010-03-19 01:52:23 UTC
I will commit the patch tomorrow.
Comment 36 Andreas J. Guelzow 2010-03-19 15:19:31 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.