Skip to content

Commit da56add

Browse files
authored
Update README.md
1 parent 22b0a8b commit da56add

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ allprojects {
2828

2929
Add the dependency:
3030
```groovy
31-
compile 'com.github.softwee:codeview-android:1.2.0'
31+
compile 'com.github.kbiakov:CodeView-android:1.3.0'
3232
```
3333

3434
## Usage
@@ -84,7 +84,7 @@ codeView.setAdapter(myAdapter);
8484
<b>Note:</b> Each <b>CodeView</b> has a adapter and each adapter has options. When calling ```setOptions(...)``` or ```setAdapter(...)``` the current adapter is "flushed" with the current options. If you want to save the state and just update options saving adapter or set adapter saving options you must call ```updateOptions(...)``` or ```updateAdapter(...)``` accordingly.
8585

8686
### Options
87-
Options helps to easily set necessary params, such as code & language, color theme, shortcut params (max lines, note), code line click listener. Some params are unnecessary.
87+
Options helps to easily set necessary params, such as code & language, color theme, font, format, shortcut params (max lines, note) and code line click listener. Some params are unnecessary.
8888

8989
When the view is initialized (options or adapter are set) you can manipulate the options in various ways:
9090
```java
@@ -115,6 +115,28 @@ ColorThemeData customTheme = new ColorThemeData(new SyntaxColors(...), ...);
115115
codeView.getOptions().setTheme(customTheme);
116116
```
117117

118+
### Font
119+
Set font for your code content:
120+
```java
121+
codeView.getOptions().withFont(Font.Consolas);
122+
```
123+
124+
`Font.Consolas` is a font preset (see the list of available below).
125+
To use your own font you can use similar method by providing `Typeface` or font path. Fonts are internally cached.
126+
127+
### Format
128+
Manage the space that code line take. There are 3 types: `Compact`, `ExtraCompact` and `Medium`.
129+
Setup is similar:
130+
```kotlin
131+
// Kotlin
132+
codeView.getOptions().withFont(Font.Compact)
133+
```
134+
```java
135+
// Java
136+
codeView.getOptions().withFont(Format.Default.getCompact());
137+
```
138+
Also you can create custom `Format` by providing params such as `scaleFactor`, `lineHeight`, `borderHeight` (above first line and below last) and `fontSize`.
139+
118140
### Adapter
119141
Sometimes you may want to take code lines under your control, and that's why you need a <b>Adapter</b>.
120142

@@ -187,9 +209,17 @@ C/C++/Objective-C (```"c"```, ```"cc"```, ```"cpp"```, ```"cxx"```, ```"cyc"```,
187209
Didn't found yours? Please, open issue to show your interest & I'll try to add this language in next releases.
188210

189211
## List of available themes
190-
1. Default (simple light theme).
191-
2. Solarized Light.
192-
3. Monokai.
212+
* Default (simple light theme).
213+
* Solarized Light.
214+
* Monokai.
215+
216+
## List of available fonts
217+
* Consolas
218+
* CourierNew
219+
* DejaVuSansMono
220+
* DroidSansMonoSlashed
221+
* Inconsolata
222+
* Monaco
193223

194224
## Contribute
195225
1. You can add your theme (see [ColorTheme](https://github.com/Softwee/codeview-android/blob/master/codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt) class). Try to add some classic color themes or create your own if it looks cool. You can find many of them in different open-source text editors.<br>

0 commit comments

Comments
 (0)