Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -222,6 +227,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

@Override
protected void onDraw(Canvas canvas) {
initPaints();
drawUnderline(canvas);
drawText(canvas);
}
Expand Down Expand Up @@ -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();
Expand Down