public static void setTextAppearance(
      TextLayoutBuilder builder, Context context, @StyleRes int resId) {
    TypedArray customAttrs = context.obtainStyledAttributes(resId, R.styleable.TextAppearance);

    ColorStateList textColor =
        customAttrs.getColorStateList(R.styleable.TextAppearance_android_textColor);

    int textSize =
        customAttrs.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);

    int shadowColor =
        customAttrs.getInt(R.styleable.TextAppearance_android_shadowColor, Color.TRANSPARENT);

    if (shadowColor != Color.TRANSPARENT) {
      float dx = customAttrs.getFloat(R.styleable.TextAppearance_android_shadowDx, 0.0f);

      float dy = customAttrs.getFloat(R.styleable.TextAppearance_android_shadowDy, 0.0f);

      float radius = customAttrs.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0.0f);

      builder.setShadowLayer(radius, dx, dy, shadowColor);
    }

    int textStyle = customAttrs.getInt(R.styleable.TextAppearance_android_textStyle, -1);

    customAttrs.recycle();

    // Override the color only if available.
    if (textColor != null) {
      builder.setTextColor(textColor);
    }

    if (textSize != 0) {
      builder.setTextSize(textSize);
    }

    // Override the style only if available.
    if (textStyle != -1) {
      builder.setTypeface(Typeface.defaultFromStyle(textStyle));
    }
  }
Sets a text appearance for the layout.

@param builder The {@link TextLayoutBuilder} instance
@param context The {@link Context} to use for resolving attributes
@param resId The resource identifier of the text appearance
library/src/main/java/com/facebook/fbui/textlayoutbuilder/ResourceTextLayoutHelper.java