gfx/graphite2/src/inc/Silf.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*  GRAPHITE2 LICENSING
     3     Copyright 2010, SIL International
     4     All rights reserved.
     6     This library is free software; you can redistribute it and/or modify
     7     it under the terms of the GNU Lesser General Public License as published
     8     by the Free Software Foundation; either version 2.1 of License, or
     9     (at your option) any later version.
    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 GNU
    14     Lesser General Public License for more details.
    16     You should also have received a copy of the GNU Lesser General Public
    17     License along with this library in the file named "LICENSE".
    18     If not, write to the Free Software Foundation, 51 Franklin Street, 
    19     Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
    20     internet at http://www.fsf.org/licenses/lgpl.html.
    22 Alternatively, the contents of this file may be used under the terms of the
    23 Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
    24 License, as published by the Free Software Foundation, either version 2
    25 of the License or (at your option) any later version.
    26 */
    27 #pragma once
    29 #include "graphite2/Font.h"
    30 #include "inc/Main.h"
    31 #include "inc/Pass.h"
    33 namespace graphite2 {
    35 class Face;
    36 class Segment;
    37 class FeatureVal;
    38 class VMScratch;
    39 class Error;
    41 class Pseudo
    42 {
    43 public:
    44     uint32 uid;
    45     uint32 gid;
    46     CLASS_NEW_DELETE;
    47 };
    49 class Justinfo
    50 {
    51 public:
    52     Justinfo(uint8 stretch, uint8 shrink, uint8 step, uint8 weight) :
    53         m_astretch(stretch), m_ashrink(shrink), m_astep(step),
    54         m_aweight(weight) {};
    55     uint8 attrStretch() const { return m_astretch; }
    56     uint8 attrShrink() const { return m_ashrink; }
    57     uint8 attrStep() const { return m_astep; }
    58     uint8 attrWeight() const { return m_aweight; }
    60 private:
    61     uint8   m_astretch;
    62     uint8   m_ashrink;
    63     uint8   m_astep;
    64     uint8   m_aweight;
    65 };
    67 class Silf
    68 {
    69     // Prevent copying
    70     Silf(const Silf&);
    71     Silf& operator=(const Silf&);
    73 public:
    74     Silf() throw();
    75     ~Silf() throw();
    77     bool readGraphite(const byte * const pSilf, size_t lSilf, Face &face, uint32 version);
    78     bool runGraphite(Segment *seg, uint8 firstPass=0, uint8 lastPass=0, int dobidi = 0) const;
    79     uint16 findClassIndex(uint16 cid, uint16 gid) const;
    80     uint16 getClassGlyph(uint16 cid, unsigned int index) const;
    81     uint16 findPseudo(uint32 uid) const;
    82     uint8 numUser() const { return m_aUser; }
    83     uint8 aPseudo() const { return m_aPseudo; }
    84     uint8 aBreak() const { return m_aBreak; }
    85     uint8 aMirror() const {return m_aMirror; }
    86     uint8 aPassBits() const { return m_aPassBits; }
    87     uint8 aBidi() const { return m_aBidi; }
    88     uint8 substitutionPass() const { return m_sPass; }
    89     uint8 positionPass() const { return m_pPass; }
    90     uint8 justificationPass() const { return m_jPass; }
    91     uint8 bidiPass() const { return m_bPass; }
    92     uint8 numPasses() const { return m_numPasses; }
    93     uint8 maxCompPerLig() const { return m_iMaxComp; }
    94     uint16 numClasses() const { return m_nClass; }
    95     byte  flags() const { return m_flags; }
    96     uint8 numJustLevels() const { return m_numJusts; }
    97     Justinfo *justAttrs() const { return m_justs; }
    98     uint16 endLineGlyphid() const { return m_gEndLine; }
    99     const gr_faceinfo *silfInfo() const { return &m_silfinfo; }
   101     CLASS_NEW_DELETE;
   103 private:
   104     size_t readClassMap(const byte *p, size_t data_len, uint32 version, Error &e);
   105     template<typename T> inline uint32 readClassOffsets(const byte *&p, size_t data_len, Error &e);
   107     Pass          * m_passes;
   108     Pseudo        * m_pseudos;
   109     uint32        * m_classOffsets;
   110     uint16        * m_classData;
   111     Justinfo      * m_justs;
   112     uint8           m_numPasses;
   113     uint8           m_numJusts;
   114     uint8           m_sPass, m_pPass, m_jPass, m_bPass,
   115                     m_flags;
   117     uint8   m_aPseudo, m_aBreak, m_aUser, m_aBidi, m_aMirror, m_aPassBits,
   118             m_iMaxComp;
   119     uint16  m_aLig,
   120             m_numPseudo,
   121             m_nClass,
   122             m_nLinear,
   123             m_gEndLine;
   124     gr_faceinfo m_silfinfo;
   126     void releaseBuffers() throw();
   127 };
   129 } // namespace graphite2

mercurial