[gradsusr] [EXTERNAL] Outlined Font options

Adams, Jennifer M. (GSFC-610.2)[ADNET SYSTEMS INC] jennifer.m.adams at nasa.gov
Sat Sep 26 17:38:18 EDT 2020


Hi, Ryan –
The only way to do this reliably and easily in GrADS is to use the Hershey fonts, by drawing a thick version underneath the regular string. I created the attached image with the following script lines:

str='Houston 80'
strsiz=0.25
scale=strsiz + 0.2*strsiz
'set strsiz 'strsiz' 'scale
'set lwid 13 5'
ypos=8
xpos=0.5
fn=0
while (fn<6)
  if (fn != 3)
    'set font 'fn
    'set string 1 bl 13' ; 'draw string 'xpos' 'ypos' 'str
    'set string 0 bl 12' ; 'draw string 'xpos' 'ypos' 'str
    ypos=ypos-2*strsiz
  endif
  fn=fn+1
endwhile

The problem when using Cairo fonts is that the thickness settings for ‘set string’ are ignored. The way to increase Cairo font thickness is to use a bold font. But drawing the bold version behind the regular version of a Cairo font does not deliver the same results; the characters don’t line up properly. The way that Cairo fonts are implemented in GrADS is lovingly referred to in the Cairo documentation as the “toy” text API – it takes UTF-8 encoded text and renders simple left-to-right text with no advanced features. The “toy” interface lines up very well with the GrADS algorithm: draw a letter, calculate its width, advance the position pointer by the width of the letter, draw the next letter, and so on. Building in more polished font handling would have required additional dependent libraries and a complete reworking of the way that strings are handled in GrADS, and that was beyond the scope of our limited resources.

--Jennifer


--
Jennifer Miletta Adams
ADNET Systems, Inc.
NASA/GSFC, Code 610.2
Building 32, Room S159
(301) 614-6070


From: gradsusr <gradsusr-bounces at gradsusr.org> on behalf of Ryan Maue <rnm02c at my.fsu.edu>
Reply-To: GrADS Users Forum <gradsusr at gradsusr.org>
Date: Saturday, September 26, 2020 at 11:23 AM
To: "gradsusr at gradsusr.org" <gradsusr at gradsusr.org>
Subject: [EXTERNAL] [gradsusr] Outlined Font options

Greetings,

I am looking for any advice on how to easily implement outlined (filled) fonts e.g. black surrounding white letters and vice versa.  I have had not been able to find anything that works just right out of the box.  My current workaround is using Image Magick's annotate and passing a lot of information outside the GrADS script.

I think this would help many of us out improving the annotation of our maps & charts.

I've attached an example of my current workaround, which is what I would like to accomplish entirely within GrADS

Cheers, Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20200926/5dda3ef0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: font_outline.png
Type: image/png
Size: 32392 bytes
Desc: font_outline.png
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20200926/5dda3ef0/attachment-0001.png>


More information about the gradsusr mailing list