Skip to content

Commit

Permalink
Reverting ISS/react-native PR #114011 (facebook#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
ontzic authored and acoates-ms committed Sep 23, 2019
1 parent 690168f commit a83a60b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 56 deletions.
5 changes: 0 additions & 5 deletions Libraries/Text/TextStylePropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ const TextStylePropTypes = {

color: DeprecatedColorPropType,
fontFamily: ReactPropTypes.string,
/**
* Specifies the fully qualified path of the font file.
* @platform android
*/
fontPath: ReactPropTypes.string, // TODO(android ISS)
fontSize: ReactPropTypes.number,
fontStyle: ReactPropTypes.oneOf(['normal', 'italic']),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public class ViewProps {
public static final String FONT_WEIGHT = "fontWeight";
public static final String FONT_STYLE = "fontStyle";
public static final String FONT_FAMILY = "fontFamily";
public static final String FONT_PATH = "fontPath";
public static final String LINE_HEIGHT = "lineHeight";
public static final String LETTER_SPACING = "letterSpacing";
public static final String NEEDS_OFFSCREEN_ALPHA_COMPOSITING = "needsOffscreenAlphaCompositing";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
Expand Down Expand Up @@ -36,20 +35,6 @@ public class CustomStyleSpan extends MetricAffectingSpan implements ReactSpan {
private final int mStyle;
private final int mWeight;
private final @Nullable String mFontFamily;
private final @Nullable String mFontPath;

public CustomStyleSpan(
int fontStyle,
int fontWeight,
@Nullable String fontFamily,
@Nullable String fontPath,
AssetManager assetManager) {
mStyle = fontStyle;
mWeight = fontWeight;
mFontFamily = fontFamily;
mFontPath = fontPath;
mAssetManager = assetManager;
}

public CustomStyleSpan(
int fontStyle,
Expand All @@ -59,18 +44,17 @@ public CustomStyleSpan(
mStyle = fontStyle;
mWeight = fontWeight;
mFontFamily = fontFamily;
mFontPath = null;
mAssetManager = assetManager;
}

@Override
public void updateDrawState(TextPaint ds) {
apply(ds, mStyle, mWeight, mFontFamily, mFontPath, mAssetManager);
apply(ds, mStyle, mWeight, mFontFamily, mAssetManager);
}

@Override
public void updateMeasureState(@NonNull TextPaint paint) {
apply(paint, mStyle, mWeight, mFontFamily, mFontPath, mAssetManager);
apply(paint, mStyle, mWeight, mFontFamily, mAssetManager);
}

/**
Expand All @@ -94,19 +78,11 @@ public int getWeight() {
return mFontFamily;
}

/**
* Returns the font path set for this StyleSpan.
*/
public @Nullable String getFontPath() {
return mFontPath;
}

private static void apply(
Paint paint,
int style,
int weight,
@Nullable String family,
@Nullable String path,
AssetManager assetManager) {
int oldStyle;
Typeface typeface = paint.getTypeface();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ private static void buildSpannedFromShadowNode(
}
if (textShadowNode.mFontStyle != UNSET
|| textShadowNode.mFontWeight != UNSET
|| textShadowNode.mFontFamily != null
|| (textShadowNode.mFontPath != null && textShadowNode.mFontFamily != null)) {
|| textShadowNode.mFontFamily != null) {
ops.add(
new SetSpanOperation(
start,
Expand All @@ -189,7 +188,6 @@ private static void buildSpannedFromShadowNode(
textShadowNode.mFontStyle,
textShadowNode.mFontWeight,
textShadowNode.mFontFamily,
textShadowNode.mFontPath,
textShadowNode.getThemedContext().getAssets())));
}
if (textShadowNode.mIsUnderlineTextDecorationSet) {
Expand Down Expand Up @@ -363,7 +361,6 @@ private static int parseNumericFontWeight(String fontWeightString) {
* <Text style={{fontFamily="serif}}>Bold Text</Text>
*/
protected @Nullable String mFontFamily = null;
protected @Nullable String mFontPath = null;

protected boolean mContainsImages = false;
protected Map<Integer, ReactShadowNode> mInlineViews;
Expand Down Expand Up @@ -483,12 +480,6 @@ public void setFontFamily(@Nullable String fontFamily) {
markUpdated();
}

@ReactProp(name = ViewProps.FONT_PATH)
public void setFontPath(@Nullable String fontPath) {
mFontPath = fontPath;
markUpdated();
}

/**
/* This code is duplicated in ReactTextInputManager
/* TODO: Factor into a common place they can both use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,6 @@ public void setTypeface(String fontFamilyName, int style, Typeface typeface) {
return Typeface.create(fontFamilyName, style);
}

private static
@Nullable Typeface createTypeface(
String fontPath,
String fontFamilyName,
int style) {
try {
return Typeface.createFromFile(fontPath);
} catch (RuntimeException e) {
// unfortunately Typeface.createFromFile throws an exception instead of returning null
// if the typeface doesn't exist
}
return Typeface.create(fontFamilyName, style);
}

private static class FontFamily {

private SparseArray<Typeface> mTypefaceSparseArray;
Expand Down

0 comments on commit a83a60b

Please sign in to comment.