in litho-rendercore-text/src/main/java/com/facebook/rendercore/text/TextStylesAttributeHelper.java [139:220]
private static void resolveStyleAttrsForTypedArray(TypedArray a, TextStyle textStyle) {
int viewTextAlignment = View.TEXT_ALIGNMENT_GRAVITY;
int gravity = Gravity.NO_GRAVITY;
String fontFamily = null;
for (int i = 0, size = a.getIndexCount(); i < size; i++) {
final int attr = a.getIndex(i);
int textStyleInt = 0;
if (attr == R.styleable.RenderCoreText_android_textColor) {
textStyle.setTextColorStateList(a.getColorStateList(attr));
} else if (attr == R.styleable.RenderCoreText_android_textSize) {
textStyle.textSize = a.getDimensionPixelSize(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_ellipsize) {
final int index = a.getInteger(attr, 0);
if (index > 0) {
textStyle.ellipsize = TRUNCATE_AT[index - 1];
}
} else if (attr == R.styleable.RenderCoreText_android_textAlignment) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
viewTextAlignment = a.getInt(attr, -1);
textStyle.alignment = getTextAlignment(viewTextAlignment, gravity);
}
} else if (attr == R.styleable.RenderCoreText_android_gravity) {
gravity = a.getInt(attr, -1);
textStyle.alignment = getTextAlignment(viewTextAlignment, gravity);
textStyle.verticalGravity = getVerticalGravity(gravity);
} else if (attr == R.styleable.RenderCoreText_android_includeFontPadding) {
textStyle.includeFontPadding = a.getBoolean(attr, false);
} else if (attr == R.styleable.RenderCoreText_android_minLines) {
textStyle.minLines = a.getInteger(attr, -1);
} else if (attr == R.styleable.RenderCoreText_android_maxLines) {
textStyle.maxLines = a.getInteger(attr, -1);
} else if (attr == R.styleable.RenderCoreText_android_singleLine) {
textStyle.isSingleLine = a.getBoolean(attr, false);
} else if (attr == R.styleable.RenderCoreText_android_textColorLink) {
textStyle.linkColor = a.getColor(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_textColorHighlight) {
textStyle.highlightColor = a.getColor(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_textStyle) {
textStyleInt = a.getInteger(attr, 0);
textStyle.textStyle = textStyleInt;
} else if (attr == R.styleable.RenderCoreText_android_lineSpacingExtra) {
textStyle.extraSpacing = a.getDimensionPixelOffset(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_lineSpacingMultiplier) {
textStyle.spacingMultiplier = a.getFloat(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_shadowDx) {
textStyle.shadowDx = a.getFloat(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_shadowDy) {
textStyle.shadowDy = a.getFloat(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_shadowRadius) {
textStyle.shadowRadius = a.getFloat(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_shadowColor) {
textStyle.shadowColor = a.getColor(attr, 0);
} else if (attr == R.styleable.RenderCoreText_android_minEms) {
textStyle.minEms = a.getInteger(attr, DEFAULT_EMS);
} else if (attr == R.styleable.RenderCoreText_android_maxEms) {
textStyle.maxEms = a.getInteger(attr, DEFAULT_EMS);
} else if (attr == R.styleable.RenderCoreText_android_minWidth) {
textStyle.minTextWidth = a.getDimensionPixelSize(attr, DEFAULT_MIN_WIDTH);
} else if (attr == R.styleable.RenderCoreText_android_maxWidth) {
textStyle.maxTextWidth = a.getDimensionPixelSize(attr, DEFAULT_MAX_WIDTH);
} else if (attr == R.styleable.RenderCoreText_android_fontFamily) {
fontFamily = a.getString(attr);
if (fontFamily != null) {
textStyle.typeface = Typeface.create(fontFamily, textStyleInt);
}
} else if (attr == R.styleable.RenderCoreText_android_breakStrategy) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
textStyle.breakStrategy = a.getInt(attr, DEFAULT_BREAK_STRATEGY);
}
} else if (attr == R.styleable.RenderCoreText_android_hyphenationFrequency) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
textStyle.hyphenationFrequency = a.getInt(attr, DEFAULT_HYPHENATION_FREQUENCY);
}
} else if (attr == R.styleable.RenderCoreText_android_justificationMode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
textStyle.justificationMode = a.getInt(attr, DEFAULT_JUSTIFICATION_MODE);
}
}
}
}