1 // $Id: ClientSideFont.hh 5748 2014-10-11 19:38:53Z flaterco $ 2 3 /* 4 Copyright (C) 2012 David Flater. 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 namespace libxtide { 21 22 namespace ClientSide { 23 24 struct Pixel { 25 int x; // Can be negative (some glyphs start left of origin). 26 int y; 27 uint8_t opacity; // Divide by 255 to get 0..1. 28 }; 29 30 struct Glyph { 31 unsigned advance; 32 SafeVector<Pixel> pixels; 33 }; 34 35 struct Font { 36 unsigned height; // For line spacing. 37 unsigned oughtHeight; // For vertical alignment of depth labels. 38 SafeVector<Glyph> glyphs; // size = 256 39 }; 40 41 } 42 43 const unsigned stringWidth (const ClientSide::Font &font, const Dstr &s); 44 45 } 46