1 /* 2 * Copyright (C) 2024 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_LETTER_SPACING_UTILS_H 18 #define MINIKIN_LETTER_SPACING_UTILS_H 19 20 #define LOG_TAG "Minikin" 21 22 #include <hb.h> 23 24 namespace minikin { 25 26 /** 27 * Disable certain scripts (mostly those with cursive connection) from having letterspacing 28 * applied. See https://github.com/behdad/harfbuzz/issues/64 for more details. 29 */ isLetterSpacingCapableScript(hb_script_t script)30inline bool isLetterSpacingCapableScript(hb_script_t script) { 31 return !(script == HB_SCRIPT_ARABIC || script == HB_SCRIPT_NKO || 32 script == HB_SCRIPT_PSALTER_PAHLAVI || script == HB_SCRIPT_MANDAIC || 33 script == HB_SCRIPT_MONGOLIAN || script == HB_SCRIPT_PHAGS_PA || 34 script == HB_SCRIPT_DEVANAGARI || script == HB_SCRIPT_BENGALI || 35 script == HB_SCRIPT_GURMUKHI || script == HB_SCRIPT_MODI || 36 script == HB_SCRIPT_SHARADA || script == HB_SCRIPT_SYLOTI_NAGRI || 37 script == HB_SCRIPT_TIRHUTA || script == HB_SCRIPT_OGHAM); 38 } 39 isLetterSpacingCapableCodePoint(uint32_t cp)40inline bool isLetterSpacingCapableCodePoint(uint32_t cp) { 41 hb_script_t script = hb_unicode_script(hb_unicode_funcs_get_default(), cp); 42 return isLetterSpacingCapableScript(script); 43 } 44 45 } // namespace minikin 46 47 #endif // MINIKIN_LETTER_SPACING_UTILS_H 48