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 331489 - MetaPost export font size is wrong
MetaPost export font size is wrong
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: exports
0.95-preX
Other All
: Normal normal
: 0.95
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2006-02-17 02:34 UTC by Rob McDonald
Modified: 2006-07-15 17:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Rob McDonald 2006-02-17 02:34:32 UTC
Please describe the problem:
When exporting a MetaPost file, the font scaling is dependent on the on-screen
zoom level.

Steps to reproduce:
1) Start Dia.
2) Insert a text label "foo".
3) Set the zoom to 100%.
4) Export a MetaPost file foo1.mp
5) Set the zoom to 200% (or anything else)
6) Export a MetaPost file foo2.mp
7) Compare the two files.  diff foo1.mp foo2.mp 


Actual results:
There will be a difference in the files corresponding to the font scaling
parameter changing due to the zoom level changing.

Expected results:
The font scaling parameter should be independent of zoom level.  100% zoom does
not coincide with the correct scaling parameter.

Does this happen every time?
Yes

Other information:
MetaPost's font scaling is a simple proportion based off the font's 'natural'
size.  For example, cmr10 is 10pt.  1.2 yields 12pt.  To the user, Dia works
with font sizes specified in centimeters.  As a test case, a font size of 0.35cm
should yield a scaling factor very close to 1.0 for cmr10.

Hans says:  Just looked into it and it appears to be a really simple solution.
Currently set_font() is ignoring the passed in parameter 'height'
which has the size independent of the scale.
Instead their is a call to dia_font_height() which apparently returns
a scaled font size. The latter may be a bug in itself but the whole
font handling is a little messy at the moment
Comment 1 Hans Breuer 2006-02-17 13:29:01 UTC
With the above mentioned change I'm now getting

% Metapost TeX macro
% Title: D:\graph\dia2\bin\Diagram1.dia
% Creator: Dia v0.95-pre1
% CreationDate: Fri Feb 17 14:10:35 2006
% For: hb


beginfig(1);
verbatimtex
%&latex
\documentclass{minimal}
\begin{document}
etex
  % picture(5.400000,-5.667500)(6.908750,-5.241250)
  x = 1.000000cm; y = -1.000000cm;

% set_line_color 0.000000, 0.000000, 0.000000
% set_line_color 1.000000, 1.000000, 1.000000
% set_line_color 0.000000, 0.000000, 0.000000
  label.urt(btex {\usefont{OT1}{phv}{m}{n} Text 0.35} etex scaled 1.05,(5.400000x,5.550000y));
endfig;
end; 

Do you think this is close enough to 1.0 or is there some extra 
tweaking needed?

Comment 2 Rob McDonald 2006-02-17 14:30:00 UTC
That should be close enough.  The main issue is removing the zoom dependence.

Of course, it isn't _exactly_ the answer I would expect...

(0.35 / 2.54) * 72.27 / 10 = 0.995846

or

(0.35 / 2.54) * 72 / 10 = 0.992126

So, I'm not sure what conversion factors are playing into the equation, but 1.05 is pretty close.

Of course, depending on how careful you want to be, at 10pt, it is 0.5pt off, which is halfway to 11pt....

It may not be worth messing with further because of the work that will happen when Dia is made units-aware.  If a user wants 10pt, they aren't going to input 0.35cm, they'll input 10pt...

In the meantime, simply documenting the exact conversion constants used should be adequate.  That way, if anybody absolutely _has_ to have a certain font size, they can figure out what number to input.  For example, assuming everything is just linear, putting in 0.3333cm should cause the current implementation to output 1.0 exactly (or nearly so).
Comment 3 Hans Breuer 2006-02-17 15:43:13 UTC
2006-02-17  Hans Breuer  <hans@breuer.org>

	* plug-ins/metapost/render_metapost.c(draw_string) : dont query
	the font for it's height but use the 'height' parameter passed
	in. Close enough to the desired size - and independent of zoom -
	to close bug #331489 (Rob McDonald)
	
Comment 4 Hans Breuer 2006-07-15 17:23:15 UTC
moving away form 0.95-pre1 to delete that label afterwards. Sorry for the noise.