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 // Definitions internal to Minikin 17 18 #define LOG_TAG "Minikin" 19 20 #include "MinikinInternal.h" 21 22 #include <log/log.h> 23 24 #include "FeatureFlags.h" 25 #include "minikin/MinikinPaint.h" 26 27 namespace minikin { 28 isBMPVariationSelector(uint32_t codePoint)29inline static bool isBMPVariationSelector(uint32_t codePoint) { 30 return VS1 <= codePoint && codePoint <= VS16; 31 } 32 isVariationSelectorSupplement(uint32_t codePoint)33inline static bool isVariationSelectorSupplement(uint32_t codePoint) { 34 return VS17 <= codePoint && codePoint <= VS256; 35 } 36 getVsIndex(uint32_t codePoint)37uint16_t getVsIndex(uint32_t codePoint) { 38 if (isBMPVariationSelector(codePoint)) { 39 return codePoint - VS1; 40 } else if (isVariationSelectorSupplement(codePoint)) { 41 return codePoint - VS17 + 16; 42 } else { 43 return INVALID_VS_INDEX; 44 } 45 } 46 isVariationSelector(uint32_t codePoint)47bool isVariationSelector(uint32_t codePoint) { 48 return isBMPVariationSelector(codePoint) || isVariationSelectorSupplement(codePoint); 49 } 50 skipCache() const51bool MinikinPaint::skipCache() const { 52 if (features::letter_spacing_justification()) { 53 return false; // if the flag is on, do not skip the cache. 54 } else { 55 return !fontFeatureSettings.empty(); 56 } 57 } 58 59 } // namespace minikin 60