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
>>
>> This is probably know - or is it a non-feature?
>> ###########
>>
>> (Un ?)related: a monitor de-/reselect doesn't make survive the
>> font selection:
>>
>> 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.mon x1
>> d.mon sel=x0
>> d.redraw # or resize
>>
>> Probably the d.out.file problem is related to this. Does D_add_to_list()
>> fail or
>> something like that?
>
> 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
--
Glynn Clements <glynn@gclements.plus.com>