Guides/Text Titles

From J Wiki
Jump to: navigation, search

For various applications there is a need to quickly create a bitmap with a piece of text, such as a Web banner, a title to combine with an image, etc.

It turns out that the Plot package is a great tool just for the purpose of quickly creating casual text images.

Here is an example.

load 'plot'
'title Hello World;titlecolor red;'plot ''
Plot0.png

We instantly get a piece of text. You can manually resize the window to fit the desired area, or use glwh.

For more presize text positioning, use text instead of title

'textfont Symbol 40 bold;text 10x _10x S a+b'plot ''
Plot2.png

Many additional attributes, such as font family, size, style, text and background color and other can be specified. See Plot documentation for details.

T1=. 'title Hello World;titlefont Arial 32 bold;'
(T1,'titlecolor red;backcolor lightgreen')plot ''

glwh 260 60

You can save the resulting image in a bitmap (or any other supported export format) for further manipulation with other tools.

pd 'save bmp plot1.bmp'
viewbmp 'plot1.bmp'
viewrgb B=: readbmp 'plot1.bmp'
Plot1.png

Antialias

Depending on your needs, you may want to change or turn off the system font smoothing, which is used by Plot.

Plot3.png

glwh

glwh=: 3 : 'wd''pmovex '',(+0 0,y-glqwh_jgl2_@$@#)&.".wd''qformx'''

References

  • Plot package in J User Manual

Contributed by Oleg Kobchenko