1 /* 2 * Copyright (C) 2022 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 package android.text; 18 19 import android.annotation.NonNull; 20 21 import java.util.Collections; 22 import java.util.Set; 23 24 25 /** 26 * The set of emoji that should be drawn by the system with the default font for device consistency. 27 * 28 * This is intended to be used only by applications that do custom emoji rendering using tools like 29 * {@link android.text.style.ReplacementSpan} or custom emoji fonts. 30 * 31 * An example of how this should be used: 32 * 33 * <p> 34 * <ol> 35 * <li> 36 * Match emoji for third party custom rendering 37 * </li> 38 * <li> 39 * For each match, check against NonStandardEmoji before displaying custom glyph 40 * </li> 41 * <li> 42 * If in NonStandardEmojiSet, do not display custom glyph (render with 43 * android.graphics.Typeface.DEFAULT instead) 44 * </li> 45 * <li> 46 * Otherwise, do custom rendering like normal 47 * </li> 48 * </ol> 49 * </p> 50 */ 51 @android.ravenwood.annotation.RavenwoodKeepWholeClass 52 public final class EmojiConsistency { 53 /* Cannot construct */ EmojiConsistency()54 private EmojiConsistency() { } 55 56 /** 57 * The set of emoji that should be drawn by the system with the default font for device 58 * consistency. 59 * 60 * Apps SHOULD attempt to avoid overwriting system emoji rendering with custom emoji glyphs for 61 * these codepoint sequences. 62 * 63 * Apps that display custom emoji glyphs via matching code may filter against this set. On 64 * match, the application SHOULD prefer Typeface.Default instead of a custom glyph 65 * 66 * Apps that use fonts may use this set to add {@link android.text.style.TypefaceSpan} for 67 * android.graphics.Typeface.DEFAULT for matched codepoint sequences. 68 * 69 * Codepoint sequences returned MUST match exactly to be considered a match with the exception 70 * of Variation Selectors. 71 * 72 * All codepoint sequences returned MUST be a complete emoji codepoint sequence as defined by 73 * unicode. 74 * 75 * @return set of codepoint sequences representing codepoints that should be rendered by the 76 * system using the default font. 77 */ 78 @NonNull getEmojiConsistencySet()79 public static Set<int[]> getEmojiConsistencySet() { 80 return Collections.emptySet(); 81 } 82 83 } 84