tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Pass.h (4591B)


      1 /*  GRAPHITE2 LICENSING
      2 
      3    Copyright 2010, SIL International
      4    All rights reserved.
      5 
      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.
     10 
     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.
     15 
     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.
     21 
     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
     28 
     29 #include <cstdlib>
     30 #include "inc/Code.h"
     31 
     32 namespace graphite2 {
     33 
     34 class Segment;
     35 class Face;
     36 class Silf;
     37 struct Rule;
     38 struct RuleEntry;
     39 struct State;
     40 class FiniteStateMachine;
     41 class Error;
     42 class ShiftCollider;
     43 class KernCollider;
     44 class json;
     45 
     46 enum passtype;
     47 
     48 class Pass
     49 {
     50 public:
     51    Pass();
     52    ~Pass();
     53 
     54    bool readPass(const byte * pPass, size_t pass_length, size_t subtable_base, Face & face,
     55        enum passtype pt, uint32 version, Error &e);
     56    bool runGraphite(vm::Machine & m, FiniteStateMachine & fsm, bool reverse) const;
     57    void init(Silf *silf) { m_silf = silf; }
     58    byte collisionLoops() const { return m_numCollRuns; }
     59    bool reverseDir() const { return m_isReverseDir; }
     60 
     61    CLASS_NEW_DELETE
     62 private:
     63    void    findNDoRule(Slot* & iSlot, vm::Machine &, FiniteStateMachine& fsm) const;
     64    int     doAction(const vm::Machine::Code* codeptr, Slot * & slot_out, vm::Machine &) const;
     65    bool    testPassConstraint(vm::Machine & m) const;
     66    bool    testConstraint(const Rule & r, vm::Machine &) const;
     67    bool    readRules(const byte * rule_map, const size_t num_entries,
     68                     const byte *precontext, const uint16 * sort_key,
     69                     const uint16 * o_constraint, const byte *constraint_data,
     70                     const uint16 * o_action, const byte * action_data,
     71                     Face &, enum passtype pt, Error &e);
     72    bool    readStates(const byte * starts, const byte * states, const byte * o_rule_map, Face &, Error &e);
     73    bool    readRanges(const byte * ranges, size_t num_ranges, Error &e);
     74    uint16  glyphToCol(const uint16 gid) const;
     75    bool    runFSM(FiniteStateMachine & fsm, Slot * slot) const;
     76    void    dumpRuleEventConsidered(const FiniteStateMachine & fsm, const RuleEntry & re) const;
     77    void    dumpRuleEventOutput(const FiniteStateMachine & fsm, const Rule & r, Slot * os) const;
     78    void    adjustSlot(int delta, Slot * & slot_out, SlotMap &) const;
     79    bool    collisionShift(Segment *seg, int dir, json * const dbgout) const;
     80    bool    collisionKern(Segment *seg, int dir, json * const dbgout) const;
     81    bool    collisionFinish(Segment *seg, GR_MAYBE_UNUSED json * const dbgout) const;
     82    bool    resolveCollisions(Segment *seg, Slot *slot, Slot *start, ShiftCollider &coll, bool isRev,
     83                     int dir, bool &moved, bool &hasCol, json * const dbgout) const;
     84    float   resolveKern(Segment *seg, Slot *slot, Slot *start, int dir,
     85                     float &ymin, float &ymax, json *const dbgout) const;
     86 
     87    const Silf        * m_silf;
     88    uint16            * m_cols;
     89    Rule              * m_rules; // rules
     90    RuleEntry         * m_ruleMap;
     91    uint16            * m_startStates; // prectxt length
     92    uint16            * m_transitions;
     93    State             * m_states;
     94    vm::Machine::Code * m_codes;
     95    byte              * m_progs;
     96 
     97    byte   m_numCollRuns;
     98    byte   m_kernColls;
     99    byte   m_iMaxLoop;
    100    uint16 m_numGlyphs;
    101    uint16 m_numRules;
    102    uint16 m_numStates;
    103    uint16 m_numTransition;
    104    uint16 m_numSuccess;
    105    uint16 m_successStart;
    106    uint16 m_numColumns;
    107    byte m_minPreCtxt;
    108    byte m_maxPreCtxt;
    109    byte m_colThreshold;
    110    bool m_isReverseDir;
    111    vm::Machine::Code m_cPConstraint;
    112 
    113 private:        //defensive
    114    Pass(const Pass&);
    115    Pass& operator=(const Pass&);
    116 };
    117 
    118 } // namespace graphite2