Terrapin Resources
Turtle Text

TURTLETEXT     SETFONT     FONTS     FONT

This section shows you how to print text to the Graphics panel, where the turtle lives.


TURTLETEXT word-or-list
(TURTLETEXT word-or-list mode)
TT word-or-list
(TT word-or-list mode)


TURTLETEXT prints its input to the drawing canvas. An optional input, see example below, allows you to align the characters to the baseline (ignoring descenders like j, y, and g), top, or bottom of the text.

This command uses the current turtle’s current pencolor and font. The text is displayed at the turtle’s location and heading.

If you rotate the turtle, the text rotates as well.

   

The only difference between the commands to create the two pictures above is this:

The first one uses a list of words as input. Because the words are in a list, inside brackets, all the letters appear in upper case.

TURTLETEXT [Welcome to Logo!]

The second one uses a word. Because the word starts with a quotation mark and the text is surrounded by vertical bars, the case of the letters is retained. This syntax allows you to print upper and lower case letters.

TURTLETEXT "|Welcome to Logo!|

In both cases, the text is rotated because the turtle turns. Here are the instructions used:

REPEAT 6 [TT [Welcome to Logo!] RT 60]
and
REPEAT 6 [TT "|Welcome to Logo!| RT 60]

If you don’t see any text, it may be because the turtle’s pen is up or its pen color is the same as the background color.

To make rows of text, pick up the turtle’s pen so it doesn’t draw, move it backwards, put the pen down and use TT again.

Here are the instructions that produced that result:

TURTLETEXT "|This is my story.
PU BK 25 PD
TURTLETEXT "|Once upon a time...|

Note that the turtle stays in the same spot when it prints the text.

Aligning Your Text Vertically

If you are combining text in different fonts and sizes, you may wish to use the optional second input to TURTLETEXT, which is the mode used to align the text.

For example, you might want to produce text that looks like one of these:

The optional second inputs are “TOP, “BASELINE, and “BOTTOM.

This code produces the image above, showing the different modes:

SETFONT "Times 18 0
(TT "|My Story - Top| "TOP)
RT 90 FD 150 BK 150 LT 90 STAMP

PU BK 60 PD
(TT "|My Story - Baseline| "BASELINE) STAMP
RT 90 FD 150 BK 150 LT 90 STAMP

PU BK 50 PD
(TT "|My Story - Bottom| "BOTTOM) STAMP
RT 90 FD 150 BK 150 LT 90 STAMP

For more details about these inputs, visit this page:.

» Things to Try

Use TURTLETEXT or more simply TT to place text where the turtle is.

Try rotating the text.

Here is another example of rotating text, from the October 1, 2024, Turtle Tuesday challenge.

Next you’ll learn to change the font and size of the text you print to the Graphics panel.

Try using the optional second input to position your text.


SETFONT name size attributes
(SETFONT name size)
(SETFONT name)
(SETFONT)


SETFONT allows you to choose the font name and size you want, as well as its attributes (bold, italic, bold italic).

There are four options for fonts. You can set any or all of them.

name is the font name. The font should already be available on your computer. If it isn’t, a similar one is selected.
size is the size of the letters in points. You may be familiar with point sizes in word processing programs. A size of 60 is about one inch. The size can be any number from 4 to 999 (although 999 isn’t very practical!).
attributes can be one of the following values:

  • 0 = regular
  • 1 = bold
  • 2 = italic
  • 3 = bold italic

Try these instructions to print your name in large red letters at a 45° angle. (Change _____ to your name!)

SETPC "RED LT 45
SETFONT "Times 36 3
TT "|My name is ___! |

You can use SETFONT in programs you write.

You can change the default font, size, and style in Logo’s Tools > Settings menu.

» Things to Try

Explore different fonts, sizes, colors, angles, and attributes.

Can you make a word search puzzle with words that intersect in a grid?

If you are using multiple turtles, each turtle can use different font settings for text it displays.


FONTS


FONTS reports a list of fonts that Logo knows about.

FONTS
Result: TIMES HELVETICA COURIER SERIF SANS_SERIF MONOSPACE LUMINARI BRADLEY MONACO VERDANA TAHOMA IMPACT

If you use a different font name, the computer will try to come as close to it as possible.

» Things to Try

Use all the different fonts reported by FONTS with TURTLETEXT and see how they appear on the screen.

Can you print a word that has each letter in a different font and perhaps size?
This is tricky, as you will have to move the turtle between letters.


FONT


FONT tells you the font in use by the turtle. When Logo starts up, it uses the font listed below.

FONT
Result: [HELVETICA 12 0]

You can use FONT in programs you write.

» Things to Try

As you try different fonts, use FONT to confirm the current font.