source: nanovis/trunk/util/Fonts.h @ 4822

Last change on this file since 4822 was 3630, checked in by ldelgass, 11 years ago

Nanovis refactoring to fix problems with scaling and multiple results.
Do rendering in world space to properly place and scale multiple data sets.
Also fix flows to reduce resets of animations. More work toward removing
Cg dependency. Fix panning to convert viewport coords to world coords.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 */
5#ifndef NV_UTIL_FONTS_H
6#define NV_UTIL_FONTS_H
7
8#include <vector>
9#include <string>
10
11namespace nv {
12namespace util {
13
14class Fonts
15{
16public:
17    struct FontAttributes {
18        std::string _fontName;
19        int _textureWidth;
20        int _textureHeight;
21        int _fontHeight;
22        unsigned int _fontTextureID;
23        unsigned int _displayLists;
24
25        struct CharInfo {
26            float _left;
27            float _right;
28            float _top;
29            float _bottom;
30            bool _valid;
31            float _width;
32        };
33        CharInfo _chars[256];
34    };
35
36    Fonts();
37    ~Fonts();
38
39    /// set projection to orthographic
40    void begin();
41
42    /// reset projection matrix
43    void end();
44
45    /// initialize FontAttributes
46    void initializeFont(FontAttributes& attr);
47
48    /**
49     * @brief load font data
50     */
51    bool loadFont(const char *fontName, const char *fontFileName, FontAttributes& sFont);
52
53    void addFont(const char *fontName, const char *fontFileName);
54
55    void setFont(const char *fontName);
56
57    void draw(const char *pString, ...) const;
58
59    void resize(int width, int height);
60
61    /// return font height
62    int getFontHeight() const;
63
64private:
65    typedef std::vector<FontAttributes> FontVector;
66
67    FontVector _fonts;
68    /// current font index
69    int _fontIndex;
70    // screen width
71    int _screenWidth;
72    /// screen height
73    int _screenHeight;
74};
75
76inline int Fonts::getFontHeight() const
77{
78    return _fonts[_fontIndex]._fontHeight;
79}
80
81}
82}
83
84#endif
Note: See TracBrowser for help on using the repository browser.