Data Structures | |
struct | OSL_FONT |
struct | OSL_FONTINFO |
struct | OSL_FONT_FORMAT_HEADER |
Defines | |
#define | oslSetFont(f) (osl_curFont = f) |
#define | OSL_FONT_OFT 1 |
#define | OSL_FONT_INTRA 2 |
#define | oslDrawStringf(x, y,...) { char __str[1000]; sprintf(__str , __VA_ARGS__); oslDrawString(x, y, __str); } |
Functions | |
void | oslInitConsole () |
OSL_FONT * | oslLoadFontFile (const char *filename) |
OSL_FONT * | oslLoadFont (OSL_FONTINFO *fi) |
void | oslDrawChar (int x, int y, unsigned char c) |
void | oslDrawString (int x, int y, const char *str) |
void | oslDrawStringLimited (int x, int y, int width, const char *str) |
void | oslConsolePrint (const char *str) |
void | oslSetTextColor (OSL_COLOR color) |
void | oslSetBkColor (OSL_COLOR color) |
void | oslDrawTextBox (int x0, int y0, int x1, int y1, const char *text, int format) |
void | oslDeleteFont (OSL_FONT *f) |
int | oslGetStringWidth (const char *str) |
int | oslGetTextBoxHeight (int width, int maxHeight, const char *text, int format) |
int | oslIntraFontInit (unsigned int options) |
OSL_FONT * | oslLoadIntraFontFile (const char *filename, unsigned int options) |
void | oslIntraFontSetStyle (OSL_FONT *f, float size, unsigned int color, unsigned int shadowColor, unsigned int options) |
float | oslIntraFontPrintColumn (OSL_FONT *f, float x, float y, float width, int autoBreakLine, const char *text) |
void | oslIntraFontShutdown () |
Variables | |
OSL_FONT * | osl_curFont |
int | osl_consolePosX |
int | osl_consolePosY |
OSL_FONT * | osl_sceFont |
#define oslSetFont | ( | f | ) | (osl_curFont = f) |
Sets the current font. For forward compatibilty, please use this function rather than osl_curFont = yourFont.
//Save the current font OSL_FONT *oldFont = osl_curFont; //Temporarily set another font oslSetFont(newFont); oslPrintf("Using the new font.\n"); //Restore the old font oslSetFont(oldFont); oslPrintf("Using the normal font.\n");
#define OSL_FONT_OFT 1 |
Font type OFT
#define OSL_FONT_INTRA 2 |
Font type INTRA
#define oslDrawStringf | ( | x, | |||
y, | |||||
... | ) | { char __str[1000]; sprintf(__str , __VA_ARGS__); oslDrawString(x, y, __str); } |
Draws a formatted string litteral at the specified x and y positions.
oslDrawStringf(0, 0, "Test string %i", 1);
void oslInitConsole | ( | ) |
Initializes the console. You do not need to call this anymore, as it's automatically done upon oslInitGfx.
OSL_FONT* oslLoadFontFile | ( | const char * | filename | ) |
Loads a font from a file. Remember that you can load virtual files located in RAM, see the VirtualFile section for more information. Also, there is an application (font2osl) which converts fonts to the OldSchool Library Font format (.oft).
OSL_FONT *f = oslLoadFontFile("verdana.oft"); oslSetFont(f); oslDrawString(0, 0, "Hello world using verdana!");
OSL_FONT* oslLoadFont | ( | OSL_FONTINFO * | fi | ) |
Loads a font from a OSL_FONTINFO file (located in RAM). Rather use oslLoadFontFile, which is more friendly. Use this ONLY with OFT fonts (doesen't work with intraFont).
void oslDrawChar | ( | int | x, | |
int | y, | |||
unsigned char | c | |||
) |
Draws a single character at the specified x and y positions. If you must draw several characters placed one after the other, use oslDrawString, as indiviudal oslDrawChar calls will be slightly slower.
void oslDrawString | ( | int | x, | |
int | y, | |||
const char * | str | |||
) |
void oslDrawStringLimited | ( | int | x, | |
int | y, | |||
int | width, | |||
const char * | str | |||
) |
Draws a string litteral at the specified x and y positions limiting it to a given width.
oslDrawStringLimited(0, 0, 200, "Test string");
void oslConsolePrint | ( | const char * | str | ) |
Outputs a text to the console at the current cursor position, and moves it. Here for debugging purposes, not very useful in a game.
void oslSetTextColor | ( | OSL_COLOR | color | ) |
Sets the current text color. This doesen't work with intraFont (use oslIntraFontSetStyle)
void oslSetBkColor | ( | OSL_COLOR | color | ) |
Sets the text background color. Setting a transparent color (e.g. RGBA(0, 0, 0, 0)) will disable drawing a background. In this case, the text rendering will be faster. This doesen't work with intraFont (use oslIntraFontSetStyle)
void oslDrawTextBox | ( | int | x0, | |
int | y0, | |||
int | x1, | |||
int | y1, | |||
const char * | text, | |||
int | format | |||
) |
Draws a text box, that is, text contained in a rectangle. The text will automatically be wrapped at the end of a line and be placed below.
x0,y0 | Top-left corner of the text box. | |
x1,y1 | Bottom-right corner of the text box. | |
text | Text to be drawn. Can contain characters to make a carriage return. | |
format | Let it 0. |
void oslDeleteFont | ( | OSL_FONT * | f | ) |
Deletes a font.
Warning: the font must NOT be currently selected (that is f != osl_curFont) else your program will crash the next time you'll try to draw a character (or later).
int oslGetStringWidth | ( | const char * | str | ) |
Returns the size (in pixels) of a text, using the currently selected font. Note that you can get the height of the text and some other parameters by exploring the OSL_FONT structure. The following sample shows you how to center a text horizontally and align it to the bottom of the screen:
const char *text = "© 2007 Brunni"; int width = oslGetStringWidth(text); oslDrawString((SCREEN_WIDTH - width) / 2, SCREEN_HEIGHT - osl_curFont->charHeight, text);
int oslGetTextBoxHeight | ( | int | width, | |
int | maxHeight, | |||
const char * | text, | |||
int | format | |||
) |
Returns the height (in pixels) which would take a text box drawn with oslDrawTextBox.
int oslIntraFontInit | ( | unsigned int | options | ) |
Inits intraFont (MUST be called before loading any pgf font). The same options will be applied to all intraFonts
options | INTRAFONT_XXX flags as defined above including flags related to CACHE (ored together) |
#define INTRAFONT_ADVANCE_H 0x00000000 //default: advance horizontaly from one char to the next #define INTRAFONT_ADVANCE_V 0x00000100 #define INTRAFONT_ALIGN_LEFT 0x00000000 //default: left-align the text #define INTRAFONT_ALIGN_CENTER 0x00000200 #define INTRAFONT_ALIGN_RIGHT 0x00000400 #define INTRAFONT_WIDTH_VAR 0x00000000 //default: variable-width #define INTRAFONT_WIDTH_FIX 0x00000800 //set your custom fixed witdh to 24 pixels: INTRAFONT_WIDTH_FIX | 24 //(max is 255, set to 0 to use default fixed width, this width will be scaled by size) #define INTRAFONT_ACTIVE 0x00001000 //assumes the font-texture resides inside sceGuTex already, prevents unecessary reloading -> very small speed-gain #define INTRAFONT_STRING_ASCII 0x00000000 //default: interpret strings as ascii text #define INTRAFONT_STRING_SJIS 0x00002000 //interpret strings as shifted-jis (japanese) #define INTRAFONT_STRING_UTF8 0x00010000 //interpret strings as UTF-8 #define INTRAFONT_CACHE_MED 0x00000000 //default: 256x256 texture (enough to cache about 100 chars) #define INTRAFONT_CACHE_LARGE 0x00004000 //512x512 texture(enough to cache all chars of ltn0.pgf or ... or ltn15.pgf or kr0.pgf) #define INTRAFONT_CACHE_ASCII 0x00008000 //try to cache all ASCII chars during fontload (uses less memory and is faster to draw text, but slower to load font) //if it fails: (because the cache is too small) it will automatically switch to chache on-the-fly with a medium texture //if it succeeds: (all chars and shadows fit into chache) it will free some now unneeded memory #define INTRAFONT_CACHE_ALL 0x0000C000 //try to cache all chars during fontload (uses less memory and is faster to draw text, but slower to load font) //if it fails: (because the cache is too small) it will automatically switch to chache on-the-fly with a large texture //if it succeeds: (all chars and shadows fit into chache) it will free some now unneeded memory
OSL_FONT* oslLoadIntraFontFile | ( | const char * | filename, | |
unsigned int | options | |||
) |
Loads a font from a pgf file (intraFont). Use this if you want to load a pgf font with options different from the one passed to oslIntraFontInit.
OSL_FONT *f = oslLoadIntraFontFile("verdana.pgf", INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8); oslSetFont(f); oslDrawString(0, 0, "Hello world using verdana!");
void oslIntraFontSetStyle | ( | OSL_FONT * | f, | |
float | size, | |||
unsigned int | color, | |||
unsigned int | shadowColor, | |||
unsigned int | options | |||
) |
Sets style for a pgf font (works ONLY with pgf font)
float oslIntraFontPrintColumn | ( | OSL_FONT * | f, | |
float | x, | |||
float | y, | |||
float | width, | |||
int | autoBreakLine, | |||
const char * | text | |||
) |
Draw text along the baseline starting at x, y.
font | - A valid intraFont | |
x | - X position on screen | |
y | - Y position on screen | |
width | - column width for automatic line breaking (intraFontPrintColumn... versions only) | |
text | - Text to draw (ASCII & extended ASCII, S-JIS or UTF-8 encoded) | |
length | - char length of text to draw (...Ex versions only) |
void oslIntraFontShutdown | ( | ) |
Shuts down intraFont
Current font. You can read from it but please do not write to it, use oslSetFont instead.
int osl_consolePosX |
Console horizontal position (in pixels). Use oslMoveTo to move the cursor.
int osl_consolePosY |
Console vertical position (in pixels).
System OSLib font.