Re: Default font

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 8 Jul 2009 08:17:08 -0600 (MDT)

On Tue, 7 Jul 2009, Mateus Teixeira wrote:

> Dear NCL users,
>
> Is there a way to retrieve the font table previously defined in the
> .hluresfile and include it in a function code string?
>

Hi Mateus,

As you know, in the ".hluresfile" you can set the font with
a single line:

*Font : helvetica

Unfortunately, I'm pretty sure there's no way to retrieve this special
"Font".

However, you could retrieve *any* of the font resources (txFont, tiMainFont)
and it would give you the default font that is set up for your
particular script.

Here's a function with a test script:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
;
; Create a dummy text object in order to retrieve the default font.
; Nothing gets drawn here.
;
function get_font(wks)
local txid
begin
   txid = create "text" textItemClass wks end create
   getvalues txid
     "txFont" : font
   end getvalues
   delete(txid)

   return(font)
end

begin
   wks = gsn_open_wks("x11","test1")

   ifont = get_font(wks)

   print("font number is = " + ifont)

   str1 = "~F22~bold font ~F~default font"
   gsn_text_ndc(wks,str1,0.5,0.7,False)

   str2 = "~F22~bold font ~F" + ifont + "~default font"
   gsn_text_ndc(wks,str2,0.5,0.5,False)
   frame(wks)
end

Just FYI: you shouldn't need to set the default font in a text string,
because you will get this font in any string that you create unless
you explicitly changed the font to something else.

You can change the font in a text string and go back to the default
using the "F" function code without an argument. See my example above.

--Mary

> I'm asking it because I often forget what are my default font table, so I
> have to open .hluresfile to see which table I'm using and search in NCL
> website for numerical code for that table. In addition, if it could be done,
> the script could be more automatic, specially when we run scripts in
> different systems with different .hluresfile.
>
> Best regards,
>
>
> --
> Mateus da Silva Teixeira
>
> Registered Linux User #466740
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 08 2009 - 08:17:08 MDT

This archive was generated by hypermail 2.2.0 : Wed Jul 08 2009 - 14:48:16 MDT