1 /* 2 * Copyright (C) 2018 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.graphics.fonts; 18 19 import com.android.layoutlib.bridge.Bridge; 20 import com.android.layoutlib.bridge.impl.DelegateManager; 21 import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 22 23 import android.annotation.NonNull; 24 import android.text.FontConfig; 25 import android.util.ArrayMap; 26 27 import java.util.ArrayList; 28 29 import static android.graphics.FontFamily_Delegate.getFontLocation; 30 31 /** 32 * Delegate implementing the native methods of android.graphics.fonts.SystemFonts 33 * <p> 34 * Through the layoutlib_create tool, the original native methods of SystemFonts have been 35 * replaced by calls to methods of the same name in this delegate class. 36 * <p> 37 * This class behaves like the original native implementation, but in Java, keeping previously 38 * native data into its own objects and mapping them to int that are sent back and forth between it 39 * and the original SystemFonts class. 40 * 41 * @see DelegateManager 42 */ 43 public class SystemFonts_Delegate { 44 45 @LayoutlibDelegate buildSystemFallback(@onNull String xmlPath, @NonNull String fontDir, @NonNull FontCustomizationParser.Result oemCustomization, @NonNull ArrayMap<String, FontFamily[]> fallbackMap, @NonNull ArrayList<Font> availableFonts)46 /*package*/ static FontConfig.Alias[] buildSystemFallback(@NonNull String xmlPath, 47 @NonNull String fontDir, 48 @NonNull FontCustomizationParser.Result oemCustomization, 49 @NonNull ArrayMap<String, FontFamily[]> fallbackMap, 50 @NonNull ArrayList<Font> availableFonts) { 51 Bridge.sIsTypefaceInitialized = true; 52 return SystemFonts.buildSystemFallback_Original(getFontLocation() + "/standard/fonts.xml", 53 getFontLocation() + "/", oemCustomization, fallbackMap, availableFonts); 54 } 55 } 56