// // "$Id$" // // Standard X11 font selection code for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2016 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // // http://www.fltk.org/COPYING.php // // Please report all bugs and problems on the following page: // // http://www.fltk.org/str.php // /* This module implements a lowest-common-denominator font for OpenGL. It will always work, even if the main graphics library does not support rendering text into a texture buffer. The font is limited to a single face and ASCII characters. It is drawn using lines which makes it arbitrarily scalable. I am trying to keep font data really compact. */ #include #include "../../config_lib.h" #include "Fl_OpenGL_Graphics_Driver.H" #include #include #include #include #include // FIXME: check out FreeGlut: // FIXME: implement font-to-RGBA in the main graphics driver #if 1 /* |01234567| -+--------+ 0| |____ 1|++++++++|font 2|++++++++| 3|++++++++| 4|++++++++| 5|++++++++|____ 6| |descent 7| | -+--------+ */ static const char *font_data[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */0, /*!*/"\31\34\100\35\36", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*B*/"\43\54\45\15\11\41\52\43\13", 0, 0, /*E*/"\51\11\15\55\100\13\43", 0, 0, /*H*/"\11\15\100\61\65\100\13\63", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*T*/"\11\71\100\41\45", 0, 0, /*W*/"\01\15\33\55\61", /*X*/"\15\51\100\11\55", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*d*/"\64\55\55\25\14\13\22\52\63\100\61\65", /*e*/"\55\25\14\13\22\52\63\64\14", 0, 0, 0, /*i*/"\31\32\100\23\33\35\100\25\45", 0, 0, /*l*/"\31\34\45", 0, /*n*/"\15\12\100\13\22\42\53\55", /*o*/"\55\25\14\13\22\52\63\64\55", /*p*/"\17\12\42\53\54\45\15", 0, /*r*/"\25\22\100\23\32\52", /*s*/"\62\22\13\64\55\15", /*t*/"\41\44\55\65\100\22\62", 0, 0, 0, /*x*/"\15\52\100\12\55", 0, 0, 0, 0, 0, 0, 0, }; double Fl_OpenGL_Graphics_Driver::width(const char *str, int n) { return size_*n*0.5; } int Fl_OpenGL_Graphics_Driver::descent() { return (int)(size_ - size_*0.8); } int Fl_OpenGL_Graphics_Driver::height() { return (int)(size_); } void Fl_OpenGL_Graphics_Driver::text_extents(const char *str, int n, int& dx, int& dy, int& w, int& h) { dx = 0; dy = descent(); w = (int)width(str, n); h = size_; } void Fl_OpenGL_Graphics_Driver::draw(const char *str, int n, int x, int y) { int i; for (i=0; i63) { if (cmd=='\100' && rendering) { glEnd(); glBegin(GL_POINTS); glVertex2f(px, py); glEnd(); rendering = 0; } } else { if (!rendering) { glBegin(GL_LINE_STRIP); rendering = 1; } int vx = (cmd & '\70')>>3; int vy = (cmd & '\07'); px = (int)(0.5+x+vx*size_*0.5/8.0); py = (int)(0.5+y+vy*size_/8.0-0.8*size_); glVertex2f(px, py); } } } x += size_*0.5; } } #elif 0 /* extern FL_EXPORT Fl_Glut_StrokeFont glutStrokeRoman; extern FL_EXPORT Fl_Glut_StrokeFont glutStrokeMonoRoman; # define GLUT_STROKE_ROMAN (&glutStrokeRoman) # define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman) FL_EXPORT void glutStrokeCharacter(void *font, int character); FL_EXPORT GLfloat glutStrokeHeight(void *font); FL_EXPORT int glutStrokeLength(void *font, const unsigned char *string); FL_EXPORT void glutStrokeString(void *font, const unsigned char *string); FL_EXPORT int glutStrokeWidth(void *font, int character); */ #else void Fl_OpenGL_Graphics_Driver::draw(const char* str, int n, int x, int y) { gl_draw(str, n, x, y); } #endif // // End of "$Id$". //