44import android .app .AlertDialog ;
55import android .content .Context ;
66import android .graphics .Color ;
7+ import android .graphics .Typeface ;
78import android .text .Editable ;
9+ import android .text .InputType ;
810import android .text .Spanned ;
911import android .text .TextUtils ;
1012import android .text .TextWatcher ;
1113import android .text .style .CharacterStyle ;
1214import android .text .style .ForegroundColorSpan ;
1315import android .util .AttributeSet ;
1416import android .util .Log ;
17+ import android .view .inputmethod .EditorInfo ;
1518import android .widget .EditText ;
1619import android .widget .RelativeLayout ;
1720import android .widget .ScrollView ;
@@ -69,6 +72,7 @@ public SyntaxView(Context context,String BackgroundColor,String keywordsColor,St
6972
7073 private void initialize (Context context , String BackgroundColor , final String keywordsColor , final String NumberColor , final String specialCharColors , final String printStatmentsColor ){
7174 // default/constructor color are set here
75+
7276 setKeywordsColor (keywordsColor );
7377 setNumbersColor (NumberColor );
7478 setSpecialCharsColor (specialCharColors );
@@ -77,9 +81,12 @@ private void initialize(Context context, String BackgroundColor, final String ke
7781 inflate (context , R .layout .syntaxview , this );
7882 code = findViewById (R .id .code );
7983 rows = findViewById (R .id .rows );
80- code .setInputType (InputType .TYPE_TEXT_VARIATION_VISIBLE_PASSWORD );
84+ Typeface tf = Typeface .createFromAsset (getContext ().getAssets (), "progfont.ttf" );
85+ code .setTypeface (tf );
86+ code .setInputType (InputType .TYPE_TEXT_VARIATION_VISIBLE_PASSWORD );
8187 code .setSingleLine (false );
82- code .setImeOptions (EditorInfo .IME_FLAG_NO_ENTER_ACTION ); code .setBackgroundColor (Color .parseColor (BackgroundColor ));
88+ code .setImeOptions (EditorInfo .IME_FLAG_NO_ENTER_ACTION );
89+ code .setBackgroundColor (Color .parseColor (BackgroundColor ));
8390 code .addTextChangedListener (new TextWatcher () {
8491
8592
@@ -271,6 +278,8 @@ public void setRowNumbersBgColor (String color) throws Error{
271278 rows .setBackgroundColor (Color .parseColor (color ));
272279 }
273280
274-
281+ public void setFont (Typeface tf ){
282+ code .setTypeface (tf );
283+ }
275284
276285}
0 commit comments