-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxtext.h
66 lines (47 loc) · 1.59 KB
/
xtext.h
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
66
/**
* This file belongs to the 'xlab' game engine.
* Copyright 2009 xfacter
* Copyright 2016 wickles
* This work is licensed under the LGPLv3
* subject to all terms as reproduced in the included LICENSE file.
*/
#pragma once
#include "xconfig.h"
#include "xtexture.h"
#ifdef __cplusplus
extern "C" {
#endif
#define X_ALIGN_LEFT (0)
#define X_ALIGN_CENTER (1)
#define X_ALIGN_RIGHT (2)
/* things to add
scale is independent of texture size - rather it is the pixel size of the characters
constant char width (another var in xBitmapFont)
wordwrap - shouldn't be too hard with length functions
xTextPrintSize( ... , float xsize, float ysize, ... )
?
*/
typedef struct xBitmapFont {
xTexture* texture;
u16 widths[256];
} xBitmapFont;
/* texture should be pow2 aligned and contain left-justified characters */
/* width file should contain 16bit unsigned character widths */
/* http://www.lmnopc.com/bitmapfontbuilder/ */
xBitmapFont* xTextLoadFont(xTexture* tex, char* widths_filename);
void xTextFreeFont(xBitmapFont* font);
void xTextSetFont(xBitmapFont* font);
void xTextSetColor(u32 color);
void xTextSetScale(float scale);
void xTextSetAlign(int align);
int xTextLength(char* text, int num);
int xTextNumWithLength(char* src, int length);
int xTextPrint(int x, int y, char* text);
int xTextPrintf(int x, int y, char* text, ... );
/* unimplemented/unworking
float xText3DPrint(ScePspFVector3* pos, float char_scale, float height, char* text, int num);
float xText3DPrintf(ScePspFVector3* pos, float char_scale, float height, char* text, ... );
*/
#ifdef __cplusplus
}
#endif