Skip to content

Commit

Permalink
Extract a shared FontConstants.UNSET constant
Browse files Browse the repository at this point in the history
  • Loading branch information
cubuspl42 committed Nov 1, 2023
1 parent 4f59241 commit 967c56b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.common.assets;

import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
Expand Down Expand Up @@ -167,7 +169,6 @@ public static class TypefaceStyle {

public static final int BOLD = 700;
public static final int NORMAL = 400;
public static final int UNSET = -1;

private static final int MIN_WEIGHT = 1;
private static final int MAX_WEIGHT = 1000;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.facebook.react.internal.fonts

object FontConstants {
/**
* A special value indicating that a font-related property is not set
*/
const val UNSET: Int = -1
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package com.facebook.react.internal.views.text

import com.facebook.react.common.assets.ReactFontManager
import com.facebook.react.internal.fonts.FontConstants
import com.facebook.react.views.text.TextTransform

/**
* Interface for an entity providing effective text attributes of a text node/fragment
*/
interface EffectiveTextAttributeProvider : BasicTextAttributeProvider {
companion object {
const val UNSET = ReactFontManager.TypefaceStyle.UNSET
}

val textTransform: TextTransform

val effectiveLetterSpacing: Float

/**
* @return The effective font size, or [UNSET] if not set
* @return The effective font size, or [FontConstants.UNSET] if not set
*/
val effectiveFontSize: Int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import android.content.Context
import android.graphics.Color
import android.text.*
import android.view.View
import com.facebook.react.common.assets.ReactFontManager
import com.facebook.react.internal.fonts.FontConstants.UNSET
import com.facebook.react.uimanager.PixelUtil
import com.facebook.react.uimanager.ReactAccessibilityDelegate
import com.facebook.react.internal.views.text.fragments.TextFragmentList
Expand All @@ -22,7 +22,6 @@ import com.facebook.react.views.text.*
*/
object TextLayoutUtils {
private const val INLINE_VIEW_PLACEHOLDER = "0"
private const val UNSET = ReactFontManager.TypefaceStyle.UNSET

fun buildSpannableFromTextFragmentList(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.views.text;

import static com.facebook.react.internal.fonts.FontConstants.UNSET;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
Expand Down Expand Up @@ -59,7 +61,6 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode implement
// character.
// https://en.wikipedia.org/wiki/Bi-directional_text#weak_characters
private static final String INLINE_VIEW_PLACEHOLDER = "0";
public static final int UNSET = ReactFontManager.TypefaceStyle.UNSET;

public static final String PROP_SHADOW_OFFSET = "textShadowOffset";
public static final String PROP_SHADOW_OFFSET_WIDTH = "width";
Expand Down

0 comments on commit 967c56b

Please sign in to comment.