Quoting Thomas Evans (tevans@losalamos.com):
> I have had problems exporting dia UML figures on RH7.2. I believe it
> has to do with the font substitution during export. For example, I
> can go into the .eps output and change the scale (scf) factor on the
> fonts and things fit inside of class boxes fine.
>
> I'm not sure why things are working this way as X11 font stuff has
> always confused me somewhat.
>
> Does anybody know about this issue or have any suggestions?
I'm not doing a lot of exporting, but I can reliably break the font
scaling in UML classes by using the name "Terrain Feature" as the
class name.
The problem appears to be in the font_string_width function (in
font.c), which comments itself to be an admitted hack.
The attached patch resolves this for my system, and a friend who's
running Mandrake 8.1. The old calculation was taking total height of
the string and width from origin to next suggested origin, performing
some mathematical transforms on them to try to guess at "wide enough
or wider".
My patch uses the ascent of the font in place of total height (because
that appears consistent with the way the fonts render, and other
available metrics do not), and the total width of the font, from the
leftmost rendered pixel to the rightmost.
In using these numbers, the kruft placed around the other calculation
to try to fuzzy up the guess wasn't really required.
Please let me know if this doesn't work for you.
Thanks,
--G
--
Geoff Gerrietts <ggerrietts@yahoo.com>
-rw-rw-rw-: permissions of the beast
Index: font.c
===================================================================
RCS file: /cvs/gnome/dia/lib/font.c,v
retrieving revision 1.44
diff -r1.44 font.c
1183,1184c1183
< int iwidth, iheight;
< double width_height;
---
> double scaled_width;
1187a1187
> gint g_lbear, g_rbear, g_width, g_asc, g_desc, c_wide, c_tall;
1217,1218c1217,1220
< /* Note: This is an ugly hack. It tries to overestimate the width with
< some magic stuff. No guarantees. */
---
> /* this gets the extents of the text written, and the ascent height of the
> written font. it divides width by height to get a wide-to-high ratio, then
> multiplies by the scaled height.
> */
1220,1221c1222,1232
< iwidth = gdk_text_width_wc (gdk_font, wcstr, length);
< iheight = gdk_string_height(gdk_font, str);
---
> gdk_text_extents_wc(gdk_font,
> wcstr,
> length,
> &g_lbear,
> &g_rbear,
> &g_width,
> &g_asc,
> &g_desc);
> c_wide = g_lbear + g_rbear;
> if (c_wide == 0) return (real)0.0;
> scaled_width = (double)c_wide / (double)g_asc * height;
1226,1231c1237
< if ((iwidth==0) || (iheight==0))
< return 0.0;
<
< width_height = ((real)iwidth)/((real)iheight);
< width_height *= 1.01;
< return width_height*height*(iheight/100.0) + 0.2;
---
> return (real)scaled_width;