gfx/graphite2/src/inc/Silf.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/graphite2/src/inc/Silf.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,129 @@
     1.4 +/*  GRAPHITE2 LICENSING
     1.5 +
     1.6 +    Copyright 2010, SIL International
     1.7 +    All rights reserved.
     1.8 +
     1.9 +    This library is free software; you can redistribute it and/or modify
    1.10 +    it under the terms of the GNU Lesser General Public License as published
    1.11 +    by the Free Software Foundation; either version 2.1 of License, or
    1.12 +    (at your option) any later version.
    1.13 +
    1.14 +    This program is distributed in the hope that it will be useful,
    1.15 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 +    Lesser General Public License for more details.
    1.18 +
    1.19 +    You should also have received a copy of the GNU Lesser General Public
    1.20 +    License along with this library in the file named "LICENSE".
    1.21 +    If not, write to the Free Software Foundation, 51 Franklin Street, 
    1.22 +    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
    1.23 +    internet at http://www.fsf.org/licenses/lgpl.html.
    1.24 +
    1.25 +Alternatively, the contents of this file may be used under the terms of the
    1.26 +Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
    1.27 +License, as published by the Free Software Foundation, either version 2
    1.28 +of the License or (at your option) any later version.
    1.29 +*/
    1.30 +#pragma once
    1.31 +
    1.32 +#include "graphite2/Font.h"
    1.33 +#include "inc/Main.h"
    1.34 +#include "inc/Pass.h"
    1.35 +
    1.36 +namespace graphite2 {
    1.37 +
    1.38 +class Face;
    1.39 +class Segment;
    1.40 +class FeatureVal;
    1.41 +class VMScratch;
    1.42 +class Error;
    1.43 +
    1.44 +class Pseudo
    1.45 +{
    1.46 +public:
    1.47 +    uint32 uid;
    1.48 +    uint32 gid;
    1.49 +    CLASS_NEW_DELETE;
    1.50 +};
    1.51 +
    1.52 +class Justinfo
    1.53 +{
    1.54 +public:
    1.55 +    Justinfo(uint8 stretch, uint8 shrink, uint8 step, uint8 weight) :
    1.56 +        m_astretch(stretch), m_ashrink(shrink), m_astep(step),
    1.57 +        m_aweight(weight) {};
    1.58 +    uint8 attrStretch() const { return m_astretch; }
    1.59 +    uint8 attrShrink() const { return m_ashrink; }
    1.60 +    uint8 attrStep() const { return m_astep; }
    1.61 +    uint8 attrWeight() const { return m_aweight; }
    1.62 +
    1.63 +private:
    1.64 +    uint8   m_astretch;
    1.65 +    uint8   m_ashrink;
    1.66 +    uint8   m_astep;
    1.67 +    uint8   m_aweight;
    1.68 +};
    1.69 +
    1.70 +class Silf
    1.71 +{
    1.72 +    // Prevent copying
    1.73 +    Silf(const Silf&);
    1.74 +    Silf& operator=(const Silf&);
    1.75 +
    1.76 +public:
    1.77 +    Silf() throw();
    1.78 +    ~Silf() throw();
    1.79 +    
    1.80 +    bool readGraphite(const byte * const pSilf, size_t lSilf, Face &face, uint32 version);
    1.81 +    bool runGraphite(Segment *seg, uint8 firstPass=0, uint8 lastPass=0, int dobidi = 0) const;
    1.82 +    uint16 findClassIndex(uint16 cid, uint16 gid) const;
    1.83 +    uint16 getClassGlyph(uint16 cid, unsigned int index) const;
    1.84 +    uint16 findPseudo(uint32 uid) const;
    1.85 +    uint8 numUser() const { return m_aUser; }
    1.86 +    uint8 aPseudo() const { return m_aPseudo; }
    1.87 +    uint8 aBreak() const { return m_aBreak; }
    1.88 +    uint8 aMirror() const {return m_aMirror; }
    1.89 +    uint8 aPassBits() const { return m_aPassBits; }
    1.90 +    uint8 aBidi() const { return m_aBidi; }
    1.91 +    uint8 substitutionPass() const { return m_sPass; }
    1.92 +    uint8 positionPass() const { return m_pPass; }
    1.93 +    uint8 justificationPass() const { return m_jPass; }
    1.94 +    uint8 bidiPass() const { return m_bPass; }
    1.95 +    uint8 numPasses() const { return m_numPasses; }
    1.96 +    uint8 maxCompPerLig() const { return m_iMaxComp; }
    1.97 +    uint16 numClasses() const { return m_nClass; }
    1.98 +    byte  flags() const { return m_flags; }
    1.99 +    uint8 numJustLevels() const { return m_numJusts; }
   1.100 +    Justinfo *justAttrs() const { return m_justs; }
   1.101 +    uint16 endLineGlyphid() const { return m_gEndLine; }
   1.102 +    const gr_faceinfo *silfInfo() const { return &m_silfinfo; }
   1.103 +
   1.104 +    CLASS_NEW_DELETE;
   1.105 +
   1.106 +private:
   1.107 +    size_t readClassMap(const byte *p, size_t data_len, uint32 version, Error &e);
   1.108 +    template<typename T> inline uint32 readClassOffsets(const byte *&p, size_t data_len, Error &e);
   1.109 +
   1.110 +    Pass          * m_passes;
   1.111 +    Pseudo        * m_pseudos;
   1.112 +    uint32        * m_classOffsets;
   1.113 +    uint16        * m_classData;
   1.114 +    Justinfo      * m_justs;
   1.115 +    uint8           m_numPasses;
   1.116 +    uint8           m_numJusts;
   1.117 +    uint8           m_sPass, m_pPass, m_jPass, m_bPass,
   1.118 +                    m_flags;
   1.119 +
   1.120 +    uint8   m_aPseudo, m_aBreak, m_aUser, m_aBidi, m_aMirror, m_aPassBits,
   1.121 +            m_iMaxComp;
   1.122 +    uint16  m_aLig,
   1.123 +            m_numPseudo,
   1.124 +            m_nClass,
   1.125 +            m_nLinear,
   1.126 +            m_gEndLine;
   1.127 +    gr_faceinfo m_silfinfo;
   1.128 +    
   1.129 +    void releaseBuffers() throw();
   1.130 +};
   1.131 +
   1.132 +} // namespace graphite2

mercurial