forked from MightyPirates/TIS-3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFontRendererAPI.java
65 lines (59 loc) · 1.91 KB
/
FontRendererAPI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package li.cil.tis3d.api;
/**
* API entry point for access to the tiny font renderer used on execution
* modules, for example.
* <p>
* Keep in mind that the list of printable characters is very small for this
* font renderer, due to the small number of characters in the font sheet.
*/
public final class FontRendererAPI {
/**
* Render the specified string.
*
* @param string the string to render.
*/
public static void drawString(final String string) {
if (API.fontRendererAPI != null) {
API.fontRendererAPI.drawString(string);
}
}
/**
* Render up to the specified amount of characters of the specified string.
* <p>
* This is intended as a convenience method for clamped-width rendering,
* avoiding additional string operations such as <tt>substring</tt>.
*
* @param string the string to render.
* @param maxChars the maximum number of characters to render.
*/
public static void drawString(final String string, final int maxChars) {
if (API.fontRendererAPI != null) {
API.fontRendererAPI.drawString(string, maxChars);
}
}
/**
* Get the width of the characters drawn with the font renderer, in pixels.
*
* @return the width of the drawn characters.
*/
public static int getCharWidth() {
if (API.fontRendererAPI != null) {
return API.fontRendererAPI.getCharWidth();
}
return 0;
}
/**
* Get the height of the characters drawn with the font renderer, in pixels.
*
* @return the height of the drawn characters.
*/
public static int getCharHeight() {
if (API.fontRendererAPI != null) {
return API.fontRendererAPI.getCharHeight();
}
return 0;
}
// --------------------------------------------------------------------- //
private FontRendererAPI() {
}
}