diff --git a/editcodeview/src/main/java/com/bigbangbutton/editcodeview/EditCodeView.java b/editcodeview/src/main/java/com/bigbangbutton/editcodeview/EditCodeView.java index bd30008..67cfef2 100644 --- a/editcodeview/src/main/java/com/bigbangbutton/editcodeview/EditCodeView.java +++ b/editcodeview/src/main/java/com/bigbangbutton/editcodeview/EditCodeView.java @@ -62,6 +62,7 @@ public class EditCodeView extends View private boolean codeHiddenMode; private boolean isSelected; private String codeHiddenMask; + private Typeface typeface; private Rect textBounds = new Rect(); private Runnable cursorAnimation = new Runnable() { @@ -180,7 +181,11 @@ private void initPaints() { textPaint = new Paint(); textPaint.setColor(textColor); textPaint.setTextSize(textSize); - textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, fontStyle)); + if(typeface == null) { + textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, fontStyle)); + } else { + textPaint.setTypeface(typeface); + } textPaint.setAntiAlias(true); underlinePaint = new Paint(); @@ -222,6 +227,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { @Override protected void onDraw(Canvas canvas) { + initPaints(); drawUnderline(canvas); drawText(canvas); } @@ -367,6 +373,11 @@ public void setTextColor(@ColorInt int colorId) { invalidate(); } + public void setTypeface(@NonNull Typeface typeface) { + this.typeface = typeface; + invalidate(); + } + public void setUnderlineStrokeWidth(float underlineStrokeWidth) { this.underlineStrokeWidth = underlineStrokeWidth; invalidate();