String length when FONT=1 [message #29094] |
Thu, 31 January 2002 11:53  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Hey there,
Anyone know how to determine string length in normalised units when you're using truetype
fonts?
Currently I have:
ch_size = CONVERT_COORD( !D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL )
x_ch_size = ch_size[ 0 ] * charsize
x_length = STRLEN( my_string ) * x_ch_size )
which works great for the regular on-screen hershey type of fonts, but not for proportional
fonts.
any ideas? what I want to do is blank out the plot behind the text, e.g. like for legends etc.
paulv
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|
Re: String length when FONT=1 [message #29158 is a reply to message #29094] |
Fri, 01 February 2002 11:42  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Paul van Delst (paul.vandelst@noaa.gov) writes:
> Hmm...this does not seem to work as advertised on my system.
>
> IDL> print, !version
> { x86 linux unix 5.4.1 Jan 16 2001 32 32}
>
> The following is what I get for the string lengths via the XYOUTS with font=1:
>
> Level ppmv 0.0484790
> ppmv->cd->corr.ppmv 0.0991605
> corr-nocorr ppmv 0.0736377
> corr-interp ppmv 0.0700989
> nocorr-interp ppmv 0.0809504
>
> oh so incorrect.
Humm. I've never known this to be incorrect before.
Are you sure the same window was the current graphics
window when you ran these tests? In other words, have
you done a WSet *before* you ran the XYOUTS command?
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: String length when FONT=1 [message #29159 is a reply to message #29094] |
Fri, 01 February 2002 11:32  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Paul van Delst wrote:
>
> Andrew Cool wrote:
>>
>> Paul van Delst wrote:
>>>
>>> Hey there,
>>>
>>> Anyone know how to determine string length in normalised units when you're using truetype
>>> fonts?
>>>
>>> Currently I have:
>>>
>>> ch_size = CONVERT_COORD( !D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL )
>>> x_ch_size = ch_size[ 0 ] * charsize
>>> x_length = STRLEN( my_string ) * x_ch_size )
>>>
>>> which works great for the regular on-screen hershey type of fonts, but not for proportional
>>> fonts.
>>>
>>> any ideas? what I want to do is blank out the plot behind the text, e.g. like for legends etc.
>>>
>>> paulv
>>
>> Hiya Paul,
>>
>> Does the Width keyword to XYOUTS not help? e.g. :-
>>
>> XYOUTS, x, y, string, WIDTH=thisWidth, CHARSIZE=-1
>>
>> Charsize of -1 suppresses printing to the window, and the variable
>> thisWidth returns the width of the string in normalized coordinates.
>
> Hmm...this does not seem to work as advertised on my system.
>
> IDL> print, !version
> { x86 linux unix 5.4.1 Jan 16 2001 32 32}
>
> The following is what I get for the string lengths via the XYOUTS with font=1:
>
> Level ppmv 0.0484790
> ppmv->cd->corr.ppmv 0.0991605
> corr-nocorr ppmv 0.0736377
> corr-interp ppmv 0.0700989
> nocorr-interp ppmv 0.0809504
>
> oh so incorrect.
Aha! Must scale the result by whatever the charsize value is for the ACTUAL string. Cool. Still
- it's a bit silly to have to use xyouts twice.... or maybe not.
paulv
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|