mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate com.facebook.react.views.text.ReactFontManager to Kotlin (#47488)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47488 As per title. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D65594248 fbshipit-source-id: 5a21baefb768b1c6f8ec0c33158812d1de6113d5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bcdf6ad1af
commit
791afd3209
@@ -7302,14 +7302,20 @@ public abstract class com/facebook/react/views/text/ReactBaseTextShadowNode : co
|
||||
protected fun spannedFromShadowNode (Lcom/facebook/react/views/text/ReactBaseTextShadowNode;Ljava/lang/String;ZLcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)Landroid/text/Spannable;
|
||||
}
|
||||
|
||||
public class com/facebook/react/views/text/ReactFontManager {
|
||||
public fun addCustomFont (Landroid/content/Context;Ljava/lang/String;I)V
|
||||
public fun addCustomFont (Ljava/lang/String;Landroid/graphics/Typeface;)V
|
||||
public static fun getInstance ()Lcom/facebook/react/views/text/ReactFontManager;
|
||||
public fun getTypeface (Ljava/lang/String;IILandroid/content/res/AssetManager;)Landroid/graphics/Typeface;
|
||||
public fun getTypeface (Ljava/lang/String;ILandroid/content/res/AssetManager;)Landroid/graphics/Typeface;
|
||||
public fun getTypeface (Ljava/lang/String;IZLandroid/content/res/AssetManager;)Landroid/graphics/Typeface;
|
||||
public fun setTypeface (Ljava/lang/String;ILandroid/graphics/Typeface;)V
|
||||
public final class com/facebook/react/views/text/ReactFontManager {
|
||||
public static final field Companion Lcom/facebook/react/views/text/ReactFontManager$Companion;
|
||||
public synthetic fun <init> (Lcom/facebook/react/views/text/ReactFontManager;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun addCustomFont (Landroid/content/Context;Ljava/lang/String;I)V
|
||||
public final fun addCustomFont (Ljava/lang/String;Landroid/graphics/Typeface;)V
|
||||
public static final fun getInstance ()Lcom/facebook/react/views/text/ReactFontManager;
|
||||
public final fun getTypeface (Ljava/lang/String;IILandroid/content/res/AssetManager;)Landroid/graphics/Typeface;
|
||||
public final fun getTypeface (Ljava/lang/String;ILandroid/content/res/AssetManager;)Landroid/graphics/Typeface;
|
||||
public final fun getTypeface (Ljava/lang/String;IZLandroid/content/res/AssetManager;)Landroid/graphics/Typeface;
|
||||
public final fun setTypeface (Ljava/lang/String;ILandroid/graphics/Typeface;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/views/text/ReactFontManager$Companion {
|
||||
public final fun getInstance ()Lcom/facebook/react/views/text/ReactFontManager;
|
||||
}
|
||||
|
||||
public class com/facebook/react/views/text/ReactRawTextManager : com/facebook/react/uimanager/ViewManager {
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.views.text;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Typeface;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
|
||||
/**
|
||||
* Responsible for loading and caching Typeface objects.
|
||||
*
|
||||
* @deprecated This class is deprecated and it will be deleted in the near future. Please use {@link
|
||||
* com.facebook.react.common.assets.ReactFontManager} instead.
|
||||
*/
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
@Deprecated
|
||||
public class ReactFontManager {
|
||||
|
||||
private static ReactFontManager sReactFontManagerInstance;
|
||||
private final com.facebook.react.common.assets.ReactFontManager mDelegate;
|
||||
|
||||
private ReactFontManager(com.facebook.react.common.assets.ReactFontManager delegate) {
|
||||
mDelegate = delegate;
|
||||
}
|
||||
|
||||
public static ReactFontManager getInstance() {
|
||||
if (sReactFontManagerInstance == null) {
|
||||
sReactFontManagerInstance =
|
||||
new ReactFontManager(com.facebook.react.common.assets.ReactFontManager.getInstance());
|
||||
}
|
||||
return sReactFontManagerInstance;
|
||||
}
|
||||
|
||||
public Typeface getTypeface(String fontFamilyName, int style, AssetManager assetManager) {
|
||||
return mDelegate.getTypeface(fontFamilyName, style, assetManager);
|
||||
}
|
||||
|
||||
public Typeface getTypeface(
|
||||
String fontFamilyName, int weight, boolean italic, AssetManager assetManager) {
|
||||
return mDelegate.getTypeface(fontFamilyName, weight, italic, assetManager);
|
||||
}
|
||||
|
||||
public Typeface getTypeface(
|
||||
String fontFamilyName, int style, int weight, AssetManager assetManager) {
|
||||
return mDelegate.getTypeface(fontFamilyName, style, weight, assetManager);
|
||||
}
|
||||
|
||||
public void addCustomFont(Context context, String fontFamily, int fontId) {
|
||||
mDelegate.addCustomFont(context, fontFamily, fontId);
|
||||
}
|
||||
|
||||
public void addCustomFont(String fontFamily, @Nullable Typeface font) {
|
||||
mDelegate.addCustomFont(fontFamily, font);
|
||||
}
|
||||
|
||||
public void setTypeface(String fontFamilyName, int style, Typeface typeface) {
|
||||
mDelegate.setTypeface(fontFamilyName, style, typeface);
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.views.text
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.AssetManager
|
||||
import android.graphics.Typeface
|
||||
|
||||
/** Responsible for loading and caching Typeface objects. */
|
||||
@Deprecated(
|
||||
message =
|
||||
"This class is deprecated and will be deleted in the near future. Please use [com.facebook.react.common.assets.ReactFontManager] instead.")
|
||||
@Suppress("DEPRECATION")
|
||||
public class ReactFontManager private constructor(private val delegate: ReactFontManager) {
|
||||
|
||||
public fun getTypeface(fontFamilyName: String, style: Int, assetManager: AssetManager): Typeface =
|
||||
delegate.getTypeface(fontFamilyName, style, assetManager)
|
||||
|
||||
public fun getTypeface(
|
||||
fontFamilyName: String,
|
||||
weight: Int,
|
||||
italic: Boolean,
|
||||
assetManager: AssetManager
|
||||
): Typeface = delegate.getTypeface(fontFamilyName, weight, italic, assetManager)
|
||||
|
||||
public fun getTypeface(
|
||||
fontFamilyName: String,
|
||||
style: Int,
|
||||
weight: Int,
|
||||
assetManager: AssetManager
|
||||
): Typeface = delegate.getTypeface(fontFamilyName, style, weight, assetManager)
|
||||
|
||||
public fun addCustomFont(context: Context, fontFamily: String, fontId: Int) {
|
||||
delegate.addCustomFont(context, fontFamily, fontId)
|
||||
}
|
||||
|
||||
public fun addCustomFont(fontFamily: String, font: Typeface?) {
|
||||
delegate.addCustomFont(fontFamily, font)
|
||||
}
|
||||
|
||||
public fun setTypeface(fontFamilyName: String, style: Int, typeface: Typeface) {
|
||||
delegate.setTypeface(fontFamilyName, style, typeface)
|
||||
}
|
||||
|
||||
public companion object {
|
||||
private var instance: ReactFontManager? = null
|
||||
|
||||
@JvmStatic
|
||||
public fun getInstance(): ReactFontManager {
|
||||
return instance ?: ReactFontManager(ReactFontManager.getInstance()).also { instance = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user