Path: blob/master/thirdparty/graphite/src/inc/Font.h
10279 views
// SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later1// Copyright 2010, SIL International, All rights reserved.23#pragma once4#include <cassert>5#include "graphite2/Font.h"6#include "inc/Main.h"7#include "inc/Face.h"89namespace graphite2 {1011#define INVALID_ADVANCE -1e38f // can't be a static const because non-integral1213class Font14{15public:16Font(float ppm, const Face & face, const void * appFontHandle=0, const gr_font_ops * ops=0);17virtual ~Font();1819float advance(unsigned short glyphid) const;20float scale() const;21bool isHinted() const;22const Face & face() const;23operator bool () const throw() { return m_advances; }2425CLASS_NEW_DELETE;26private:27gr_font_ops m_ops;28const void * const m_appFontHandle;29float * m_advances; // One advance per glyph in pixels. Nan if not defined30const Face & m_face;31float m_scale; // scales from design units to ppm32bool m_hinted;3334Font(const Font&);35Font& operator=(const Font&);36};3738inline39float Font::advance(unsigned short glyphid) const40{41if (m_advances[glyphid] == INVALID_ADVANCE)42m_advances[glyphid] = (*m_ops.glyph_advance_x)(m_appFontHandle, glyphid);43return m_advances[glyphid];44}4546inline47float Font::scale() const48{49return m_scale;50}5152inline53bool Font::isHinted() const54{55return m_hinted;56}5758inline59const Face & Font::face() const60{61return m_face;62}6364} // namespace graphite26566struct gr_font : public graphite2::Font {};676869