cs349 - s10 - Lecture 5
CS349 -
Implementing User Interfaces - Spring 2010
Public Service Annoucements
- Mark breakdown
- 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
- base line, x-height, ascender, descender
- point size, inter-line spacing, leading
- left bearing, right bearing (apply to slanted fonts)
Type used well
- easy to read
- visually attractive
- overall appearance
- hyphenation
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 )
- Finds font
- Scan converts the font and puts it in off-screen memory
- Gives the font a unique name for you to use
XSetFont( display, gc, font )
- Text will now be drawn using this font
Putting Text into a Window
XDrawString( display, window, gc, x, y, str, length )
- Draw the text in a window using the gc
- x, y is the position of the baseline where the text begins
str is the text to be drawn
length is the number of characters of str to
be drawn
- 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 )
fontStruct->fid is font
width = XTextWidth( fontStruct, str, length )
- Gives you the width of the string in pixels
- E.g., for centring text.
To get more information about the graphic properties of a string
XTextExtents( fontStruct, ... ) tells you quite a bit
- ascent, descent
- left bearing, right bearing
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: