| 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 | public final class EmojiConsistency { |
| 52 | /* Cannot construct */ |
| 53 | private EmojiConsistency() { } |
| 54 | |
| 55 | /** |
| 56 | * The set of emoji that should be drawn by the system with the default font for device |
| 57 | * consistency. |
| 58 | * |
| 59 | * Apps SHOULD attempt to avoid overwriting system emoji rendering with custom emoji glyphs for |
| 60 | * these codepoint sequences. |
| 61 | * |
| 62 | * Apps that display custom emoji glyphs via matching code may filter against this set. On |
| 63 | * match, the application SHOULD prefer Typeface.Default instead of a custom glyph |
| 64 | * |
| 65 | * Apps that use fonts may use this set to add {@link android.text.style.TypefaceSpan} for |
| 66 | * android.graphics.Typeface.DEFAULT for matched codepoint sequences. |
| 67 | * |
| 68 | * Codepoint sequences returned MUST match exactly to be considered a match with the exception |
| 69 | * of Variation Selectors. |
| 70 | * |
| 71 | * All codepoint sequences returned MUST be a complete emoji codepoint sequence as defined by |
| 72 | * unicode. |
| 73 | * |
| 74 | * @return set of codepoint sequences representing codepoints that should be rendered by the |
| 75 | * system using the default font. |
| 76 | */ |
| 77 | @NonNull |
| 78 | public static Set<int[]> getEmojiConsistencySet() { |
| 79 | return Collections.emptySet(); |
| 80 | } |
| 81 | |
| 82 | } |