{"record":{"id":"4645dfee6d007d3f","repo":"JakeWharton/butterknife","slug":"bindfont-style-must-be-normal-bold-italic-or-b","errorCode":null,"errorMessage":"@BindFont style must be NORMAL, BOLD, ITALIC, or BOLD_ITALIC. (","messagePattern":"@BindFont style must be NORMAL, BOLD, ITALIC, or BOLD_ITALIC\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":593,"sourceCode":"    int id = bindFont.value();\n    int style = bindFont.style();\n    Context context = source.getContext();\n\n    Class<?> fieldType = field.getType();\n    Object value;\n    if (fieldType == Typeface.class) {\n      Typeface font = ResourcesCompat.getFont(context, id);\n      switch (style) {\n        case Typeface.NORMAL:\n          value = font;\n          break;\n        case Typeface.BOLD:\n        case Typeface.ITALIC:\n        case Typeface.BOLD_ITALIC:\n          value = Typeface.create(font, style);\n          break;\n        default:\n          throw new IllegalStateException(\n              \"@BindFont style must be NORMAL, BOLD, ITALIC, or BOLD_ITALIC. (\"\n                  + field.getDeclaringClass().getName()\n                  + '.'\n                  + field.getName()\n                  + ')');\n      }\n    } else {\n      throw new IllegalStateException(\"@BindFont field type must be 'Typeface'. (\"\n          + field.getDeclaringClass().getName()\n          + '.'\n          + field.getName()\n          + ')');\n    }\n    trySet(field, target, value);\n\n    return Unbinder.EMPTY;\n  }\n","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L575-L611","documentation":"Thrown by the reflection-based ButterKnife runtime when the style attribute of @BindFont is not one of Typeface.NORMAL, Typeface.BOLD, Typeface.ITALIC, or Typeface.BOLD_ITALIC. After loading the font family, the binder switches on the style constant; an unrecognized value falls into the default branch and aborts binding.","triggerScenarios":"ButterKnife.bind(...) via butterknife-reflect on a field with `@BindFont(value = R.font.x, style = 3)` or any style constant outside {0,1,2,3} — typically a hand-written constant, a typo'd constant, or a style value computed at runtime via a non-final variable.","commonSituations":"Passing Typeface.Style constants from android.R.attr or custom values, or copy-pasting a style int from another API (e.g. Paint typeface flags). The compiler path validates the style is a compile-time constant in range; reflect defers the failure to bind time.","solutions":["Use one of the named constants: Typeface.NORMAL, Typeface.BOLD, Typeface.ITALIC, or Typeface.BOLD_ITALIC in the @BindFont declaration.","If the annotation took a bad constant from another class, replace it with the Typeface constant.","Switch to butterknife-compiler so an out-of-range style fails the build."],"exampleFix":"// before\n@BindFont(value = R.font.sans, style = 7) Typeface font;\n\n// after\n@BindFont(value = R.font.sans, style = Typeface.BOLD_ITALIC) Typeface font;","handlingStrategy":"validation","validationCode":"int style = fontAnnotation.style();\nif (style != Typeface.NORMAL && style != Typeface.BOLD\n    && style != Typeface.ITALIC && style != Typeface.BOLD_ITALIC) {\n  throw new IllegalArgumentException(\"Invalid @BindFont style: \" + style);\n}","typeGuard":"static boolean isValidBindFontStyle(int style) {\n  return style == Typeface.NORMAL || style == Typeface.BOLD\n      || style == Typeface.ITALIC || style == Typeface.BOLD_ITALIC;\n}","tryCatchPattern":null,"preventionTips":["Only reference the four Typeface constants in @BindFont(style = ...).","Never compute style from non-typeface constants or android.R.attr values.","Use butterknife-compiler for build-time validation."],"tags":["butterknife","reflection","annotation","bindfont","typeface","invalid-value"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}