Skip to main content

Glyph - 2.0.0.a2

Pygame typesetting library

Chandler Armstrong
glyph is a library for manipulating text and printing it to a pygame window. so what? there are about a million pygame libraries to do that already. glyph is different for a few reasons: 1) glyph provides a within string literal mini-language for text manipulation. you can use the mini-language to indicate what you want exactly where you want it, all right within the string literal. 2) glyph provides typesetting like functionality: positioning text, wrapping text, justifying text, scrolling text, switching font, text color, background color, even inserting images into text 3) glyph provides 'linked' text: text that returns a value whenever the mouse is hovering over it. this can be used to route the user around your program, or provide tooltips. one simple object, the Glyph object, provides all this functionality. how? because Glyph interprets a mini-language, provided in string literals, that indicates how the Glyph object should treat text.


glyph mark-up language: glyph accepts special commands given through markup in the text. the language can be used to change font, size, color, background color, and denote text as 'linked'. the commands given in the mark-up language are called 'environments'. all text inside of an environment is treated according to the environemnt type. for example, text can be italicized by starting an italics environment, and all text inside the environment will be blitted to the screen as italicized. environments are started with a left curly bracket '{', and terminated with a right curly bracket '}'. the first text following the left curly bracket is the type of the environment. currently, the following types are available: font - tells glyph that this font should be used in this environment color - tells glyph that this color should be used in this environment bkg - tells glyph that this background color should be used in this environment link - tells glyph that this text is 'linked' environments can be nested. when two environments of the same type are nested (e.g. two font environments), the most recent will take precedence. immediately following the environment type are the arguments. the arguments specify what the environment will do to the text within it. arguments must be seperated with commas and terminated with a semi-colon. below are the environments and the arguments they expect: font - file, size file is the path to the directory containing the font file size will be the size of the font color - R, G, B R, G, B are the red, green, blue values, respectively. bkg R, G, B R, G, B are the red, green, blue values, respectively. link - linkname linkname is the name of the link, and will serve as the key for all the rects associated with the link below are some example environments: glyph can {font fonts\\silkscreen_bold, 8;bold} text for you. it can also {color (255, 0, 0);color} text for you. it can even {font fonts\\silkscreen_bold, 8;nest these {color (255, 0, 0);features} for you}. the environments and arguments can become cumbersome to type out. fortunately, glyph can store macros that will allow long rules to be abbreviated. to do this, simply add an entry to the glyph.Macro dictionary, with the key being the abbreviation, and the value being the environment type and environment: glyph.Macro['b'] = ('font', Font(silkscreen_bold, 8)) glyph.Macro['red'] = ('color', (255, 0, 0)) with macros set, simply use the abbreviation at the start of environments rather than the name and argument list: glyph can {b;bold} text for you. it can also {red;color} text for you. it can even {b;nest these {red;features} for you}.


Home Page


Glyph 2.5.4rc — 27 Jul, 2011

Glyph 2.6.0b — 6 Jul, 2012

Glyph 2.6.5 — 23 Dec, 2012

Glyph 1.1.0 — 10 Jan, 2009

Glyph 1.0.0 — 3 Jan, 2009

Glyph 1.2.0 — 14 Jan, 2009

Glyph 2.5.3rc — 9 Jul, 2011

Glyph 2.4.0 — 12 Dec, 2010

Glyph 2.5.0 — 2 Mar, 2011

Glyph 2.5.2rc — 25 Jun, 2011

Glyph 2.5.1 — 27 Mar, 2011

Glyph 2.0.0.a — 18 Jul, 2010

Glyph 2.0.0.a2 — 1 Aug, 2010

Glyph 2.1.0b — 5 Oct, 2010 account Comments

  • pooootrick 2013-05-07 08:11

    yaaaaay pygame