Mercurial > malikania
view libclient/malikania/font.hpp @ 42:a47a4477f347
Misc: new style, closes #578
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 29 Nov 2016 21:21:36 +0100 |
parents | 9af360f34c7d |
children | fabbe1759cec |
line wrap: on
line source
/* * font.hpp -- font object * * Copyright (c) 2013-2016 Malikania Authors * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef MALIKANIA_FONT_HPP #define MALIKANIA_FONT_HPP /** * \file font.hpp * \brief fonts. */ #include <memory> #include <string> #include "size.hpp" namespace malikania { /** * \brief font object. */ class font { private: class backend_impl; std::unique_ptr<backend_impl> m_backend; unsigned m_size; public: /** * Construct a font from binary data. * * \param data the raw data * \param size the size */ font(std::string data, unsigned size); /** * Default move constructor. * * \param other the other font */ font(font&& other) noexcept; /** * Default destructor. */ virtual ~font() noexcept; /** * Get the font size. * * \return the font size */ inline unsigned size() const noexcept { return m_size; } /** * Get the underlying backend. * * \return the backend */ inline const backend_impl& backend() const noexcept { return *m_backend; } /** * Overloaded function. * * \return the backend */ inline backend_impl& backend() noexcept { return *m_backend; } /** * Get the clipping size required to draw the given text. * * \param text the text to clip * \return the required size */ malikania::size clip(const std::string& text) const; /** * Default move assignment operator. * * \param other the other font * \return this */ font& operator=(font&& other) noexcept; }; } // !malikania #endif // MALIKANIA_FONT_HPP