[GRASS-dev] d.out.file and d.font issue
Markus Neteler
neteler at itc.it
Tue Jul 31 08:29:00 EDT 2007
Glynn Clements wrote:
>
> Markus Neteler wrote:
>> >> I tried to make a nice GRASS monitor dump with d.out.file but
>> >> realized that the freetype fonts are only approximated:
>> >>
>> >> # spearfish
>> >> g.region rast=elevation.dem -p
>> >> d.mon x0
>> >> d.font FreeSans
>> >> d.rast elevation.dem
>> >> echo "Spearfish elevation" | d.text col=black
>> >> # ... looks nice
>> >>
>> >> d.out.file demo res=2 format=png
>> >> display demo.png
>> >> # ... looks say, different
>> >>
> [...]
>> > Unless called with -o, d.rast erases the screen, which removes the
>> > font setting (the monitor remembers the actual font setting, but the
>> > information is removed from the "pads", which is what d.save uses):
>> >
>> > [display/d.rast/display.c lines 38-40]
>> >
>> > /* cell maps wipe out a picture, so we clear info on the window too
>> */
>> > if (!overlay)
>> > D_clear_window();
>> >
>> > Try running d.font *after* d.rast.
>>
>> Glynn, is there a reason to wipe the font out in D_clear_window()?
>
> There isn't a specific "font" setting; D_clear_window() simply removes
> the command list, including any "d.font" commands.
>
>> I would set if for the entire session (or longer) (otherwise use d.font
>> again).
>> If it is due to technical constraints, should I modify the
>> d.redraw/d.out.*
>> to first grab the font setting and then restore it after d.erase?
>> I would like to avoid that I have to hack a couple of GRASS scripts
>> locally to keep the font setting in the monitor.
>
> There isn't any reliable way to determine the current font. Looking
> for d.font commands won't help if the font was set using something
> like "d.text font=..."[1], or if there was a d.font command run on a
> different frame (each frame has its own pads, but there is only one
> current font).
>
> [1] The following programs call R_font(), but only d.font will add
> "d.font" to the command list.
>
> d.font
> d.paint.labels
> d.rast.num
> d.menu
> d.vect
> d.text
> i.class
> r.le.trace
> mon.select
>
> Ultimately, the whole frames/pads design is a hack; there are bound to
> be cases where it fails.
>
> If you are looking for a quick fix to this specific problem, it would
> be simpler to just remove the D_clear_window() call from d.rast. FWIW,
> the comment about "cell maps wipe out a picture" is incorrect; the
> frame may contain graphics which lie outside of the current region,
> e.g. (in Spearfish):
>
> g.region rast=elevation.dem
> g.region w=595010 e=604000
> d.legend elevation.dem
> d.rast elevation.dem
> d.redraw
>
Great suggestion:
Index: display.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/display/d.rast/display.c,v
retrieving revision 2.10
diff -u -r2.10 display.c
--- display.c 6 May 2007 21:04:51 -0000 2.10
+++ display.c 31 Jul 2007 12:23:17 -0000
@@ -35,10 +35,6 @@
D_setup(0);
- /* cell maps wipe out a picture, so we clear info on the window too */
- if (!overlay)
- D_clear_window();
-
/* Go draw the raster map */
cell_draw(name, mapset, &colors, overlay, invert, data_type) ;
Now d.out.file keeps the d.font settings.
Any objections to submit this to CVS?
Concerning the workaround which I suggested: I meant something along the
lines of
d.frame -l | grep '^d.font'
d.font font="FreeSans" charset="UTF-8"
Markus
--
View this message in context: http://www.nabble.com/d.out.file-and-d.font-issue-tf4169926.html#a11923092
Sent from the Grass - Dev mailing list archive at Nabble.com.
More information about the grass-dev
mailing list