From: Jun T <tak...@kb...> - 2018-07-05 13:54:12
Attachments:
aqua-font.patch
|
[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?] 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? Jun |
From: Jun T <tak...@kb...> - 2018-07-06 01:18:49
Attachments:
aqua-font-v2.patch
|
A revised patch is attached. > 2018/07/06 2:41, Ethan A Merritt <me...@uw...> wrote: > > I notice only: > - gnuplot style has been to follow C rules and place declarations > only at the top of a block Sorry, I thought it was OK because aquaterm.trm is in Objective-C. > - needs free(s) at line 227 Yes, indeed. > They should be reset if the > plot window size is changed interactively using the mouse but not for > font changes. Thanks. I had no idea what v_tic/h_tic were for. I just guessed it need be reset from the comments in wxt_gui.cpp (line 2438) and gp_cairo.c (line 1916). It seems gp_cairo_set_termvar() had a code to reset v_tic/h_tic but it was removed long time ago. Only old comments remain. Jun |
From: Ethan A M. <sf...@us...> - 2018-07-06 18:06:43
|
On Thursday, July 5, 2018 6:18:40 PM PDT Jun T wrote: > A revised patch is attached. Applied for 5.2 and 5.3 thanks Ethan |
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 > > |