Moves on to the next indexable sample. If the end is reached, leaves the state such that AtEnd() is true.
| 154 | // Moves on to the next indexable sample. If the end is reached, leaves |
| 155 | // the state such that AtEnd() is true. |
| 156 | void SampleIterator::Next() { |
| 157 | if (shape_table_ != NULL) { |
| 158 | // Next sample in this class/font combination. |
| 159 | ++sample_index_; |
| 160 | if (sample_index_ < num_samples_) |
| 161 | return; |
| 162 | // Next font in this class in this shape. |
| 163 | sample_index_ = 0; |
| 164 | do { |
| 165 | ++shape_font_index_; |
| 166 | if (shape_font_index_ >= num_shape_fonts_) { |
| 167 | // Next unichar in this shape. |
| 168 | shape_font_index_ = 0; |
| 169 | ++shape_char_index_; |
| 170 | if (shape_char_index_ >= num_shape_chars_) { |
| 171 | // Find the next shape that is mapped in the charset_map_. |
| 172 | shape_char_index_ = 0; |
| 173 | do { |
| 174 | ++shape_index_; |
| 175 | } while (shape_index_ < num_shapes_ && |
| 176 | charset_map_ != NULL && |
| 177 | charset_map_->SparseToCompact(shape_index_) < 0); |
| 178 | if (shape_index_ >= num_shapes_) |
| 179 | return; // The end. |
| 180 | num_shape_chars_ = shape_table_->GetShape(shape_index_).size(); |
| 181 | } |
| 182 | } |
| 183 | const UnicharAndFonts* shape_entry = GetShapeEntry(); |
| 184 | num_shape_fonts_ = shape_entry->font_ids.size(); |
| 185 | int char_id = shape_entry->unichar_id; |
| 186 | int font_id = shape_entry->font_ids[shape_font_index_]; |
| 187 | num_samples_ = sample_set_->NumClassSamples(font_id, char_id, randomize_); |
| 188 | } while (num_samples_ == 0); |
| 189 | } else { |
| 190 | // We are just iterating over the samples. |
| 191 | ++shape_index_; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // Returns the size of the compact charset space. |
| 196 | int SampleIterator::CompactCharsetSize() const { |