Skip to content

Commit dd718d1

Browse files
committed
Added missed ability to set Typeface font
1 parent 60bfb03 commit dd718d1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,19 @@ data class Options(
366366
withTheme(theme)
367367
}
368368

369-
fun withFont(fontPath: String): Options {
370-
this.font = FontCache.get(context).getTypeface(context, fontPath)
369+
fun withFont(font: Font): Options {
370+
this.font = FontCache.get(context).getTypeface(context, font)
371371
return this
372372
}
373373

374-
fun withFont(font: Font): Options {
375-
this.font = FontCache.get(context).getTypeface(context, font)
374+
fun withFont(font: Typeface): Options {
375+
FontCache.get(context).saveTypeface(font)
376+
this.font = font
377+
return this
378+
}
379+
380+
fun withFont(fontPath: String): Options {
381+
this.font = FontCache.get(context).getTypeface(context, fontPath)
376382
return this
377383
}
378384

Diff for: codeview/src/main/java/io/github/kbiakov/codeview/highlight/FontCache.java

+4
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,8 @@ public Typeface getTypeface(Context context, String fontPath) {
7777
return font;
7878
}
7979
}
80+
81+
public void saveTypeface(Typeface fontTypeface) {
82+
fonts.put(fontTypeface.toString(), fontTypeface);
83+
}
8084
}

0 commit comments

Comments
 (0)