cs349 - s10 - Lecture 5

CS349 - Implementing User Interfaces - Spring 2010

Public Service Annoucements

  1. Mark breakdown
  2. Assignment 1

Lecture 5 - Text & Typography

Written Language in the Graphical Interface

Language dominates every interface

Letters are pictures

Presentation of Written Language over the Millennia

Pictographs = Icons with grammar

Letters and words

Paper, ink and the codex

Movable type

Type used well

Written Language on the Computer

Text in the interface is essentially a computer simulation of of movable type.

canvas.text( window, gc, x, y, "Words, words, that's all you can say." )

Getting Fonts

font = XLoadFont( display, name )
  1. Finds font
  2. Scan converts the font and puts it in off-screen memory
  3. Gives the font a unique name for you to use
XSetFont( display, gc, font )
  1. Text will now be drawn using this font

Putting Text into a Window

XDrawString( display, window, gc, x, y, str, length )
  1. Draw the text in a window using the gc
  2. x, y is the position of the baseline where the text begins
  3. str is the text to be drawn
  4. length is the number of characters of str to be drawn
  5. The background is transparent. If you want to get the background colour behind the text use XDrawImageString

Putting Text where you Want It

fontStruct = XLoadQueryFont( display, name )
  1. fontStruct->fid is font
width = XTextWidth( fontStruct, str, length )
  1. Gives you the width of the string in pixels
  2. E.g., for centring text.

To get more information about the graphic properties of a string XTextExtents( fontStruct, ... ) tells you quite a bit

Finding What's Available

xfd             xfd (1)         - display all the characters in an X font
xfontsel        xfontsel (1)    - point & click interface for selecting X11 font names
xfs             xfs (1)         - X font server
xlsfonts        xlsfonts (1)    - server font list displayer for X

Try man -k font.

Return to: