Browse Source

Text: moved font size to abstract base.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
57adfac002
  1. 4
      src/Text/AbstractFont.cpp
  2. 8
      src/Text/AbstractFont.h
  3. 8
      src/Text/FreeTypeFont.cpp
  4. 6
      src/Text/FreeTypeFont.h

4
src/Text/AbstractFont.cpp

@ -26,10 +26,12 @@
namespace Magnum { namespace Text {
AbstractFont::AbstractFont() {}
AbstractFont::AbstractFont(Float size): _size(size) {}
AbstractFont::~AbstractFont() {}
AbstractLayouter::AbstractLayouter(): _glyphCount(0) {}
AbstractLayouter::~AbstractLayouter() {}
}}

8
src/Text/AbstractFont.h

@ -48,9 +48,12 @@ class MAGNUM_TEXT_EXPORT AbstractFont {
AbstractFont& operator=(const AbstractFont&&) = delete;
public:
explicit AbstractFont();
explicit AbstractFont(Float size);
virtual ~AbstractFont() = 0;
/** @brief Font size */
inline Float size() const { return _size; }
/**
* @brief Create glyph cache for given character set
* @param cache Glyph cache instance
@ -69,6 +72,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont {
* @see createGlyphCache()
*/
virtual AbstractLayouter* layout(const GlyphCache* const cache, const Float size, const std::string& text) = 0;
private:
Float _size;
};
/**

8
src/Text/FreeTypeFont.cpp

@ -62,14 +62,14 @@ FreeTypeFontRenderer::~FreeTypeFontRenderer() {
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Done_FreeType(_library) == 0);
}
FreeTypeFont::FreeTypeFont(FreeTypeFontRenderer& renderer, const std::string& fontFile, Float size): _size(size) {
FreeTypeFont::FreeTypeFont(FreeTypeFontRenderer& renderer, const std::string& fontFile, Float size): AbstractFont(size) {
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0);
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Set_Char_Size(_ftFont, 0, _size*64, 100, 100) == 0);
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Set_Char_Size(_ftFont, 0, size*64, 100, 100) == 0);
}
FreeTypeFont::FreeTypeFont(FreeTypeFontRenderer& renderer, const unsigned char* data, std::size_t dataSize, Float size): _size(size) {
FreeTypeFont::FreeTypeFont(FreeTypeFontRenderer& renderer, const unsigned char* data, std::size_t dataSize, Float size): AbstractFont(size) {
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_New_Memory_Face(renderer.library(), data, dataSize, 0, &_ftFont) == 0);
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Set_Char_Size(_ftFont, 0, _size*64, 100, 100) == 0);
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Set_Char_Size(_ftFont, 0, size*64, 100, 100) == 0);
}
void FreeTypeFont::createGlyphCache(GlyphCache* const cache, const std::string& characters) {

6
src/Text/FreeTypeFont.h

@ -102,9 +102,6 @@ class MAGNUM_TEXT_EXPORT FreeTypeFont: public AbstractFont {
~FreeTypeFont();
/** @brief Font size */
inline Float size() const { return _size; }
/** @brief FreeType font handle */
inline FT_Face font() { return _ftFont; }
@ -117,9 +114,6 @@ class MAGNUM_TEXT_EXPORT FreeTypeFont: public AbstractFont {
protected:
#endif
FT_Face _ftFont;
private:
Float _size;
};
}}

Loading…
Cancel
Save