OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2007,2008,2009 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009 Red Hat, Inc. |
3 * Copyright © 2010,2012 Google, Inc. | 3 * Copyright © 2010,2012 Google, Inc. |
4 * | 4 * |
5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
6 * | 6 * |
7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "hb-ot-layout-private.hh" | 32 #include "hb-ot-layout-private.hh" |
33 #include "hb-open-type-private.hh" | 33 #include "hb-open-type-private.hh" |
34 #include "hb-set-private.hh" | 34 #include "hb-set-private.hh" |
35 | 35 |
36 | 36 |
37 namespace OT { | 37 namespace OT { |
38 | 38 |
39 | 39 |
40 #define NOT_COVERED ((unsigned int) -1) | 40 #define NOT_COVERED ((unsigned int) -1) |
41 #define MAX_NESTING_LEVEL 8 | 41 #define MAX_NESTING_LEVEL 8 |
| 42 #define MAX_CONTEXT_LENGTH 64 |
42 | 43 |
43 | 44 |
44 | 45 |
45 /* | 46 /* |
46 * | 47 * |
47 * OpenType Layout Common Table Formats | 48 * OpenType Layout Common Table Formats |
48 * | 49 * |
49 */ | 50 */ |
50 | 51 |
51 | 52 |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 case 2: u.format2.add_coverage (glyphs); break; | 865 case 2: u.format2.add_coverage (glyphs); break; |
865 default: break; | 866 default: break; |
866 } | 867 } |
867 } | 868 } |
868 | 869 |
869 struct Iter { | 870 struct Iter { |
870 Iter (void) : format (0) {}; | 871 Iter (void) : format (0) {}; |
871 inline void init (const Coverage &c_) { | 872 inline void init (const Coverage &c_) { |
872 format = c_.u.format; | 873 format = c_.u.format; |
873 switch (format) { | 874 switch (format) { |
874 case 1: return u.format1.init (c_.u.format1); | 875 case 1: u.format1.init (c_.u.format1); return; |
875 case 2: return u.format2.init (c_.u.format2); | 876 case 2: u.format2.init (c_.u.format2); return; |
876 default:return; | 877 default: return; |
877 } | 878 } |
878 } | 879 } |
879 inline bool more (void) { | 880 inline bool more (void) { |
880 switch (format) { | 881 switch (format) { |
881 case 1: return u.format1.more (); | 882 case 1: return u.format1.more (); |
882 case 2: return u.format2.more (); | 883 case 2: return u.format2.more (); |
883 default:return true; | 884 default:return false; |
884 } | 885 } |
885 } | 886 } |
886 inline void next (void) { | 887 inline void next (void) { |
887 switch (format) { | 888 switch (format) { |
888 case 1: u.format1.next (); break; | 889 case 1: u.format1.next (); break; |
889 case 2: u.format2.next (); break; | 890 case 2: u.format2.next (); break; |
890 default: break; | 891 default: break; |
891 } | 892 } |
892 } | 893 } |
893 inline uint16_t get_glyph (void) { | 894 inline uint16_t get_glyph (void) { |
894 switch (format) { | 895 switch (format) { |
895 case 1: return u.format1.get_glyph (); | 896 case 1: return u.format1.get_glyph (); |
896 case 2: return u.format2.get_glyph (); | 897 case 2: return u.format2.get_glyph (); |
897 default:return true; | 898 default:return 0; |
898 } | 899 } |
899 } | 900 } |
900 inline uint16_t get_coverage (void) { | 901 inline uint16_t get_coverage (void) { |
901 switch (format) { | 902 switch (format) { |
902 case 1: return u.format1.get_coverage (); | 903 case 1: return u.format1.get_coverage (); |
903 case 2: return u.format2.get_coverage (); | 904 case 2: return u.format2.get_coverage (); |
904 default:return true; | 905 default:return -1; |
905 } | 906 } |
906 } | 907 } |
907 | 908 |
908 private: | 909 private: |
909 unsigned int format; | 910 unsigned int format; |
910 union { | 911 union { |
911 CoverageFormat1::Iter format1; | 912 CoverageFormat1::Iter format1; |
912 CoverageFormat2::Iter format2; | 913 CoverageFormat2::Iter format2; |
913 } u; | 914 } u; |
914 }; | 915 }; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 template <typename set_t> | 949 template <typename set_t> |
949 inline void add_class (set_t *glyphs, unsigned int klass) const { | 950 inline void add_class (set_t *glyphs, unsigned int klass) const { |
950 unsigned int count = classValue.len; | 951 unsigned int count = classValue.len; |
951 for (unsigned int i = 0; i < count; i++) | 952 for (unsigned int i = 0; i < count; i++) |
952 if (classValue[i] == klass) | 953 if (classValue[i] == klass) |
953 glyphs->add (startGlyph + i); | 954 glyphs->add (startGlyph + i); |
954 } | 955 } |
955 | 956 |
956 inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) cons
t { | 957 inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) cons
t { |
957 unsigned int count = classValue.len; | 958 unsigned int count = classValue.len; |
| 959 if (klass == 0) |
| 960 { |
| 961 /* Match if there's any glyph that is not listed! */ |
| 962 hb_codepoint_t g = -1; |
| 963 if (!hb_set_next (glyphs, &g)) |
| 964 return false; |
| 965 if (g < startGlyph) |
| 966 return true; |
| 967 g = startGlyph + count - 1; |
| 968 if (hb_set_next (glyphs, &g)) |
| 969 return true; |
| 970 /* Fall through. */ |
| 971 } |
958 for (unsigned int i = 0; i < count; i++) | 972 for (unsigned int i = 0; i < count; i++) |
959 if (classValue[i] == klass && glyphs->has (startGlyph + i)) | 973 if (classValue[i] == klass && glyphs->has (startGlyph + i)) |
960 return true; | 974 return true; |
961 return false; | 975 return false; |
962 } | 976 } |
963 | 977 |
964 protected: | 978 protected: |
965 USHORT classFormat; /* Format identifier--format = 1 */ | 979 USHORT classFormat; /* Format identifier--format = 1 */ |
966 GlyphID startGlyph; /* First GlyphID of the classValueArray
*/ | 980 GlyphID startGlyph; /* First GlyphID of the classValueArray
*/ |
967 ArrayOf<USHORT> | 981 ArrayOf<USHORT> |
(...skipping 23 matching lines...) Expand all Loading... |
991 template <typename set_t> | 1005 template <typename set_t> |
992 inline void add_class (set_t *glyphs, unsigned int klass) const { | 1006 inline void add_class (set_t *glyphs, unsigned int klass) const { |
993 unsigned int count = rangeRecord.len; | 1007 unsigned int count = rangeRecord.len; |
994 for (unsigned int i = 0; i < count; i++) | 1008 for (unsigned int i = 0; i < count; i++) |
995 if (rangeRecord[i].value == klass) | 1009 if (rangeRecord[i].value == klass) |
996 rangeRecord[i].add_coverage (glyphs); | 1010 rangeRecord[i].add_coverage (glyphs); |
997 } | 1011 } |
998 | 1012 |
999 inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) cons
t { | 1013 inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) cons
t { |
1000 unsigned int count = rangeRecord.len; | 1014 unsigned int count = rangeRecord.len; |
| 1015 if (klass == 0) |
| 1016 { |
| 1017 /* Match if there's any glyph that is not listed! */ |
| 1018 hb_codepoint_t g = (hb_codepoint_t) -1; |
| 1019 for (unsigned int i = 0; i < count; i++) |
| 1020 { |
| 1021 if (!hb_set_next (glyphs, &g)) |
| 1022 break; |
| 1023 if (g < rangeRecord[i].start) |
| 1024 return true; |
| 1025 g = rangeRecord[i].end; |
| 1026 } |
| 1027 if (g != (hb_codepoint_t) -1 && hb_set_next (glyphs, &g)) |
| 1028 return true; |
| 1029 /* Fall through. */ |
| 1030 } |
1001 for (unsigned int i = 0; i < count; i++) | 1031 for (unsigned int i = 0; i < count; i++) |
1002 if (rangeRecord[i].value == klass && rangeRecord[i].intersects (glyphs)) | 1032 if (rangeRecord[i].value == klass && rangeRecord[i].intersects (glyphs)) |
1003 return true; | 1033 return true; |
1004 return false; | 1034 return false; |
1005 } | 1035 } |
1006 | 1036 |
1007 protected: | 1037 protected: |
1008 USHORT classFormat; /* Format identifier--format = 2 */ | 1038 USHORT classFormat; /* Format identifier--format = 2 */ |
1009 SortedArrayOf<RangeRecord> | 1039 SortedArrayOf<RangeRecord> |
1010 rangeRecord; /* Array of glyph ranges--ordered by | 1040 rangeRecord; /* Array of glyph ranges--ordered by |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 { return get_delta (font->y_ppem, font->y_scale); } | 1105 { return get_delta (font->y_ppem, font->y_scale); } |
1076 | 1106 |
1077 inline int get_delta (unsigned int ppem, int scale) const | 1107 inline int get_delta (unsigned int ppem, int scale) const |
1078 { | 1108 { |
1079 if (!ppem) return 0; | 1109 if (!ppem) return 0; |
1080 | 1110 |
1081 int pixels = get_delta_pixels (ppem); | 1111 int pixels = get_delta_pixels (ppem); |
1082 | 1112 |
1083 if (!pixels) return 0; | 1113 if (!pixels) return 0; |
1084 | 1114 |
1085 return pixels * (int64_t) scale / ppem; | 1115 return (int) (pixels * (int64_t) scale / ppem); |
1086 } | 1116 } |
1087 | 1117 |
1088 | 1118 |
1089 inline int get_delta_pixels (unsigned int ppem_size) const | 1119 inline int get_delta_pixels (unsigned int ppem_size) const |
1090 { | 1120 { |
1091 unsigned int f = deltaFormat; | 1121 unsigned int f = deltaFormat; |
1092 if (unlikely (f < 1 || f > 3)) | 1122 if (unlikely (f < 1 || f > 3)) |
1093 return 0; | 1123 return 0; |
1094 | 1124 |
1095 if (ppem_size < startSize || ppem_size > endSize) | 1125 if (ppem_size < startSize || ppem_size > endSize) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 USHORT deltaValue[VAR]; /* Array of compressed data */ | 1162 USHORT deltaValue[VAR]; /* Array of compressed data */ |
1133 public: | 1163 public: |
1134 DEFINE_SIZE_ARRAY (6, deltaValue); | 1164 DEFINE_SIZE_ARRAY (6, deltaValue); |
1135 }; | 1165 }; |
1136 | 1166 |
1137 | 1167 |
1138 } /* namespace OT */ | 1168 } /* namespace OT */ |
1139 | 1169 |
1140 | 1170 |
1141 #endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */ | 1171 #endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */ |
OLD | NEW |