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.annotation.Nullable; 25 import android.text.FontConfig; 26 27 import java.io.File; 28 import java.util.Map; 29 30 import static android.graphics.FontFamily_Delegate.getFontLocation; 31 32 /** 33 * Delegate implementing the native methods of android.graphics.fonts.SystemFonts 34 * <p> 35 * Through the layoutlib_create tool, the original native methods of SystemFonts have been 36 * replaced by calls to methods of the same name in this delegate class. 37 * <p> 38 * This class behaves like the original native implementation, but in Java, keeping previously 39 * native data into its own objects and mapping them to int that are sent back and forth between it 40 * and the original SystemFonts class. 41 * 42 * @see DelegateManager 43 */ 44 public class SystemFonts_Delegate { 45 46 @LayoutlibDelegate getSystemFontConfigInternal( String fontsXml, String systemFontDir, String oemXml, String productFontDir, Map<String, File> updatableFontMap)47 /*package*/ static FontConfig getSystemFontConfigInternal( 48 String fontsXml, 49 String systemFontDir, 50 String oemXml, 51 String productFontDir, 52 Map<String, File> updatableFontMap) { 53 Bridge.sIsTypefaceInitialized = true; 54 return SystemFonts.getSystemFontConfigInternal_Original( 55 getFontLocation() + "/standard/fonts.xml", getFontLocation() + "/", 56 null, null, updatableFontMap, 0, 0); 57 } 58 } 59