Advertisement
WeltEnSTurm

Untitled

Oct 19th, 2011
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. // File: font.hpp, created on Aug 20, 2011 by WeltEnSTurm
  2.  
  3.  
  4. #ifndef FONT_HPP_
  5. #define FONT_HPP_
  6.  
  7.  
  8. #include <ft2build.h>
  9. #include <freetype/freetype.h>
  10. #include <freetype/ftglyph.h>
  11. #include <freetype/ftoutln.h>
  12. #include <freetype/fttrigon.h>
  13.  
  14. #include <vector>
  15. #include <string>
  16. #include "tools/base.hpp"
  17. #include "GLTools.h"
  18. #include "GLBatch.h"
  19.  
  20. class fm {
  21.     public:
  22.  
  23.         class font {
  24.  
  25.             protected:
  26.  
  27.                 struct Glyph {
  28.                     GLuint      Map;
  29.                     GLBatch     Vertices;
  30.                     long        Width;
  31.                     long        Height;
  32.                 };
  33.  
  34.                 FT_Face         Face;
  35.                 bool            Invalid;
  36.                 std::string     Path;
  37.                 long            Index;
  38.  
  39.             public:
  40.                 std::vector<Glyph*> Data;
  41.  
  42.                 font(bool ninv = true){
  43.                     Invalid = !ninv;
  44.                 }
  45.  
  46.                 void init();
  47.  
  48.                 bool operator ! (){
  49.                     return Invalid;
  50.                 }
  51.                 friend class fm;
  52.         };
  53.  
  54.     protected:
  55.         fm(){
  56.         }
  57.         ~fm();
  58.  
  59.         FT_Library  mLib;
  60.         std::vector<font*> Fonts;
  61.     public:
  62.  
  63.         static fm& Get(){
  64.             static fm Manager;
  65.             return Manager;
  66.         }
  67.  
  68.         static font* LoadFont(std::string path, long size = 12, long index = 0);
  69.  
  70.         void DrawText(const std::string& text);
  71.  
  72. };
  73.  
  74. #endif /* FONT_HPP_ */
  75.  
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement