From: Ethan A M. <me...@uw...> - 2018-07-05 17:44:31
|
On Thursday, July 5, 2018 6:15:47 AM PDT Jun T wrote: > [Problem] > aqua terminal has a problem in setting font for each label (or title etc.) > if enhanced mode is in use. For example, if I run > > gnuplot> set term aqua font "Times,16" > gnuplot> label 1 "A_{ij}" at 0,0 font "Arial,30" > gnuplot> plot sin(x) > > then A_{ij} is drawn in the default font "Times", although the size is > correct (i.e., 30). If "A_{ij}" is replaced by "A" (no enhanced mode) > then it is drawn in the specified font "Arial". > > The problem is, in enhanced mode, ENHAQUA_put_text() calls > enhanced_recursion() with fontname=AQUA_fontNameCur (because > ENHAQUA_put_text() does not know the correct font for the current label), > but AQUA_fontNameCur has not been set by AQUA_set_font() (which is > called just before ENHAQUA_put_text()). > > [A Possible Patch] > In the attached patch, AQUA_set_font() is rewritten so that it takes > care of AQUA_fontNameCur properly. The variable AQUA_fontNameDef was there > but not used anywhere, so I used it to save the default font name. > AQUA_set_font("name") will set AQUA_fontNameCur to "name", and > AQUA_set_font("") will reset AQUA_fontNameCur to AQUA_fontNameDef. > > AQUA_fontNameDef (and AQUA_fontNameCur also) is set in AQUA_options() > (i.e., 'set term aqua font "name"' or 'set termoption font "name"'). > > I introduced two helper functions to simplify the code. > > [Is this OK?] Looks OK to me. I don't have an OSX machine to try it on. I notice only: - gnuplot style has been to follow C rules and place declarations only at the top of a block - needs free(s) at line 227 - see below > In the helper function set_font_size(), h_tic and v_tic are also reset. > Before the patch, they were reset only in AQUA_init(), but I *guess* > they need be reset every time font size changes. Is there any test case > in which not resetting h_tic/v_tic causes a problem? These are used by the core code to reserve space in the plot margins for outward-facing tics. Also the ratio v_tic/h_tic is used to calculate the aspect ration of the plot. Neither of those space requirements change with the font size, so h_tic and v_tic should be set initially in term->() or term->options() when the size is specified. They should be reset if the plot window size is changed interactively using the mouse but not for font changes. Can you send a revised patch when there has been a chance for feedback also from people using aquaterm? thanks Ethan > > Jun > > |