monoFont = Font clone open("Library/Fonts/Bitstream/VeraMoBd.ttf") setPointSize(12) sansFont = Font clone open("Library/Fonts/Bitstream/Vera.ttf") setPointSize(12) serifFont = Font clone open("Library/Fonts/Bitstream/VeraSe.ttf") setPointSize(12) //monoFont = Font clone open("Library/Fonts/Free/FreeMonoBold.ttf") setPointSize(12) //sansFont = Font clone open("Library/Fonts/Free/FreeSans.ttf") setPointSize(12) //serifFont = Font clone open("Library/Fonts/Free/FreeSerif.ttf") setPointSize(12) Screen = Object clone Screen parent = OpenGL Screen string = "Io TrueType 123!@#" Screen reshape = method(w, h, self width = w self height = h glViewport(0,0,w,h) glLoadIdentity gluOrtho2D(0,w,0,h) monoFont setPointSize(width/15) sansFont setPointSize(width/15) serifFont setPointSize(width/15) glutPostRedisplay ) Screen display = method( glClearColor(1, 1, 1, 1) glClear(GL_COLOR_BUFFER_BIT) x = width/(2) -(monoFont widthOfString(string)/2) y = height/(2) +(monoFont pointSize*1.5) x Ceil y Ceil //y += monoFont pointSize + 10 glPushMatrix glTranslated(x, y, 0) monoFont drawString(string) glPopMatrix glPushMatrix y -= sansFont pointSize *1.5 glTranslated(x, y, 0) sansFont drawString(string) glPopMatrix y -= serifFont pointSize *1.5 glPushMatrix glTranslated(x, y, 0) serifFont drawString(string) glPopMatrix glFlush glutSwapBuffers ) Screen mouse = method(button, state, x, y, if (state == 0, if ( y < 50, v = Number random(0,1) glColor4d(v, 0, 1 - v, 1) ) self display ) ) Screen special = method(c, x, y, if (c == GLUT_KEY_UP, monoFont setPointSize(monoFont pointSize + 1) sansFont setPointSize(sansFont pointSize + 1) serifFont setPointSize(serifFont pointSize + 1) ) if (c == GLUT_KEY_DOWN, monoFont setPointSize(monoFont pointSize - 1) sansFont setPointSize(sansFont pointSize - 1) serifFont setPointSize(serifFont pointSize - 1) ) if (c == GLUT_KEY_RIGHT, glColor4d(1 random, 1 random,1 random, 1) ) self display ) Screen run = method( glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutInitWindowSize(512, 512) glutInit glutCreateWindow("Font Test") glutEventTarget(Screen) glutDisplayFunc glutMouseFunc glutReshapeFunc glutSpecialFunc glColor4d(0,0,0,1) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glutMainLoop ) Screen run