< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh

Print this page




 815   }
 816 
 817   template <typename set_t>
 818   inline bool add_coverage (set_t *glyphs) const {
 819     unsigned int count = rangeRecord.len;
 820     for (unsigned int i = 0; i < count; i++)
 821       if (unlikely (!rangeRecord[i].add_coverage (glyphs)))
 822         return false;
 823     return true;
 824   }
 825 
 826   public:
 827   /* Older compilers need this to be public. */
 828   struct Iter
 829   {
 830     inline void init (const CoverageFormat2 &c_)
 831     {
 832       c = &c_;
 833       coverage = 0;
 834       i = 0;
 835       j = c->rangeRecord.len ? c_.rangeRecord[0].start : 0;





 836     }
 837     inline bool more (void) { return i < c->rangeRecord.len; }
 838     inline void next (void)
 839     {
 840       if (j >= c->rangeRecord[i].end)
 841       {
 842         i++;
 843         if (more ())
 844         {

 845           j = c->rangeRecord[i].start;






 846           coverage = c->rangeRecord[i].value;
 847         }
 848         return;
 849       }
 850       coverage++;
 851       j++;
 852     }
 853     inline hb_codepoint_t get_glyph (void) { return j; }
 854     inline unsigned int get_coverage (void) { return coverage; }
 855 
 856     private:
 857     const struct CoverageFormat2 *c;
 858     unsigned int i, j, coverage;

 859   };
 860   private:
 861 
 862   protected:
 863   HBUINT16      coverageFormat; /* Format identifier--format = 2 */
 864   SortedArrayOf<RangeRecord>
 865                 rangeRecord;    /* Array of glyph ranges--ordered by
 866                                  * Start GlyphID. rangeCount entries
 867                                  * long */
 868   public:
 869   DEFINE_SIZE_ARRAY (4, rangeRecord);
 870 };
 871 
 872 struct Coverage
 873 {
 874   inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
 875   {
 876     switch (u.format) {
 877     case 1: return u.format1.get_coverage (glyph_id);
 878     case 2: return u.format2.get_coverage (glyph_id);




 815   }
 816 
 817   template <typename set_t>
 818   inline bool add_coverage (set_t *glyphs) const {
 819     unsigned int count = rangeRecord.len;
 820     for (unsigned int i = 0; i < count; i++)
 821       if (unlikely (!rangeRecord[i].add_coverage (glyphs)))
 822         return false;
 823     return true;
 824   }
 825 
 826   public:
 827   /* Older compilers need this to be public. */
 828   struct Iter
 829   {
 830     inline void init (const CoverageFormat2 &c_)
 831     {
 832       c = &c_;
 833       coverage = 0;
 834       i = 0;
 835       j = c->rangeRecord.len ? c->rangeRecord[0].start : 0;
 836       if (unlikely (c->rangeRecord[0].start > c->rangeRecord[0].end))
 837       {
 838         /* Broken table. Skip. */
 839         i = c->rangeRecord.len;
 840       }
 841     }
 842     inline bool more (void) { return i < c->rangeRecord.len; }
 843     inline void next (void)
 844     {
 845       if (j >= c->rangeRecord[i].end)
 846       {
 847         i++;
 848         if (more ())
 849         {
 850           hb_codepoint_t old = j;
 851           j = c->rangeRecord[i].start;
 852           if (unlikely (j <= old))
 853           {
 854             /* Broken table. Skip. Important to avoid DoS. */
 855            i = c->rangeRecord.len;
 856            return;
 857           }
 858           coverage = c->rangeRecord[i].value;
 859         }
 860         return;
 861       }
 862       coverage++;
 863       j++;
 864     }
 865     inline hb_codepoint_t get_glyph (void) { return j; }
 866     inline unsigned int get_coverage (void) { return coverage; }
 867 
 868     private:
 869     const struct CoverageFormat2 *c;
 870     unsigned int i, coverage;
 871     hb_codepoint_t j;
 872   };
 873   private:
 874 
 875   protected:
 876   HBUINT16      coverageFormat; /* Format identifier--format = 2 */
 877   SortedArrayOf<RangeRecord>
 878                 rangeRecord;    /* Array of glyph ranges--ordered by
 879                                  * Start GlyphID. rangeCount entries
 880                                  * long */
 881   public:
 882   DEFINE_SIZE_ARRAY (4, rangeRecord);
 883 };
 884 
 885 struct Coverage
 886 {
 887   inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
 888   {
 889     switch (u.format) {
 890     case 1: return u.format1.get_coverage (glyph_id);
 891     case 2: return u.format2.get_coverage (glyph_id);


< prev index next >