Browse Source

Text: moved FontRenderer into Font header.

Now everything related to FreeType and HarfBuzz is in one header.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
c864fefb95
  1. 2
      src/Text/CMakeLists.txt
  2. 8
      src/Text/Font.cpp
  3. 24
      src/Text/Font.h
  4. 32
      src/Text/FontRenderer.cpp
  5. 52
      src/Text/FontRenderer.h

2
src/Text/CMakeLists.txt

@ -8,11 +8,9 @@ endif()
set(MagnumText_SRCS set(MagnumText_SRCS
Font.cpp Font.cpp
FontRenderer.cpp
TextRenderer.cpp) TextRenderer.cpp)
set(MagnumText_HEADERS set(MagnumText_HEADERS
Font.h Font.h
FontRenderer.h
Text.h Text.h
TextRenderer.h TextRenderer.h

8
src/Text/Font.cpp

@ -30,6 +30,14 @@
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
FontRenderer::FontRenderer() {
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Init_FreeType(&_library) == 0);
}
FontRenderer::~FontRenderer() {
FT_Done_FreeType(_library);
}
Font::Font(FontRenderer& renderer, const std::string& fontFile, Float size): _size(size) { Font::Font(FontRenderer& renderer, const std::string& fontFile, Float size): _size(size) {
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0); CORRADE_INTERNAL_ASSERT_OUTPUT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0);

24
src/Text/Font.h

@ -16,18 +16,19 @@
*/ */
/** @file /** @file
* @brief Class Magnum::Text::Font, Magnum::Text::TextLayouter * @brief Class Magnum::Text::FontRenderer, Magnum::Text::Font, Magnum::Text::TextLayouter
*/ */
#include <unordered_map> #include <unordered_map>
#include "Math/Geometry/Rectangle.h" #include "Math/Geometry/Rectangle.h"
#include "Texture.h" #include "Texture.h"
#include "Text/FontRenderer.h"
#include "magnumTextVisibility.h" #include "magnumTextVisibility.h"
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
struct FT_LibraryRec_;
typedef FT_LibraryRec_* FT_Library;
struct FT_FaceRec_; struct FT_FaceRec_;
typedef FT_FaceRec_* FT_Face; typedef FT_FaceRec_* FT_Face;
struct hb_font_t; struct hb_font_t;
@ -38,6 +39,25 @@ struct hb_glyph_position_t;
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
/**
@brief %Font renderer
Contains global instance of font renderer. See Font class documentation for
more information.
*/
class MAGNUM_TEXT_EXPORT FontRenderer {
public:
explicit FontRenderer();
~FontRenderer();
/** @brief FreeType library handle */
inline FT_Library library() { return _library; }
private:
FT_Library _library;
};
/** /**
@brief %Font @brief %Font

32
src/Text/FontRenderer.cpp

@ -1,32 +0,0 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum 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 Lesser General Public License version 3 for more details.
*/
#include "FontRenderer.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <Corrade/Utility/Assert.h>
namespace Magnum { namespace Text {
FontRenderer::FontRenderer() {
CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Init_FreeType(&_library) == 0);
}
FontRenderer::~FontRenderer() {
FT_Done_FreeType(_library);
}
}}

52
src/Text/FontRenderer.h

@ -1,52 +0,0 @@
#ifndef Magnum_Text_FontRenderer_h
#define Magnum_Text_FontRenderer_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum 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 Lesser General Public License version 3 for more details.
*/
/** @file
* @brief Class Magnum::Text::FontRenderer
*/
#include "magnumTextVisibility.h"
#ifndef DOXYGEN_GENERATING_OUTPUT
struct FT_LibraryRec_;
typedef FT_LibraryRec_* FT_Library;
#endif
namespace Magnum { namespace Text {
/**
@brief %Font renderer
Contains global instance of font renderer. See Font class documentation for
more information.
*/
class MAGNUM_TEXT_EXPORT FontRenderer {
public:
explicit FontRenderer();
~FontRenderer();
/** @brief FreeType library handle */
inline FT_Library library() { return _library; }
private:
FT_Library _library;
};
}}
#endif
Loading…
Cancel
Save