File: Font.h

package info (click to toggle)
glgrib 1.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,861,496 kB
  • sloc: cpp: 20,811; ansic: 6,530; perl: 2,902; sh: 513; makefile: 147; python: 58; sql: 18
file content (48 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <vector>
#include <memory>
#include "glGrib/OpenGL.h"
#include "glGrib/Options.h"
#include "glGrib/Program.h"


namespace glGrib
{

class Font
{
public:
  static void clearCache ();
  void setup (const OptionsFont &);
  int map (char c) const
  { 
    if (c <= 32) 
      return 15; 
    int ix =     (c - 32) % 16; 
    int iy = 5 - (c - 32) / 16;
    return iy * nx + ix;
  }
  Program * getProgram () const { return Program::load ("FONT"); }
  void select () const;
  float getAspect () const { return aspect; }
  float getPosBelow () const { return posb; }
  float getPosAbove () const { return posu; }
  const OptionsFont & getOptions () const { return opts; }
private:
  OptionsFont opts;
  std::vector<float> xoff, yoff;
  int nx, ny;  // Array of letters dimension
  bool ready = false;
  OpenGLTexturePtr texture;
  float aspect;
  float posu;  // Size above line
  float posb;  // Size below line
};

typedef std::shared_ptr<Font> FontPtr;
typedef std::shared_ptr<const Font> const_FontPtr;

FontPtr getGlGribFontPtr (const OptionsFont &);

}