Flutter Engine
GraphemeBreak.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINIKIN_GRAPHEME_BREAK_H
18 #define MINIKIN_GRAPHEME_BREAK_H
19 
20 #include <stddef.h>
21 #include <unicode/utf16.h>
22 
23 namespace minikin {
24 
26  public:
27  // These values must be kept in sync with CURSOR_AFTER etc in Paint.java
28  enum MoveOpt {
29  AFTER = 0,
31  BEFORE = 2,
33  AT = 4
34  };
35 
36  // Determine whether the given offset is a grapheme break.
37  // This implementation generally follows Unicode's UTR #29 extended
38  // grapheme break, with various tweaks.
39  static bool isGraphemeBreak(const float* advances,
40  const uint16_t* buf,
41  size_t start,
42  size_t count,
43  size_t offset);
44 
45  // Matches Android's Java API. Note, return (size_t)-1 for AT to
46  // signal non-break because unsigned return type.
47  static size_t getTextRunCursor(const float* advances,
48  const uint16_t* buf,
49  size_t start,
50  size_t count,
51  size_t offset,
52  MoveOpt opt);
53 };
54 
55 } // namespace minikin
56 
57 #endif // MINIKIN_GRAPHEME_BREAK_H
static bool isGraphemeBreak(const float *advances, const uint16_t *buf, size_t start, size_t count, size_t offset)
static size_t getTextRunCursor(const float *advances, const uint16_t *buf, size_t start, size_t count, size_t offset, MoveOpt opt)