| 1 | // SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later |
| 2 | // Copyright 2010, SIL International, All rights reserved. |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "inc/Main.h" |
| 7 | #include "inc/Position.h" |
| 8 | #include "inc/Sparse.h" |
| 9 | |
| 10 | namespace graphite2 { |
| 11 | |
| 12 | enum metrics { |
| 13 | kgmetLsb = 0, kgmetRsb, |
| 14 | kgmetBbTop, kgmetBbBottom, kgmetBbLeft, kgmetBbRight, |
| 15 | kgmetBbHeight, kgmetBbWidth, |
| 16 | kgmetAdvWidth, kgmetAdvHeight, |
| 17 | kgmetAscent, kgmetDescent |
| 18 | }; |
| 19 | |
| 20 | |
| 21 | class GlyphFace |
| 22 | { |
| 23 | public: |
| 24 | GlyphFace(); |
| 25 | template<typename I> |
| 26 | GlyphFace(const Rect & bbox, const Position & adv, I first, const I last); |
| 27 | |
| 28 | const Position & theAdvance() const; |
| 29 | const Rect & theBBox() const { return m_bbox; } |
| 30 | const sparse & attrs() const { return m_attrs; } |
| 31 | int32 getMetric(uint8 metric) const; |
| 32 | |
| 33 | CLASS_NEW_DELETE; |
| 34 | private: |
| 35 | Rect m_bbox; // bounding box metrics in design units |
| 36 | Position m_advance; // Advance width and height in design units |
| 37 | sparse m_attrs; |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | // Inlines: class GlyphFace |
| 42 | // |
| 43 | inline |
| 44 | GlyphFace::GlyphFace() |
| 45 | {} |
| 46 | |
| 47 | template<typename I> |
| 48 | GlyphFace::GlyphFace(const Rect & bbox, const Position & adv, I first, const I last) |
| 49 | : m_bbox(bbox), |
| 50 | m_advance(adv), |
| 51 | m_attrs(first, last) |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | inline |
| 56 | const Position & GlyphFace::theAdvance() const { |
| 57 | return m_advance; |
| 58 | } |
| 59 | |
| 60 | } // namespace graphite2 |
| 61 | |