{"record":{"id":"ae1e7cfa61e7ef2c","repo":"JakeWharton/butterknife","slug":"bindfont-field-type-must-be-typeface","errorCode":null,"errorMessage":"@BindFont field type must be 'Typeface'. (","messagePattern":"@BindFont field type must be 'Typeface'\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":601,"sourceCode":"      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\n  private static @Nullable Unbinder parseBindInt(Object target, Field field, View source) {\n    BindInt bindInt = field.getAnnotation(BindInt.class);\n    if (bindInt == null) {\n      return null;\n    }\n    validateMember(field);\n\n    int id = bindInt.value();","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L583-L619","documentation":"Thrown by the reflection-based ButterKnife runtime when a field annotated with @BindFont is not declared as android.graphics.Typeface. The binder can only produce a Typeface from the font resource; any other declared type (String, int, a custom font wrapper) fails the exact field.getType() == Typeface.class check.","triggerScenarios":"ButterKnife.bind(...) via butterknife-reflect on a class with `@BindFont(R.font.montserrat) String fontName;` or `@BindFont(R.font.montserrat) int fontResId;` — any field whose type is not exactly Typeface.","commonSituations":"Annotating a resource-id int field or a custom font-wrapper field instead of the Typeface field that is actually applied to views; mixing up @BindFont with a font-name String convention used elsewhere in the project. The compiler path reports this at compile time; reflect defers it to runtime.","solutions":["Declare the field as `Typeface` and apply it with view.setTypeface(...) afterwards.","If a custom wrapper is needed, bind the Typeface field and construct the wrapper after bind.","Move to butterknife-compiler for compile-time checking."],"exampleFix":"// before\n@BindFont(R.font.titles) String titleFont;\n\n// after\n@BindFont(R.font.titles) Typeface titleFont;\n// then: textView.setTypeface(titleFont);","handlingStrategy":"type-guard","validationCode":"for (Field f : targetClass.getDeclaredFields()) {\n  if (f.isAnnotationPresent(BindFont.class) && f.getType() != Typeface.class) {\n    throw new IllegalStateException(f + \" must be Typeface\");\n  }\n}","typeGuard":"static boolean isValidBindFontField(Field f) {\n  return !f.isAnnotationPresent(BindFont.class)\n      || f.getType() == Typeface.class;\n}","tryCatchPattern":null,"preventionTips":["Declare @BindFont fields as android.graphics.Typeface.","Apply with textView.setTypeface(field) — never bind String or resource-id ints.","Use butterknife-compiler for compile-time checks."],"tags":["butterknife","reflection","annotation","field-type","bindfont"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}