Path: blob/master/thirdparty/graphite/src/inc/Face.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 once45#include <cstdio>67#include "graphite2/Font.h"89#include "inc/Main.h"10#include "inc/FeatureMap.h"11#include "inc/TtfUtil.h"12#include "inc/Silf.h"13#include "inc/Error.h"1415namespace graphite2 {1617class Cmap;18class FileFace;19class GlyphCache;20class NameTable;21class json;22class Font;232425using TtfUtil::Tag;2627// These are the actual tags, as distinct from the consecutive IDs in TtfUtil.h2829class Face30{31// Prevent any kind of copying32Face(const Face&);33Face& operator=(const Face&);3435public:36class Table;37static float default_glyph_advance(const void* face_ptr, gr_uint16 glyphid);3839Face(const void* appFaceHandle/*non-NULL*/, const gr_face_ops & ops);40virtual ~Face();4142virtual bool runGraphite(Segment *seg, const Silf *silf) const;4344public:45bool readGlyphs(uint32 faceOptions);46bool readGraphite(const Table & silf);47bool readFeatures();48void takeFileFace(FileFace* pFileFace/*takes ownership*/);4950const SillMap & theSill() const;51const GlyphCache & glyphs() const;52Cmap & cmap() const;53NameTable * nameTable() const;54void setLogger(FILE *log_file);55json * logger() const throw();5657const Silf * chooseSilf(uint32 script) const;58uint16 languageForLocale(const char * locale) const;5960// Features61uint16 numFeatures() const;62const FeatureRef * featureById(uint32 id) const;63const FeatureRef * feature(uint16 index) const;6465// Glyph related66int32 getGlyphMetric(uint16 gid, uint8 metric) const;67uint16 findPseudo(uint32 uid) const;6869// Errors70unsigned int error() const { return m_error; }71bool error(Error e) { m_error = e.error(); return false; }72unsigned int error_context() const { return m_error; }73void error_context(unsigned int errcntxt) { m_errcntxt = errcntxt; }7475CLASS_NEW_DELETE;76private:77SillMap m_Sill;78gr_face_ops m_ops;79const void * m_appFaceHandle; // non-NULL80FileFace * m_pFileFace; //owned81mutable GlyphCache * m_pGlyphFaceCache; // owned - never NULL82mutable Cmap * m_cmap; // cmap cache if available83mutable NameTable * m_pNames;84mutable json * m_logger;85unsigned int m_error;86unsigned int m_errcntxt;87protected:88Silf * m_silfs; // silf subtables.89uint16 m_numSilf; // num silf subtables in the silf table90private:91uint16 m_ascent,92m_descent;93#ifdef GRAPHITE2_TELEMETRY94public:95mutable telemetry tele;96#endif97};9899100101inline102const SillMap & Face::theSill() const103{104return m_Sill;105}106107inline108uint16 Face::numFeatures() const109{110return m_Sill.theFeatureMap().numFeats();111}112113inline114const FeatureRef * Face::featureById(uint32 id) const115{116return m_Sill.theFeatureMap().findFeatureRef(id);117}118119inline120const FeatureRef *Face::feature(uint16 index) const121{122return m_Sill.theFeatureMap().feature(index);123}124125inline126const GlyphCache & Face::glyphs() const127{128return *m_pGlyphFaceCache;129}130131inline132Cmap & Face::cmap() const133{134return *m_cmap;135};136137inline138json * Face::logger() const throw()139{140return m_logger;141}142143144145class Face::Table146{147const Face * _f;148mutable const byte * _p;149size_t _sz;150bool _compressed;151152Error decompress();153154void release();155156public:157Table() throw();158Table(const Face & face, const Tag n, uint32 version=0xffffffff) throw();159~Table() throw();160Table(const Table && rhs) throw();161162operator const byte * () const throw();163164size_t size() const throw();165Table & operator = (const Table && rhs) throw();166};167168inline169Face::Table::Table() throw()170: _f(0), _p(0), _sz(0), _compressed(false)171{172}173174inline175Face::Table::Table(const Table && rhs) throw()176: _f(rhs._f), _p(rhs._p), _sz(rhs._sz), _compressed(rhs._compressed)177{178rhs._p = 0;179}180181inline182Face::Table::~Table() throw()183{184release();185}186187inline188Face::Table::operator const byte * () const throw()189{190return _p;191}192193inline194size_t Face::Table::size() const throw()195{196return _sz;197}198199} // namespace graphite2200201struct gr_face : public graphite2::Face {};202203204