MinikinInternal.cpp revision 1934c2c3cb2c93aa12f852f95915190f8ac81fac
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// Definitions internal to Minikin
18
19#include "MinikinInternal.h"
20
21#include <cutils/log.h>
22
23namespace android {
24
25Mutex gMinikinLock;
26
27void assertMinikinLocked() {
28#ifdef ENABLE_RACE_DETECTION
29    LOG_ALWAYS_FATAL_IF(gMinikinLock.tryLock() == 0);
30#endif
31}
32
33// Based on Modifiers from http://www.unicode.org/L2/L2016/16011-data-file.txt
34bool isEmojiModifier(uint32_t c) {
35    return (0x1F3FB <= c && c <= 0x1F3FF);
36}
37
38// Based on Emoji_Modifier_Base from
39// http://www.unicode.org/Public/emoji/3.0/emoji-data.txt
40bool isEmojiBase(uint32_t c) {
41    if (0x261D <= c && c <= 0x270D) {
42        return (c == 0x261D || c == 0x26F9 || (0x270A <= c && c <= 0x270D));
43    } else if (0x1F385 <= c && c <= 0x1F93E) {
44        return (c == 0x1F385
45                || (0x1F3C3 <= c && c <= 0x1F3C4)
46                || (0x1F3CA <= c && c <= 0x1F3CB)
47                || (0x1F442 <= c && c <= 0x1F443)
48                || (0x1F446 <= c && c <= 0x1F450)
49                || (0x1F466 <= c && c <= 0x1F469)
50                || c == 0x1F46E
51                || (0x1F470 <= c && c <= 0x1F478)
52                || c == 0x1F47C
53                || (0x1F481 <= c && c <= 0x1F483)
54                || (0x1F485 <= c && c <= 0x1F487)
55                || c == 0x1F4AA
56                || c == 0x1F575
57                || c == 0x1F57A
58                || c == 0x1F590
59                || (0x1F595 <= c && c <= 0x1F596)
60                || (0x1F645 <= c && c <= 0x1F647)
61                || (0x1F64B <= c && c <= 0x1F64F)
62                || c == 0x1F6A3
63                || (0x1F6B4 <= c && c <= 0x1F6B6)
64                || c == 0x1F6C0
65                || (0x1F918 <= c && c <= 0x1F91E)
66                || c == 0x1F926
67                || c == 0x1F930
68                || (0x1F933 <= c && c <= 0x1F939)
69                || (0x1F93B <= c && c <= 0x1F93E));
70    } else {
71        return false;
72    }
73}
74
75}
76