Go to the documentation of this file.00001 #ifndef _OF_TTF_FONT_H_
00002 #define _OF_TTF_FONT_H_
00003
00004
00005 #include "ofConstants.h"
00006 #include "ofGraphics.h"
00007 #include "ofUtils.h"
00008 #include "ofTypes.h"
00009
00010
00011 typedef struct {
00012 int value;
00013 int height;
00014 int width;
00015 int setWidth;
00016 int topExtent;
00017 int leftExtent;
00018 float tTex;
00019 float vTex;
00020 float xOff;
00021 float yOff;
00022 } charProps;
00023
00024
00025
00026
00027
00028 #define TTF_SHAPE_SIMPLIFICATION_AMNT (0.3)
00029
00030 class ofTTFContour{
00031 public:
00032 vector <ofPoint>pts;
00033 };
00034
00035
00036 class ofTTFCharacter{
00037 public:
00038 vector <ofTTFContour> contours;
00039 };
00040
00041
00042 #define NUM_CHARACTER_TO_START 33 // 0 - 32 are control characters, no graphics needed.
00043
00044 class ofTrueTypeFont{
00045
00046 public:
00047
00048
00049 ofTrueTypeFont();
00050 virtual ~ofTrueTypeFont();
00051
00052
00053 void loadFont(string filename, int fontsize);
00054 void loadFont(string filename, int fontsize, bool _bAntiAliased, bool _bFullCharacterSet, bool makeContours = false);
00055
00056 bool bLoadedOk;
00057 bool bAntiAlised;
00058 bool bFullCharacterSet;
00059
00060 float getLineHeight();
00061 void setLineHeight(float height);
00062 float stringWidth(string s);
00063 float stringHeight(string s);
00064
00065 ofRectangle getStringBoundingBox(string s, float x, float y);
00066
00067 void drawString(string s, float x, float y);
00068 void drawStringAsShapes(string s, float x, float y);
00069
00070 int nCharacters;
00071
00072 ofTTFCharacter getCharacterAsPoints(int character);
00073
00074 protected:
00075 vector <ofTTFCharacter> charOutlines;
00076
00077 float lineHeight;
00078 charProps * cps;
00079 GLuint * texNames;
00080 int fontSize;
00081 bool bMakeContours;
00082
00083 void drawChar(int c, float x, float y);
00084 void drawCharAsShape(int c, float x, float y);
00085
00086 int ofNextPow2(int a);
00087 int border, visibleBorder;
00088
00089
00090 };
00091
00092
00093 #endif
00094