Skip to content

Commit

Permalink
Unbreak legacy ReactFontManager (#47585)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #47585

We have two classes named ReactFontManager and during the Kotlin migration this got mixed up.

Changelog: [Android][Fixed] Fixed crash in legacy ReactFontManager

Reviewed By: fabriziocucci

Differential Revision: D65877606

fbshipit-source-id: d9dc4f29045ad377adb216216334af5501c5546e
  • Loading branch information
javache authored and facebook-github-bot committed Nov 13, 2024
1 parent 3293146 commit 3da23f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -7242,7 +7242,7 @@ public abstract class com/facebook/react/views/text/ReactBaseTextShadowNode : co

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 synthetic fun <init> (Lcom/facebook/react/common/assets/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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ package com.facebook.react.views.text
import android.content.Context
import android.content.res.AssetManager
import android.graphics.Typeface
import com.facebook.react.common.assets.ReactFontManager as ReactFontAssetManager

/** 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 class ReactFontManager private constructor(private val delegate: ReactFontAssetManager) {

public fun getTypeface(fontFamilyName: String, style: Int, assetManager: AssetManager): Typeface =
delegate.getTypeface(fontFamilyName, style, assetManager)
Expand Down Expand Up @@ -52,7 +53,8 @@ public class ReactFontManager private constructor(private val delegate: ReactFon

@JvmStatic
public fun getInstance(): ReactFontManager {
return instance ?: ReactFontManager(ReactFontManager.getInstance()).also { instance = it }
return instance
?: ReactFontManager(ReactFontAssetManager.getInstance()).also { instance = it }
}
}
}

0 comments on commit 3da23f7

Please sign in to comment.