29 #define OGLFT_NO_SOLID 1
33 #define OGLFT_NO_SOLID 1
54 #ifndef OGLFT_NO_SOLID
64 #include FT_FREETYPE_H
67 #include FT_TRIGONOMETRY_H
116 static FT_Library & instance (
void);
132 static FT_Library library_;
144 Advance (
float dx = 0,
float dy = 0):dx_ (dx), dy_ (dy)
176 BBox ():x_min_ (0), y_min_ (0), x_max_ (0), y_max_ (0)
188 x_min_ = ft_bbox.xMin / 64.;
189 y_min_ = ft_bbox.yMin / 64.;
190 x_max_ = ft_bbox.xMax / 64.;
191 y_max_ = ft_bbox.yMax / 64.;
221 if (new_value < x_min_)
225 if (new_value < y_min_)
229 if (new_value > x_max_)
233 if (new_value > y_max_)
283 typedef DisplayLists::const_iterator
DLCI;
286 typedef DisplayLists::iterator
DLI;
340 FaceData (FT_Face face,
bool free_on_exit =
true):face_ (face),
402 typedef GlyphDLists::const_iterator
GDLCI;
406 typedef GlyphDLists::iterator
GDLI;
424 Face (
const char *filename,
float point_size = 12, FT_UInt
resolution =
437 Face (FT_Face face,
float point_size = 12, FT_UInt
resolution = 100);
484 compile_mode_ = compile_mode;
579 GLfloat blue = 0.0, GLfloat alpha = 1.0);
603 return foreground_color_[
R];
610 return foreground_color_[
G];
617 return foreground_color_[
B];
624 return foreground_color_[
A];
638 GLfloat blue = 1.0, GLfloat alpha = 0.0);
662 return background_color_[
R];
669 return background_color_[
G];
676 return background_color_[
B];
683 return background_color_[
A];
727 horizontal_justification)
729 horizontal_justification_ = horizontal_justification;
745 vertical_justification)
747 vertical_justification_ = vertical_justification;
767 character_display_lists_ = character_display_lists;
782 virtual double height (
void)
const = 0;
824 virtual BBox measure (
const QString & format,
double number);
843 GLuint
compile (
const char *s);
855 GLuint
compile (
const QString & s);
864 GLuint
compile (
unsigned char c);
873 GLuint
compile (
const QChar c);
881 void draw (
const char *s);
889 void draw (
const QString & s);
897 void draw (
unsigned char c);
906 void draw (
const QChar c);
916 void draw (GLfloat x, GLfloat y,
unsigned char c);
926 void draw (GLfloat x, GLfloat y, GLfloat z,
unsigned char c);
936 void draw (GLfloat x, GLfloat y, QChar c);
946 void draw (GLfloat x, GLfloat y, GLfloat z, QChar c);
954 void draw (GLfloat x, GLfloat y,
const char *s);
962 void draw (GLfloat x, GLfloat y, GLfloat z,
const char *s);
970 void draw (GLfloat x, GLfloat y,
const QString & s);
978 void draw (GLfloat x, GLfloat y, GLfloat z,
const QString & s);
996 void draw (GLfloat x, GLfloat y,
const QString & format,
double number);
1015 void draw (GLfloat x, GLfloat y, GLfloat z,
const QString & format,
1024 return faces_.front ().face_->ascender;
1033 return faces_.front ().face_->descender;
1044 virtual GLuint
compileGlyph (FT_Face face, FT_UInt glyph_index) = 0;
1049 virtual void renderGlyph (FT_Face face, FT_UInt glyph_index) = 0;
1066 BBox measure_nominal (
const char *s);
1068 BBox measure_nominal (
const QString & s);
1069 QString format_number (
const QString & format,
double number);
1146 v_[
X] = v_[
Y] = v_[
Z] = 0.;
1160 v_[
X] = (double) (ft_v->x / 64) + (double) (ft_v->x % 64) / 64.;
1161 v_[
Y] = (double) (ft_v->y / 64) + (double) (ft_v->y % 64) / 64.;
1200 double length = sqrt (v_[
X] * v_[
X] + v_[
Y] * v_[
Y] + v_[
Z] * v_[
Z]);
1217 typedef VertexInfoList::const_iterator
VILCI;
1220 typedef VertexInfoList::iterator
VILI;
1249 Polygonal (
const char *filename,
float point_size = 12,
1363 double height (
void)
const;
1396 BBox measure (
const QString & format,
double number)
1404 void setCharSize (
void);
1405 void setRotationOffset (
void);
1406 GLuint compileGlyph (FT_Face face, FT_UInt glyph_index);
1439 Outline (
const char *filename,
float point_size = 12,
1456 void renderGlyph (FT_Face face, FT_UInt glyph_index);
1457 static int moveToCallback (FT_Vector * to,
Outline * outline);
1458 static int lineToCallback (FT_Vector * to,
Outline * outline);
1459 static int conicToCallback (FT_Vector * control, FT_Vector * to,
1461 static int cubicToCallback (FT_Vector * control1, FT_Vector * control2,
1462 FT_Vector * to,
Outline * outline);
1493 GLUtesselator *tess_obj_;
1513 Filled (
const char *filename,
float point_size = 12,
1535 return extra_vertices_;
1539 void renderGlyph (FT_Face face, FT_UInt glyph_index);
1542 static int moveToCallback (FT_Vector * to,
Filled * filled);
1543 static int lineToCallback (FT_Vector * to,
Filled * filled);
1544 static int conicToCallback (FT_Vector * control, FT_Vector * to,
1546 static int cubicToCallback (FT_Vector * control1, FT_Vector * control2,
1547 FT_Vector * to,
Filled * filled);
1548 static void vertexCallback (VertexInfo * vertex);
1549 static void beginCallback (GLenum which);
1550 static void endCallback (
void);
1551 static void combineCallback (GLdouble coords[3],
void *vertex_data[4],
1552 GLfloat weight[4],
void **out_data,
1554 static void errorCallback (GLenum error_code);
1557 #ifndef OGLFT_NO_SOLID
1595 FT_Outline_Funcs interface_;
1598 static const unsigned int N_POLYLINE_PTS = 4;
1604 glePoint2D (
double p[2])
1609 glePoint2D (
double x,
double y)
1644 Solid (
const char *filename,
float point_size = 12, FT_UInt
resolution =
1654 Solid (FT_Face face,
float point_size = 12, FT_UInt
resolution = 100);
1671 return extrusion_.depth_;
1676 void assign (gleDouble a[3],
double x,
double y,
double z)
1684 void renderGlyph (FT_Face face, FT_UInt glyph_index);
1685 static int moveToCallback (FT_Vector * to,
Solid * solid);
1686 static int lineToCallback (FT_Vector * to,
Solid * solid);
1687 static int conicToCallback (FT_Vector * control, FT_Vector * to,
1689 static int cubicToCallback (FT_Vector * control1, FT_Vector * control2,
1690 FT_Vector * to,
Solid * solid);
1743 double height (
void)
const;
1776 BBox measure (
const QString & format,
double number)
1784 GLuint compileGlyph (FT_Face face, FT_UInt glyph_index);
1785 void setCharSize (
void);
1786 void setRotationOffset (
void);
1787 void clearCaches (
void);
1820 Monochrome (
const char *filename,
float point_size = 12,
1836 GLubyte * invertBitmap (
const FT_Bitmap & bitmap);
1837 void renderGlyph (FT_Face face, FT_UInt glyph_index);
1871 Grayscale (
const char *filename,
float point_size = 12,
1886 GLubyte * invertPixmap (
const FT_Bitmap & bitmap);
1887 void renderGlyph (FT_Face face, FT_UInt glyph_index);
1927 Translucent (
const char *filename,
float point_size = 12,
1945 GLubyte * invertPixmapWithAlpha (
const FT_Bitmap & bitmap);
1946 void renderGlyph (FT_Face face, FT_UInt glyph_index);
1992 typedef GlyphTexObjs::const_iterator
GTOCI;
1996 typedef GlyphTexObjs::iterator
GTOI;
2009 Texture (
const char *filename,
float point_size = 12,
2070 double height (
void)
const;
2103 BBox measure (
const QString & format,
double number)
2126 virtual void bindTexture (FT_Face face, FT_UInt glyph_index) = 0;
2130 void setCharSize (
void);
2131 void setRotationOffset (
void);
2132 GLuint compileGlyph (FT_Face face, FT_UInt glyph_index);
2133 void renderGlyph (FT_Face face, FT_UInt glyph_index);
2134 void clearCaches (
void);
2190 GLubyte * invertBitmap (
const FT_Bitmap & bitmap,
int *width,
2192 void bindTexture (FT_Face face, FT_UInt glyph_index);
2248 GLubyte * invertPixmap (
const FT_Bitmap & bitmap,
int *width,
2250 void bindTexture (FT_Face face, FT_UInt glyph_index);
2312 GLubyte * invertPixmap (
const FT_Bitmap & bitmap,
int *width,
2314 void bindTexture (FT_Face face, FT_UInt glyph_index);
BBox measure(const char *s)
double height(void) const
Baseline alignment of text (default)
Render text as a filled polygons.
float x_max_
The right-most position at which "ink" appears.
Monochrome(const char *filename, float point_size=12, FT_UInt resolution=100)
void setForegroundColor(GLfloat red=0.0, GLfloat green=0.0, GLfloat blue=0.0, GLfloat alpha=1.0)
GLuint texture_name_
< A bound texture name is an integer in OpenGL.
BBox measure(unsigned char c)
void setTessellationSteps(unsigned int tessellation_steps)
unsigned int tessellationSteps(void) const
VertexInfoList::const_iterator VILCI
A convenience definition of the iterator over the list of vertices.
The Blue component of a color.
DisplayLists::const_iterator DLCI
A convenience definition of an iterator for display list vectors.
std::map< FT_UInt, TextureInfo > GlyphTexObjs
Type of the cache of defined glyph to texture objects mapping.
void setCharacterRotationX(GLfloat character_rotation_x)
GLfloat texture_t_
The advance vector of the transformed glyph.
Advance(float dx=0, float dy=0)
Default constructor. An otherwise uninitialized Advance contains zeros.
The Z component of space.
virtual MOfloat * texCoord(MOdouble *p)=0
enum VerticalJustification vertical_justification_
PHIGS-like vertical positioning of text.
Face(const char *filename, float point_size=12, FT_UInt resolution=100)
GlyphTexObjs::iterator GTOI
float y_min_
the bottom-most position at which "ink" appears.
~TranslucentTexture(void)
This is the base class of the polygonal styles: outline, filled and solid.
virtual BBox measure(unsigned char c)=0
Filled(const char *filename, float point_size=12, FT_UInt resolution=100)
GLfloat foreground_color_[4]
GLfloat texture_s_
by the glyph.
TextureTess * texture_tess_
virtual void setCharSize(void)=0
virtual void clearCaches(void)=0
The Red component of a color.
DisplayLists & characterDisplayLists(void)
MonochromeTexture(const char *filename, float point_size=12, FT_UInt resolution=100)
float y_max_
The top-most position at which "ink" appears.
void(* GLUTessCallback)(void)
Callback from GLU tessellation routines.
FT_Int bottom_bearing_
The bottom bearing of the transformed glyph.
void setVerticalJustification(enum VerticalJustification vertical_justification)
Do not create display lists for glyphs.
DisplayLists::iterator DLI
A convenience definition of an iterator for display list vectors.
GLfloat characterRotationZ(void) const
VertexInfo(double p[2], ColorTess *color_tess=0, TextureTess *texture_tess=0)
Right justified alignment of text.
The FreeType library instance.
GLfloat stringRotation(void) const
enum VerticalJustification verticaljustification(void) const
Render text as a polygon outline.
GlyphDLists::iterator GDLI
bool advance_
Does rendering text affect the MODELVIEW matrix?
virtual GLuint compileGlyph(FT_Face face, FT_UInt glyph_index)=0
void setResolution(FT_UInt resolution)
GLfloat characterRotationZ(void) const
float point_size_
Nominal point size.
enum GlyphCompileMode compile_mode_
Glyph display list creation mode.
Advance(FT_Vector v)
Initialize an advance from a FreeType advance member.
Left justified justification of text.
GLfloat y_
Angle of rotation in the Y direction.
bool active_
the other values.)
Render text as texture mapped grayscale quads.
ColorSpace
Who to credit? Newton? I'd consider these manifest constants.
FT_Face rotation_reference_face_
The rotation reference character could be in any face.
std::vector< FaceData > faces_
GLuint compile(const char *s)
float dx_
Advance increment in the X direction.
enum HorizontalJustification horizontalJustification(void) const
GLfloat backgroundRed(void) const
Render text as a grayscale raster image.
GLfloat characterRotationZ(void) const
GLfloat rotation_offset_y_
Raster(const char *filename, float point_size=12, FT_UInt resolution=100)
std::vector< glePoint2D > contour_normals_
Render text as a monochrome raster image.
struct OGLFT::Polygonal::@57 character_rotation_
Angle of rotation of characters relative to text orientation.
virtual double height(void) const =0
GLfloat characterRotationY(void) const
Render text as a translucent raster image.
virtual void bindTexture(FT_Face face, FT_UInt glyph_index)=0
Descender alignment of text.
BBox measure(unsigned char c)
double height(void) const
VertexInfo(double x, double y, ColorTess *color_tess=0, TextureTess *texture_tess=0)
FT_UInt resolution_
Display resolution in pixels per inch.
float dy_
Advance increment in the Y direction.
void setCompileMode(enum GlyphCompileMode compile_mode)
bool valid_
Did a font load OK?
Solid(const char *filename, float point_size=12, FT_UInt resolution=100)
VertexInfoList & extraVertices(void)
Compile new glyphs when seen for the first time.
BBox & operator*=(double k)
Render text as texture mapped translucent quads.
FT_UInt rotation_reference_glyph_
TextureTess * textureTess(void) const
BBox measure(unsigned char c)
Render text as solid letters.
virtual void renderGlyph(FT_Face face, FT_UInt glyph_index)=0
GLfloat backgroundBlue(void) const
void setCharacterDisplayLists(const DisplayLists &character_display_lists)
void setCharacterRotationY(GLfloat character_rotation_y)
Render text as texture mapped monochrome quads.
The Alpha (or transparency) of a color.
void setHorizontalJustification(enum HorizontalJustification horizontal_justification)
enum HorizontalJustification horizontal_justification_
PHIGS-like horizontal positioning of text.
Polygonal(const char *filename, float point_size=12, FT_UInt resolution=100)
BBox measure(const char *s)
void setCharacterRotationZ(GLfloat character_rotation_z)
TextureTess * texture_tess_
The projection component of space.
std::map< FT_UInt, GLuint > GlyphDLists
Type of the cache of defined glyph to display list mapping.
unsigned int tessellation_steps_
GlyphDLists::const_iterator GDLCI
GLfloat background_color_[4]
Background color (what modes would use this?)
GlyphTexObjs glyph_texobjs_
Cache of defined glyph texture objects.
void setDepth(double depth)
int width_
The 2**l width of the texture.
struct OGLFT::Solid::@58::@59 normal_sign_
GLfloat foregroundBlue(void) const
static const unsigned int DEFAULT_TESSELLATION_STEPS
GLfloat string_rotation_
Rotate an entire string in the Z plane.
The Y component of space.
enum GlyphCompileMode compileMode(void) const
Advance advance_
The (total) advancement.
BBox & operator+=(const BBox &b)
The X component of space.
GLfloat characterRotationY(void) const
void setCharacterRotationZ(GLfloat character_rotation_z)
ColorTess * colorTess(void) const
BBox measure(const char *s)
VertexInfoList::iterator VILI
A convenience definition of the iterator over the list of vertices.
void setCharacterRotationZ(GLfloat character_rotation_z)
virtual void setRotationOffset(void)=0
GrayscaleTexture(const char *filename, float point_size=12, FT_UInt resolution=100)
virtual BBox measureRaw(const char *s)
virtual GLfloat characterRotationZ(void) const =0
Centered alignment of text.
void setBackgroundColor(GLfloat red=1.0, GLfloat green=1.0, GLfloat blue=1.0, GLfloat alpha=0.0)
A face (aka font) used to render text with OpenGL.
GLfloat foregroundAlpha(void) const
VertexInfo(ColorTess *color_tess=0, TextureTess *texture_tess=0)
Ascender justification of text.
void setPointSize(float point_size)
GLfloat backgroundAlpha(void) const
The Green component of a color.
std::vector< glePoint2D > contour_
Advance & operator+=(const FT_Vector v)
Grayscale(const char *filename, float point_size=12, FT_UInt resolution=100)
GLfloat foregroundGreen(void) const
GLfloat characterRotationX(void) const
Center justified alignment of text.
Coordinates
Thanks to DesCartes, I'd consider these manifest constants.
bool addAuxiliaryFace(const char *filename)
BBox()
Default constructor is all zeros.
void setAdvance(bool advance)
GLfloat x_
Angle of rotation in the X direction.
GlyphDLists glyph_dlists_
Cache of defined glyph display lists.
GLfloat z_
Angle of rotation in the Z direction.
void setCharacterRotationX(GLfloat character_rotation_x)
double height(void) const
gleDouble point_array_[N_POLYLINE_PTS][3]
All of OGLFT C++ objects are in this namespace.
GLfloat character_rotation_z_
Texture(const char *filename, float point_size=12, FT_UInt resolution=100)
VertexInfo(FT_Vector *ft_v, ColorTess *color_tess=0, TextureTess *texture_tess=0)
TranslucentTexture(const char *filename, float point_size=12, FT_UInt resolution=100)
GlyphTexObjs::const_iterator GTOCI
float x_min_
The left-most position at which "ink" appears.
void setColorTess(ColorTess *color_tess)
struct OGLFT::Texture::@60 character_rotation_
Angle of rotation of characters relative to text orientation.
GLfloat characterRotationX(void) const
GLfloat foregroundRed(void) const
virtual void setCharacterRotationZ(GLfloat character_rotation_z)=0
void setTextureTess(TextureTess *texture_tess)
Natural origin alignment of text (default)
void setStringRotation(GLfloat string_rotation)
This is the base class of the texture style.
void renderGlyph(FT_Face face, FT_UInt glyph_index)
unsigned int nearestPowerCeil(unsigned int a)
virtual MOfloat * color(MOdouble *p)=0
Translucent(const char *filename, float point_size=12, FT_UInt resolution=100)
GLfloat backgroundGreen(void) const
std::vector< GLuint > DisplayLists
void setCharacterRotationReference(unsigned char c)
std::list< VertexInfo * > VertexInfoList
Normally, we will consider a list of vertices.
Outline(const char *filename, float point_size=12, FT_UInt resolution=100)
FT_Outline_Funcs interface_
Callbacks for FreeType glyph decomposition into outlines.
void setCharacterRotationY(GLfloat character_rotation_y)
DisplayLists character_display_lists_