class hiro::draw::TextRenderer — HIRO 0.7.0 documentation

# class hiro::draw::TextRenderer

## Overview

Responsible for rendering texts. More…

    #include <TextRenderer.h>

    class TextRenderer {
    public:
        // construction

        TextRenderer();
        TextRenderer(const hiro::draw::TextRenderer&);
        ~TextRenderer();

        // methods

        size_t LoadFont(const std::string& font_file, float font_height);
        void SetFont(const size_t font_id);
        void SetColor(const cogs::Color4b& color);
        void SetAlignment(hiro::draw::TextAlignment alignment);
        void Print(glm::ivec2 pos, const std::string& text);
        void SetSceneContext(const hiro::draw::PScene& scene);
    };

## Detailed Documentation

Responsible for rendering texts.

TextRenderer has an active state which includes font, color, alignment etc. and all Print calls use current active state for the rendering.

Instance of this object stores all print calls and state changes, and renders texts automatically at the same time.

### Methods

    size_t LoadFont(const std::string& font_file, float font_height)

Load TTF font file from disk and returns unique identifier of the font.

    void SetFont(const size_t font_id)

Sets an active font by its identifier.

    void SetColor(const cogs::Color4b& color)

Sets active color for the text.

    void SetAlignment(hiro::draw::TextAlignment alignment)

Sets active text alignment for the text.

    void Print(glm::ivec2 pos, const std::string& text)

Prints specified text with the alignment origin at the specified position.

    void SetSceneContext(const hiro::draw::PScene& scene)

Sets active rendering context for the text. Not to be called by a user.