OldSchool Library
|
Text functions in OSLib. More...
Data Structures | |
struct | OSL_FONT |
Loaded font structure. More... | |
struct | OSL_FONTINFO |
Font information type. More... | |
struct | OSL_FONT_FORMAT_HEADER |
Header of a .oft file (Oslib FonT). More... | |
Macros | |
#define | oslSetFont(f) |
Sets the current font. | |
#define | OSL_FONT_OFT 1 |
Font type for OFT. | |
#define | OSL_FONT_INTRA 2 |
Font type for INTRA. | |
#define | OSL_TEXT_CHARPOSXY(f, i) |
Returns the position of a character 'i' in the font 'f' texture as a pair (x, y). | |
#define | oslDrawStringf(x, y, ...) |
Draws a formatted string literal at the specified position. | |
Functions | |
void | oslInitConsole () |
Initializes the console. | |
OSL_FONT * | oslLoadFontFile (const char *filename) |
Loads a font from a file. | |
OSL_FONT * | oslLoadFont (OSL_FONTINFO *fi) |
Loads a font from a OSL_FONTINFO file (located in RAM). | |
void | oslDrawChar (int x, int y, unsigned char c) |
Draws a character at the specified position. | |
void | oslDrawString (int x, int y, const char *str) |
Draws a string literal at the specified position. | |
void | oslDrawStringLimited (int x, int y, int width, const char *str) |
Draws a string literal at the specified position, limited to a given width. | |
void | oslConsolePrint (const char *str) |
Outputs a text to the console at the current cursor position. | |
void | oslSetTextColor (OSL_COLOR color) |
Sets the current text color. | |
void | oslSetBkColor (OSL_COLOR color) |
Sets the text background color. | |
void | oslDrawTextBox (int x0, int y0, int x1, int y1, const char *text, int format) |
Draws a text box with automatic line wrapping. | |
void | oslDrawTextBoxByWords (int x0, int y0, int x1, int y1, const char *text, int format) |
Draws a text box with automatic word wrapping. | |
void | oslDeleteFont (OSL_FONT *f) |
Deletes a font. | |
int | oslGetStringWidth (const char *str) |
Returns the width of a string in pixels. | |
int | oslGetTextBoxHeight (int width, int maxHeight, const char *text, int format) |
Returns the height of a text box. | |
int | oslIntraFontInit (unsigned int options) |
Initializes intraFont. | |
OSL_FONT * | oslLoadIntraFontFile (const char *filename, unsigned int options) |
Loads a font from a pgf file (intraFont). | |
void | oslLoadAltIntraFontFile (OSL_FONT *font, const char *filename) |
Loads an alternative intraFont file. | |
void | oslIntraFontSetStyle (OSL_FONT *f, float size, unsigned int color, unsigned int shadowColor, float angle, unsigned int options) |
Sets the style for a pgf font. | |
float | oslIntraFontPrintColumn (OSL_FONT *f, float x, float y, float width, const char *text) |
Draws text along the baseline starting at x, y. | |
void | oslIntraFontShutdown () |
Shuts down intraFont. | |
Variables | |
OSL_FONT * | osl_curFont |
int | osl_consolePosX |
int | osl_consolePosY |
OSL_FONT * | osl_sceFont |
System OSLib font. | |
OSL_FONTINFO | osl_sceFontInfo |
Font to be loaded. | |
Text functions in OSLib.
This module provides various text-related functionalities, including font management, text drawing, and intraFont handling.
#define oslSetFont | ( | f | ) |
Sets the current font.
Sets the current font to the specified font. Use this function instead of directly modifying osl_curFont for forward compatibility.
f | Pointer to the new font to be set as the current font. |
#define OSL_TEXT_CHARPOSXY | ( | f, | |
i ) |
Returns the position of a character 'i' in the font 'f' texture as a pair (x, y).
f | The font structure. |
i | The character index. |
#define oslDrawStringf | ( | x, | |
y, | |||
... ) |
Draws a formatted string literal at the specified position.
This function allows you to format a string and draw it at the specified coordinates (x, y).
x | X position on the screen. |
y | Y position on the screen. |
... | The formatted string to draw. |
|
extern |
Initializes the console.
This function is automatically called by oslInitGfx, so manual initialization of the console is not required.
|
extern |
Loads a font from a file.
Loads a font file (.oft format) from the specified file path.
filename | The path to the .oft font file. |
|
extern |
Loads a font from a OSL_FONTINFO file (located in RAM).
Use this ONLY with OFT fonts (doesn't work with intraFont). It is recommended to use oslLoadFontFile, which is more user-friendly.
fi | A pointer to the OSL_FONTINFO structure in RAM. |
|
extern |
Draws a character at the specified position.
This function draws a single character at the given coordinates (x, y). For drawing multiple characters, use oslDrawString for better performance.
x | X position on the screen. |
y | Y position on the screen. |
c | The character to draw. |
|
extern |
Draws a string literal at the specified position.
This function draws a string at the given coordinates (x, y).
x | X position on the screen. |
y | Y position on the screen. |
str | The string to draw. |
|
extern |
Draws a string literal at the specified position, limited to a given width.
This function draws a string at the given coordinates (x, y) but limits the drawing to a specified width.
x | X position on the screen. |
y | Y position on the screen. |
width | The maximum width for the string. |
str | The string to draw. |
|
extern |
Outputs a text to the console at the current cursor position.
This function prints a string to the console at the current cursor position and moves the cursor. It is intended for debugging purposes.
str | The string to print. |
|
extern |
Sets the current text color.
Sets the color of the text to be drawn. This function does not work with intraFont (use oslIntraFontSetStyle instead).
color | The color to set for the text. |
|
extern |
Sets the text background color.
Sets the background color for the text. Setting a transparent color (e.g., RGBA(0, 0, 0, 0)) will disable the background, resulting in faster text rendering. This function does not work with intraFont (use oslIntraFontSetStyle instead).
color | The background color to set. |
|
extern |
Draws a text box with automatic line wrapping.
Draws text within a rectangle defined by (x0, y0) and (x1, y1). The text will automatically wrap at the end of a line and move to the next line.
x0 | X position of the top-left corner. |
y0 | Y position of the top-left corner. |
x1 | X position of the bottom-right corner. |
y1 | Y position of the bottom-right corner. |
text | The text to be drawn. Can contain characters for line breaks. |
format | Reserved, set to 0. |
|
extern |
Draws a text box with automatic word wrapping.
Similar to oslDrawTextBox, but wraps the text by words instead of characters.
x0 | X position of the top-left corner. |
y0 | Y position of the top-left corner. |
x1 | X position of the bottom-right corner. |
y1 | Y position of the bottom-right corner. |
text | The text to be drawn. Can contain characters for line breaks. |
format | Reserved, set to 0. |
|
extern |
Deletes a font.
Deletes the specified font. Ensure that the font to be deleted is not currently selected (i.e., f != osl_curFont), or the program will crash the next time you attempt to draw a character.
f | The font to be deleted. |
|
extern |
Returns the width of a string in pixels.
Calculates the width of a string using the currently selected font. To center text horizontally or align it at the bottom of the screen, use this function to get the width.
str | The string whose width is to be calculated. |
|
extern |
Returns the height of a text box.
Calculates the height (in pixels) required to draw a text box with the specified width, maxHeight, and format.
width | The width of the text box. |
maxHeight | The maximum height of the text box. |
text | The text to be drawn. |
format | Reserved, set to 0. |
|
extern |
Initializes intraFont.
Must be called before loading any pgf font. The same options will be applied to all intraFonts.
options | INTRAFONT_XXX flags as defined in the code above. |
|
extern |
Loads a font from a pgf file (intraFont).
Use this function to load a pgf font with options different from those passed to oslIntraFontInit.
filename | The path to the pgf font file. |
options | The options for loading the font. |
|
extern |
Loads an alternative intraFont file.
Use this function to load an alternative font file for an existing font.
font | The font structure to update. |
filename | The path to the alternative font file. |
|
extern |
Sets the style for a pgf font.
Applies the specified style to the pgf font. Works only with pgf fonts.
f | The font structure. |
size | The size of the font. |
color | The color of the text. |
shadowColor | The color of the text shadow. |
angle | The rotation angle of the text. |
options | Additional style options. |
|
extern |
Draws text along the baseline starting at x, y.
Draws text along the baseline starting at the specified (x, y) coordinates.
f | A valid OSL_FONT with type OSL_FONT_INTRA. |
x | X position on the screen. |
y | Y position on the screen. |
width | Column width for automatic line breaking (intraFontPrintColumn versions only). |
text | The text to draw (ASCII & extended ASCII, S-JIS, or UTF-8 encoded). |
|
extern |
Shuts down intraFont.
Cleans up and shuts down intraFont, freeing any allocated resources.
|
extern |
Current font.
This pointer holds the currently selected font for text rendering. You can read from it, but use oslSetFont to modify it.
|
extern |
Console horizontal position (in pixels). Use oslMoveTo to move the cursor.
|
extern |
Console vertical position (in pixels).
|
extern |
System OSLib font.
A pointer to the system font used by OSLib.
|
extern |
Font to be loaded.
Holds information about the system font to be loaded.