ChrisSteinbach / mscgen

Automatically exported from code.google.com/p/mscgen
GNU General Public License v2.0
0 stars 0 forks source link

[Code addition]: Runtime choice of fonts (for USE_FREETYPE only) #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When compiling with USE_FREETYPE, the font is hard-coded at compile time. I
have written a patch off revision 75, that allows a user to run-time select
the font for mscgen for PNG-images, either by giving a new argument[1] or
if not present, by setting the "MSCGEN_FONT" environment variable[2].
Neither way, it does not check if the output type is PNG, so no
error/warning is given in case the font ends up ignored.

If neither are given, mscgen will fall back to the value of the "FONT" macro.

This modifies the ADrawOpen() API (to accept the font name), but only the
GdoInit was modified to receive the font[3]. Nevertheless, it provides a
way to send the fonts to the other output formats, requiring only changes
to that output format (and the internals of ADrawOpen).

I hope you will consider it.

~Niels

[1] -F was arbitrarily selected.
[2] Taken out of the blue sky - just like [1].
[3] I was particularly unsure of how to implement this for svg and ps
output - given their current implementation.

Original issue reported on code.google.com by NThykier@gmail.com on 26 Jul 2009 at 5:01

Attachments:

GoogleCodeExporter commented 9 years ago
Excellent!  I'll take a look at this tonight!

Original comment by Michael....@gmail.com on 27 Jul 2009 at 8:08

GoogleCodeExporter commented 9 years ago
Man page still to be updated.  I wonder if this should be made configurable so 
that
the -F option is only put into the man page in the case that fontconfig is used?

Original comment by Michael....@gmail.com on 28 Jul 2009 at 8:53

GoogleCodeExporter commented 9 years ago
I do believe it is possible to detect fontconfig[1] and based on that modify the
contents of the man page. But I am wondering if it is the smart choice here.

Personally I think it would be better to always document the switch[2], 
likewise that
mscgen always accept it. The reason for this is: 

Imagine person A has mscgen with fontconfig and person B has without. Now 
person A
makes a script/msc-file that uses the "-F" option and publishes it. When person 
B now
look at this script, mscgen is given an option on his/her PC that is not 
documented
in his man page and causes the script to break. 

Instead if it is always documented and always accepted[3], person B will never 
face
an undocumented option that is accepted on "any other PC than his/her own". 

Alternatively you could go with a "fail if not supported"; it would require a 
decent
error message. Nevertheless, I still feel the switch should be documented in 
the man
page.

I believe that distros would prefer having the full man-page installed, even if 
they
are forced to build without every feature enabled. It saves them some 
bug-reports on
"missing information about -F argument."

Also, the documentation added for ADrawOpen() (about fontName) does not match 
the
behavior for gd_out.c. The doc states that if fontName is NULL a default will be
used, where as gd_out.c calls abort() (via assert) or passes a NULL pointer to 
the gd
functions (I do not know how they handle NULLs, so I cannot say if they do the 
right
thing or not).

~Niels

[1] I assume you mean "libfontconfig" here.
[2] It would be good to mention that it may be "ignored" due to build 
limitations.
[3] Though preferably with a warning that the font request could not be 
fulfilled due
to build limitations.

Original comment by NThykier@gmail.com on 28 Jul 2009 at 11:01

GoogleCodeExporter commented 9 years ago
Okay, r80 adds docs, fixes the ADrawOpen() inline docs and enables -F with a 
warning
message in the case it is used by USE_FREETYPE was not configured, something 
like
what you suggest :)

NULL should never be passed down from ADrawOpen() - the code is pretty simple 
at the
top level so that can't happen, and the assert() would have shown it in my 
tests.

Original comment by Michael....@gmail.com on 2 Aug 2009 at 5:40