huangcm
2025-07-01 676035278781360996553c427a12bf358249ebf7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SkClusterator_DEFINED
#define SkClusterator_DEFINED
 
#include <vector>
#include <cstdint>
 
class SkGlyphRun;
 
/** Given the m-to-n glyph-to-character mapping data (as returned by
    harfbuzz), iterate over the clusters. */
class SkClusterator {
public:
    SkClusterator(const SkGlyphRun& run);
    uint32_t glyphCount() const { return fGlyphCount; }
    bool reversedChars() const { return fReversedChars; }
    struct Cluster {
        const char* fUtf8Text;
        uint32_t fTextByteLength;
        uint32_t fGlyphIndex;
        uint32_t fGlyphCount;
        explicit operator bool() const { return fGlyphCount != 0; }
        bool operator==(const SkClusterator::Cluster& o) {
            return fUtf8Text       == o.fUtf8Text
                && fTextByteLength == o.fTextByteLength
                && fGlyphIndex     == o.fGlyphIndex
                && fGlyphCount     == o.fGlyphCount;
        }
    };
    Cluster next();
 
private:
    uint32_t const * const fClusters;
    char const * const fUtf8Text;
    uint32_t const fGlyphCount;
    uint32_t const fTextByteLength;
    bool const fReversedChars;
    uint32_t fCurrentGlyphIndex = 0;
};
 
 
#endif  // SkClusterator_DEFINED