From c864fefb951aa82775f0b24d62e7545578a055d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 4 Mar 2013 11:48:31 +0100 Subject: [PATCH] Text: moved FontRenderer into Font header. Now everything related to FreeType and HarfBuzz is in one header. --- src/Text/CMakeLists.txt | 2 -- src/Text/Font.cpp | 8 ++++++ src/Text/Font.h | 24 ++++++++++++++++-- src/Text/FontRenderer.cpp | 32 ------------------------ src/Text/FontRenderer.h | 52 --------------------------------------- 5 files changed, 30 insertions(+), 88 deletions(-) delete mode 100644 src/Text/FontRenderer.cpp delete mode 100644 src/Text/FontRenderer.h diff --git a/src/Text/CMakeLists.txt b/src/Text/CMakeLists.txt index c97dcaed0..42d2586d7 100644 --- a/src/Text/CMakeLists.txt +++ b/src/Text/CMakeLists.txt @@ -8,11 +8,9 @@ endif() set(MagnumText_SRCS Font.cpp - FontRenderer.cpp TextRenderer.cpp) set(MagnumText_HEADERS Font.h - FontRenderer.h Text.h TextRenderer.h diff --git a/src/Text/Font.cpp b/src/Text/Font.cpp index 30c03f11d..f95802d6b 100644 --- a/src/Text/Font.cpp +++ b/src/Text/Font.cpp @@ -30,6 +30,14 @@ 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) { CORRADE_INTERNAL_ASSERT_OUTPUT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0); diff --git a/src/Text/Font.h b/src/Text/Font.h index a864c01ee..e14040c33 100644 --- a/src/Text/Font.h +++ b/src/Text/Font.h @@ -16,18 +16,19 @@ */ /** @file - * @brief Class Magnum::Text::Font, Magnum::Text::TextLayouter + * @brief Class Magnum::Text::FontRenderer, Magnum::Text::Font, Magnum::Text::TextLayouter */ #include #include "Math/Geometry/Rectangle.h" #include "Texture.h" -#include "Text/FontRenderer.h" #include "magnumTextVisibility.h" #ifndef DOXYGEN_GENERATING_OUTPUT +struct FT_LibraryRec_; +typedef FT_LibraryRec_* FT_Library; struct FT_FaceRec_; typedef FT_FaceRec_* FT_Face; struct hb_font_t; @@ -38,6 +39,25 @@ struct hb_glyph_position_t; 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 diff --git a/src/Text/FontRenderer.cpp b/src/Text/FontRenderer.cpp deleted file mode 100644 index 8b1f540f9..000000000 --- a/src/Text/FontRenderer.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - 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 -#include FT_FREETYPE_H -#include - -namespace Magnum { namespace Text { - -FontRenderer::FontRenderer() { - CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Init_FreeType(&_library) == 0); -} - -FontRenderer::~FontRenderer() { - FT_Done_FreeType(_library); -} - -}} diff --git a/src/Text/FontRenderer.h b/src/Text/FontRenderer.h deleted file mode 100644 index 6fd72ec57..000000000 --- a/src/Text/FontRenderer.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef Magnum_Text_FontRenderer_h -#define Magnum_Text_FontRenderer_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - 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