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 345538 - SVG export font-size is wrong
SVG export font-size is wrong
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: exports
CVS head
Other All
: Normal normal
: 0.97
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2006-06-21 12:09 UTC by Dov Grobgeld
Modified: 2009-01-09 22:37 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dov Grobgeld 2006-06-21 12:09:45 UTC
Please describe the problem:
SVG's exported by dia has the wrong font-size by a factor of 1/0.7 . This was realized by the following sequence of commands:

1. I created a small dia input consisting of text and a surrounding box.
2. I exported to EPS with latin1 fonts as reference. 
3. I exported to SVG.
4. The SVG output was rescaled according to the description by me in Bug #316590 to get rid of quantization errors.
5. The resulting file was loaded into inkscape.
6. I did export postscript in dia.
7. I calculated the total ratio of the scale of the fonts between the two methods. The result was that SVG was too big by a factor of 0.7 .

Solution in lib/diasvgrenderer.c:

<   tmp = g_strdup_printf("%s; font-size: %s", style,
<                         dia_svg_dtostr(d_buf, self->font_height) );
--
>     tmp = g_strdup_printf("%s; font-size: %s", style,
>			    dia_svg_dtostr(d_buf, 0.7 * self->font_height) );

Of course the question is why this happen, which I haven't figured out yet...



Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Stefan vonHalenbach 2006-08-10 23:54:35 UTC
I don't know why it is so, but i agree with you that the fonts in SVG were rendered a bit too big and the factor of 0.7 seems to me just right.

Greetings
Stefan
Comment 2 Hans Breuer 2007-09-08 17:08:23 UTC
There is some magic factor in lib/font.c(dia_font_build_layout) - a relict from the porting to Pango. Instead of polluting more of the code with it, it should be fixed there.
Comment 3 Dan Mihai Ile 2008-05-27 23:53:14 UTC
I can confirm this bug in Dia 0.96.1
I just made an simple diagram with dia and exported using "Scalable Vector Graphics (*.svg)" and then opened the result with Inkscape 0.46

All texts were just huge!
What I did: using text edit replaced all "font-size: 0.8 cm;" with "font-size: font-size: 0.56444447;" which is the equivalent size in inkscape so that the final result would be something like 99% the same as in Dia.

It should be fixed somehow....
Comment 4 Yuval Yerushalmy 2009-01-02 14:16:34 UTC
After experimenting with this I noticed there are 2 SVG export engines, the (probably) c code based old engine and the python based engine. The former is activated by the "scalable vector graphics" option in the export dialog and the later is activated using the "SVG Plain" or "SVG compressed" option. 
The later is more correct with a few reservations:

a. as mentioned, the font should be scaled by a factor of 0.74(that I changed in the script 'diasvg.py' and it worked great).

b. svg entities with negative coordinates don't appear(both in FF and InkScape). If I knew more about the API I would write a script that iterates over all the coordinates(including implicit ones like edges of elipses) and find out the smallest x and y. Then translate all the coordinates with the correct delta x and delta y. but I don't have time to study the API so I would just move the entire diagram to the positive quarter of the sheet...

Comment 5 Yuval Yerushalmy 2009-01-03 15:53:39 UTC
OK, I believe I successfully translated all the coordinates in diasvg.py to be positive. I've tested it against complex diagram and it seems to work(at-least in FF). I never used SVN of created patches so if anyone wants me to commit the updated script I'll be happy to take instructions...

Comment 6 Hans Breuer 2009-01-03 16:31:54 UTC
In fact there are up to three svg exporters (standard C, Python, cairo based). All of them take and give negative coordinates, which are no problem per se. Inkscape just worked for me with all of them. Firefox indeed does not like the negative viewBox coordinates given by diasvg.py. But this all has nothing to do with font-size. So this comment should have been put to bug #475978.

For the font-size issue please read my comment #2 - a patch addressing this will be attached to bug #538499 soon.
Comment 7 Hans Breuer 2009-01-09 22:37:46 UTC
When exporting to Inkscape (with "Scalable Vector Graphics" or "Cairo Sc...") to there is a perfect match of font sizes now, at least when using concrete fonts (tested Arial, Times New Roman, Courier New). I don't think is is feasible to ask for more;)

2009-01-09  Hans Breuer  <hans@breuer.org>

	* lib/font.h : declare dia_font_get_size()
	* lib/libdia.def : export it
	* lib/font.c : use pango_font_description_set_absolute_size() - the 
	magic factor which tried to compensate for fontmap resolution issues 
	_and_ the difference between Dia's intention of "font_height" and 
	Pango's "font size" is gone. 
	There is a much less magic factor just compensating the second issue. 
	Dia's font-height always meant something like line height, i.e. a 
	good difference between two consecutive lines baselines (Pango itself 
	is using line_height=ascent+descent).
	Instead of searching the right size for a given height a new factor 
	got introduced, which unfortunately changes the font-size on win32 
	and X, but all this finally fixes bug the OS dependent part of 
	bug #108293

	* plug-ins/cairo/diacairo-renderer.c : use dia_font_get_size() and 
	pango_font_description_set_absolute_size instead of magic number 0.7
	fixing bug #538499
	* plug-ins/wmf/wmf.cpp : same here 

	* lib/diasvgrenderer.c(draw_string): moved #if-0-ed original ...
	* plug-ins/svg/render_svg.c : ... implementation to be used in SVG
	export but not for shape export. For SVG export we apparently want 
	the font-size instead of it's line-height - although my interpretation
	of the specs differs ... should fix bug #345538