flutter_flutter/libs/minikin/MinikinInternal.cpp
Raph Levien 1934c2c3cb Fix wrong conditions in isEmojiBase
I computed ranges using low <= c || c <= high, should be &&.

Bug: 26829153
Change-Id: Ic1002d90b6a408a0b415f2d117d0e57adcbc2fa9
2016-02-27 07:43:56 -08:00

76 lines
2.4 KiB
C++

/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Definitions internal to Minikin
#include "MinikinInternal.h"
#include <cutils/log.h>
namespace android {
Mutex gMinikinLock;
void assertMinikinLocked() {
#ifdef ENABLE_RACE_DETECTION
LOG_ALWAYS_FATAL_IF(gMinikinLock.tryLock() == 0);
#endif
}
// Based on Modifiers from http://www.unicode.org/L2/L2016/16011-data-file.txt
bool isEmojiModifier(uint32_t c) {
return (0x1F3FB <= c && c <= 0x1F3FF);
}
// Based on Emoji_Modifier_Base from
// http://www.unicode.org/Public/emoji/3.0/emoji-data.txt
bool isEmojiBase(uint32_t c) {
if (0x261D <= c && c <= 0x270D) {
return (c == 0x261D || c == 0x26F9 || (0x270A <= c && c <= 0x270D));
} else if (0x1F385 <= c && c <= 0x1F93E) {
return (c == 0x1F385
|| (0x1F3C3 <= c && c <= 0x1F3C4)
|| (0x1F3CA <= c && c <= 0x1F3CB)
|| (0x1F442 <= c && c <= 0x1F443)
|| (0x1F446 <= c && c <= 0x1F450)
|| (0x1F466 <= c && c <= 0x1F469)
|| c == 0x1F46E
|| (0x1F470 <= c && c <= 0x1F478)
|| c == 0x1F47C
|| (0x1F481 <= c && c <= 0x1F483)
|| (0x1F485 <= c && c <= 0x1F487)
|| c == 0x1F4AA
|| c == 0x1F575
|| c == 0x1F57A
|| c == 0x1F590
|| (0x1F595 <= c && c <= 0x1F596)
|| (0x1F645 <= c && c <= 0x1F647)
|| (0x1F64B <= c && c <= 0x1F64F)
|| c == 0x1F6A3
|| (0x1F6B4 <= c && c <= 0x1F6B6)
|| c == 0x1F6C0
|| (0x1F918 <= c && c <= 0x1F91E)
|| c == 0x1F926
|| c == 0x1F930
|| (0x1F933 <= c && c <= 0x1F939)
|| (0x1F93B <= c && c <= 0x1F93E));
} else {
return false;
}
}
}