//################################################################################################## // // Custom Visualization Core library // Copyright (C) 2011-2012 Ceetron AS // // This library is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at <> // for more details. // //################################################################################################## #pragma once #include "cvfObject.h" #include "cvfArray.h" namespace cvf { class TextureImage; class RenderState; class OpenGLContext; //================================================================================================== // // Pre-rendered text character // //================================================================================================== class Glyph : public Object { public: Glyph(wchar_t character); virtual ~Glyph(); wchar_t character() const; void setWidth(uint width); uint width() const; void setHeight(uint height); uint height() const; void setTextureImage(TextureImage* textureImage); const TextureImage* textureImage() const; const FloatArray* textureCoordinates() const; void setHorizontalBearingX(short bearing); short horizontalBearingX() const; void setHorizontalBearingY(short bearing); short horizontalBearingY() const; void setHorizontalAdvance(uint advance); uint horizontalAdvance() const; void setupAndBindTexture(OpenGLContext* oglContext, bool software); private: wchar_t m_character; // Character this glyph is generated from // Size of the pre-rendered character in pixels. // Note: May be smaller than the size of m_textureImage since this may contain alpha's and even more characters uint m_width; uint m_height; // For horizontal text layouts short m_horizontalBearingX; // Horizontal distance from the current cursor position to the leftmost border of the glyph image's bounding box. short m_horizontalBearingY; // Vertical distance from the current cursor position (on the baseline) to the topmost border of the glyph image's bounding box. uint m_horizontalAdvance; // Horizontal distance used to increment the pen position when the glyph is drawn as part of a string of text. // Texture info ref m_textureImage; // Pre-rendered image of m_character ref m_textureCoordinates; // Texture coordinates of where in the m_texgtureImage to find the given pre-rendered character ref m_textureBindings; // For shader based rendering this is a TextureBindings object, while software rendering uses RenderStateTextureMapping_FF instead }; } // namespace cvf