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