1 /** @file compositebitmapfont.h Composite bitmap font. 2 * 3 * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net> 5 * 6 * @par License 7 * GPL: http://www.gnu.org/licenses/gpl.html 8 * 9 * <small>This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by the 11 * Free Software Foundation; either version 2 of the License, or (at your 12 * option) any later version. This program is distributed in the hope that it 13 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 * Public License for more details. You should have received a copy of the GNU 16 * General Public License along with this program; if not, see: 17 * http://www.gnu.org/licenses</small> 18 */ 19 20 #ifndef CLIENT_RESOURCE_COMPOSITEBITMAPFONT_H 21 #define CLIENT_RESOURCE_COMPOSITEBITMAPFONT_H 22 23 #include "abstractfont.h" 24 #include "resource/clienttexture.h" 25 #include <de/Rectangle> 26 #include <de/String> 27 #include <de/Vector> 28 29 struct ded_compositefont_s; 30 31 /** 32 * Composite bitmap font. 33 * 34 * @ingroup resource 35 */ 36 class CompositeBitmapFont : public AbstractFont 37 { 38 public: 39 struct Glyph 40 { 41 de::Rectanglei geometry; 42 patchid_t patch; 43 TextureVariant *tex; 44 uint8_t border; 45 bool haveSourceImage; 46 }; 47 48 public: 49 CompositeBitmapFont(de::FontManifest &manifest); 50 51 static CompositeBitmapFont *fromDef(de::FontManifest &manifest, struct ded_compositefont_s const &def); 52 53 struct ded_compositefont_s *definition() const; 54 void setDefinition(struct ded_compositefont_s *newDef); 55 56 /** 57 * Update the font according to the supplied definition. To be called after 58 * an engine update/reset. 59 * 60 * @param def Definition to update using. 61 * 62 * @todo Should observe engine reset. 63 */ 64 void rebuildFromDef(struct ded_compositefont_s const &def); 65 66 int ascent() const override; 67 int descent() const override; 68 int lineSpacing() const override; 69 70 void glInit() const override; 71 void glDeinit() const override; 72 73 de::Rectanglei const &glyphPosCoords(uchar ch) const override; 74 de::Rectanglei const &glyphTexCoords(uchar ch) const override; 75 76 patchid_t glyphPatch(uchar ch) const; 77 void glyphSetPatch(uchar ch, de::String encodedPatchName); 78 TextureVariant *glyphTexture(uchar ch) const; 79 uint glyphTextureBorder(uchar ch) const; 80 81 private: 82 DENG2_PRIVATE(d) 83 }; 84 85 #endif // CLIENT_RESOURCE_COMPOSITEBITMAPFONT_H 86