KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
biosfont.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/biosfont.h
4 Copyright (C) 2000-2001 Megan Potter
5 Japanese Functions Copyright (C) 2002 Kazuaki Matsumoto
6 Copyright (C) 2017 Donald Haase
7 Copyright (C) 2024 Falco Girgis
8
9*/
10
11/** \file dc/biosfont.h
12 \brief BIOS font drawing functions.
13 \ingroup bfont
14
15 This file provides support for utilizing the font built into the Dreamcast's
16 BIOS. These functions allow access to both the western character set and
17 Japanese characters.
18
19 \author Megan Potter
20 \author Kazuaki Matsumoto
21 \author Donald Haase
22 \author Falco Girgis
23
24 \todo
25 - More user-friendly way to fetch/print DC-specific icons.
26*/
27
28#ifndef __DC_BIOSFONT_H
29#define __DC_BIOSFONT_H
30
31#include <kos/cdefs.h>
32__BEGIN_DECLS
33
34#include <stdint.h>
35#include <stdbool.h>
36#include <stdarg.h>
37
38#include <arch/types.h>
39
40/** \defgroup bfont BIOS
41 \brief API for the Dreamcast's built-in BIOS font
42 \ingroup video_fonts
43 @{
44*/
45
46/** \defgroup bfont_size Dimensions
47 \brief Sizes for of the BIOS font's dimensions
48 @{
49*/
50#define BFONT_THIN_WIDTH 12 /**< \brief Width of Thin Font (ISO8859_1, half-JP) */
51#define BFONT_WIDE_WIDTH (BFONT_THIN_WIDTH * 2) /**< \brief Width of Wide Font (full-JP) */
52#define BFONT_HEIGHT 24 /**< \brief Height of All Fonts */
53/** @} */
54
55/** \brief Number of bytes to represent a single character within the BIOS font. */
56#define BFONT_BYTES_PER_CHAR (BFONT_THIN_WIDTH * BFONT_HEIGHT / 8)
57
58/** \defgroup bfont_indicies Structure
59 \brief Structure of the Bios Font
60 @{
61*/
62/** \brief Start of Narrow Characters in Font Block */
63#define BFONT_NARROW_START 0
64#define BFONT_OVERBAR BFONT_NARROW_START
65#define BFONT_ISO_8859_1_33_126 (BFONT_NARROW_START + ( 1 * BFONT_BYTES_PER_CHAR))
66#define BFONT_YEN (BFONT_NARROW_START + (95 * BFONT_BYTES_PER_CHAR))
67#define BFONT_ISO_8859_1_160_255 (BFONT_NARROW_START + (96 * BFONT_BYTES_PER_CHAR))
68
69/* JISX-0208 Rows 1-7 and 16-84 are encoded between BFONT_WIDE_START and BFONT_DREAMCAST_SPECIFIC.
70 Only the box-drawing characters (row 8) are missing. */
71/** \brief Size of a row for JISX-0208 characters */
72#define JISX_0208_ROW_SIZE 94
73/** \brief Start of Wide Characters in Font Block */
74#define BFONT_WIDE_START (288 * BFONT_BYTES_PER_CHAR)
75/** \brief Start of JISX-0208 Rows 1-7 in Font Block */
76#define BFONT_JISX_0208_ROW1 BFONT_WIDE_START
77/** \brief Start of JISX-0208 Row 16-47 (Start of Level 1) in Font Block */
78#define BFONT_JISX_0208_ROW16 (BFONT_WIDE_START + (658 * BFONT_BYTES_PER_CHAR))
79/** \brief JISX-0208 Row 48-84 (Start of Level 2) in Font Block */
80#define BFONT_JISX_0208_ROW48 (BFONT_JISX_0208_ROW16 + ((32 * JISX_0208_ROW_SIZE) * BFONT_BYTES_PER_CHAR))
81
82/** \brief Start of DC Specific Characters in Font Block */
83#define BFONT_DREAMCAST_SPECIFIC (BFONT_WIDE_START + (7056 * BFONT_BYTES_PER_CHAR))
84/** \brief Takes a DC-specific icon index and returns a character offset. */
85#define BFONT_DC_ICON(offset) (BFONT_DREAMCAST_SPECIFIC + ((offset) * BFONT_BYTES_PER_CHAR))
86
87/** \defgroup bfont_dc_indices Dreamcast-Specific
88 \brief Dreamcast-specific BIOS icon offsets.
89 @{
90*/
91#define BFONT_CIRCLECOPYRIGHT BFONT_DC_ICON(0) /**< \brief Circle copyright */
92#define BFONT_CIRCLER BFONT_DC_ICON(1) /**< \brief Circle restricted */
93#define BFONT_TRADEMARK BFONT_DC_ICON(2) /**< \brief Trademark */
94#define BFONT_UPARROW BFONT_DC_ICON(3) /**< \brief Up arrow */
95#define BFONT_DOWNARROW BFONT_DC_ICON(4) /**< \brief Down arrow */
96#define BFONT_LEFTARROW BFONT_DC_ICON(5) /**< \brief Left arrow */
97#define BFONT_RIGHTARROW BFONT_DC_ICON(6) /**< \brief Right arrow */
98#define BFONT_UPRIGHTARROW BFONT_DC_ICON(7) /**< \brief Up right arrow */
99#define BFONT_DOWNRIGHTARROW BFONT_DC_ICON(8) /**< \brief Down right arrow */
100#define BFONT_DOWNLEFTARROW BFONT_DC_ICON(9) /**< \brief Down left arrow */
101#define BFONT_UPLEFTARROW BFONT_DC_ICON(10) /**< \brief Up left arrow */
102#define BFONT_ABUTTON BFONT_DC_ICON(11) /**< \brief A button */
103#define BFONT_BBUTTON BFONT_DC_ICON(12) /**< \brief B button */
104#define BFONT_CBUTTON BFONT_DC_ICON(13) /**< \brief C button */
105#define BFONT_DBUTTON BFONT_DC_ICON(14) /**< \brief D button */
106#define BFONT_XBUTTON BFONT_DC_ICON(15) /**< \brief X button */
107#define BFONT_YBUTTON BFONT_DC_ICON(16) /**< \brief Y button */
108#define BFONT_ZBUTTON BFONT_DC_ICON(17) /**< \brief Z button */
109#define BFONT_LTRIGGER BFONT_DC_ICON(18) /**< \brief L trigger */
110#define BFONT_RTRIGGER BFONT_DC_ICON(19) /**< \brief R trigger */
111#define BFONT_STARTBUTTON BFONT_DC_ICON(20) /**< \brief Start button */
112#define BFONT_VMUICON BFONT_DC_ICON(21) /**< \brief VMU icon */
113/** @} */
114
115#define BFONT_ICON_DIMEN 32 /**< \brief Dimension of vmu icons */
116#define BFONT_VMU_DREAMCAST_SPECIFIC (BFONT_DREAMCAST_SPECIFIC+(22 * BFONT_BYTES_PER_CHAR))
117/** @} */
118
119/** \brief Builtin VMU Icons
120 \ingroup bfont_indicies
121
122 Builtin VMU volume user icons. The Dreamcast's
123 BIOS allows the user to set these when formatting the VMU.
124*/
125typedef enum bfont_vmu_icon {
126 BFONT_ICON_INVALID_VMU = 0x00, /**< \brief Invalid */
127 BFONT_ICON_HOURGLASS_ONE = 0x01, /**< \brief Hourglass 1 */
128 BFONT_ICON_HOURGLASS_TWO = 0x02, /**< \brief Hourglass 2 */
129 BFONT_ICON_HOURGLASS_THREE = 0x03, /**< \brief Hourglass 3 */
130 BFONT_ICON_HOURGLASS_FOUR = 0x04, /**< \brief Hourglass 4 */
131 BFONT_ICON_VMUICON = 0x05, /**< \brief VMU */
132 BFONT_ICON_EARTH = 0x06, /**< \brief Earth */
133 BFONT_ICON_SATURN = 0x07, /**< \brief Saturn */
134 BFONT_ICON_QUARTER_MOON = 0x08, /**< \brief Quarter moon */
135 BFONT_ICON_LAUGHING_FACE = 0x09, /**< \brief Laughing face */
136 BFONT_ICON_SMILING_FACE = 0x0A, /**< \brief Smiling face */
137 BFONT_ICON_CASUAL_FACE = 0x0B, /**< \brief Casual face */
138 BFONT_ICON_ANGRY_FACE = 0x0C, /**< \brief Angry face */
139 BFONT_ICON_COW = 0x0D, /**< \brief Cow */
140 BFONT_ICON_HORSE = 0x0E, /**< \brief Horse */
141 BFONT_ICON_RABBIT = 0x0F, /**< \brief Rabbit */
142 BFONT_ICON_CAT = 0x10, /**< \brief Cat */
143 BFONT_ICON_CHICK = 0x11, /**< \brief Chick */
144 BFONT_ICON_LION = 0x12, /**< \brief Lion */
145 BFONT_ICON_MONKEY = 0x13, /**< \brief Monkye */
146 BFONT_ICON_PANDA = 0x14, /**< \brief Panda */
147 BFONT_ICON_BEAR = 0x15, /**< \brief Bear */
148 BFONT_ICON_PIG = 0x16, /**< \brief Pig */
149 BFONT_ICON_DOG = 0x17, /**< \brief Dog */
150 BFONT_ICON_FISH = 0x18, /**< \brief Fish */
151 BFONT_ICON_OCTOPUS = 0x19, /**< \brief Octopus */
152 BFONT_ICON_SQUID = 0x1A, /**< \brief Squid */
153 BFONT_ICON_WHALE = 0x1B, /**< \brief Whale */
154 BFONT_ICON_CRAB = 0x1C, /**< \brief Crab */
155 BFONT_ICON_BUTTERFLY = 0x1D, /**< \brief Butterfly */
156 BFONT_ICON_LADYBUG = 0x1E, /**< \brief Ladybug */
157 BFONT_ICON_ANGLER_FISH = 0x1F, /**< \brief Angler fish */
158 BFONT_ICON_PENGUIN = 0x20, /**< \brief Penguin */
159 BFONT_ICON_CHERRIES = 0x21, /**< \brief Cherries */
160 BFONT_ICON_TULIP = 0x22, /**< \brief Tulip */
161 BFONT_ICON_LEAF = 0x23, /**< \brief Leaf */
162 BFONT_ICON_SAKURA = 0x24, /**< \brief Sakura */
163 BFONT_ICON_APPLE = 0x25, /**< \brief Apple */
164 BFONT_ICON_ICECREAM = 0x26, /**< \brief Ice cream */
165 BFONT_ICON_CACTUS = 0x27, /**< \brief Cactus */
166 BFONT_ICON_PIANO = 0x28, /**< \brief Piano */
167 BFONT_ICON_GUITAR = 0x29, /**< \brief Guitar */
168 BFONT_ICON_EIGHTH_NOTE = 0x2A, /**< \brief Eighth note */
169 BFONT_ICON_TREBLE_CLEF = 0x2B, /**< \brief Treble clef */
170 BFONT_ICON_BOAT = 0x2C, /**< \brief Boat */
171 BFONT_ICON_CAR = 0x2D, /**< \brief Car */
172 BFONT_ICON_HELMET = 0x2E, /**< \brief Helmet */
173 BFONT_ICON_MOTORCYCLE = 0x2F, /**< \brief Motorcycle */
174 BFONT_ICON_VAN = 0x30, /**< \brief Van */
175 BFONT_ICON_TRUCK = 0x31, /**< \brief Truck */
176 BFONT_ICON_CLOCK = 0x32, /**< \brief Clock */
177 BFONT_ICON_TELEPHONE = 0x33, /**< \brief Telephone */
178 BFONT_ICON_PENCIL = 0x34, /**< \brief Pencil */
179 BFONT_ICON_CUP = 0x35, /**< \brief Cup */
180 BFONT_ICON_SILVERWARE = 0x36, /**< \brief Silverware */
181 BFONT_ICON_HOUSE = 0x37, /**< \brief House */
182 BFONT_ICON_BELL = 0x38, /**< \brief Bell */
183 BFONT_ICON_CROWN = 0x39, /**< \brief Crown */
184 BFONT_ICON_SOCK = 0x3A, /**< \brief Sock */
185 BFONT_ICON_CAKE = 0x3B, /**< \brief cake */
186 BFONT_ICON_KEY = 0x3C, /**< \brief Key */
187 BFONT_ICON_BOOK = 0x3D, /**< \brief Book */
188 BFONT_ICON_BASEBALL = 0x3E, /**< \brief Baseball */
189 BFONT_ICON_SOCCER = 0x3F, /**< \brief Soccer */
190 BFONT_ICON_BULB = 0x40, /**< \brief Bulb */
191 BFONT_ICON_TEDDY_BEAR = 0x41, /**< \brief Teddy bear */
192 BFONT_ICON_BOW_TIE = 0x42, /**< \brief Bow tie */
193 BFONT_ICON_BOW_ARROW = 0x43, /**< \brief Bow and arrow */
194 BFONT_ICON_SNOWMAN = 0x44, /**< \brief Snowman */
195 BFONT_ICON_LIGHTNING = 0x45, /**< \brief Lightning */
196 BFONT_ICON_SUN = 0x46, /**< \brief Sun */
197 BFONT_ICON_CLOUD = 0x47, /**< \brief Cloud */
198 BFONT_ICON_UMBRELLA = 0x48, /**< \brief Umbrella */
199 BFONT_ICON_ONE_STAR = 0x49, /**< \brief One star */
200 BFONT_ICON_TWO_STARS = 0x4A, /**< \brief Two stars */
201 BFONT_ICON_THREE_STARS = 0x4B, /**< \brief Three stars */
202 BFONT_ICON_FOUR_STARS = 0x4C, /**< \brief Four stars */
203 BFONT_ICON_HEART = 0x4D, /**< \brief Heart */
204 BFONT_ICON_DIAMOND = 0x4E, /**< \brief Diamond */
205 BFONT_ICON_SPADE = 0x4F, /**< \brief Spade */
206 BFONT_ICON_CLUB = 0x50, /**< \brief Club */
207 BFONT_ICON_JACK = 0x51, /**< \brief Jack */
208 BFONT_ICON_QUEEN = 0x52, /**< \brief Queen */
209 BFONT_ICON_KING = 0x53, /**< \brief King */
210 BFONT_ICON_JOKER = 0x54, /**< \brief Joker */
211 BFONT_ICON_ISLAND = 0x55, /**< \brief Island */
212 BFONT_ICON_0 = 0x56, /**< \brief `0` digit */
213 BFONT_ICON_1 = 0x57, /**< \brief `1` digit */
214 BFONT_ICON_2 = 0x58, /**< \brief `2` digit */
215 BFONT_ICON_3 = 0x59, /**< \brief `3` digit */
216 BFONT_ICON_4 = 0x5A, /**< \brief `4` digit */
217 BFONT_ICON_5 = 0x5B, /**< \brief `5` digit */
218 BFONT_ICON_6 = 0x5C, /**< \brief `6` digit */
219 BFONT_ICON_7 = 0x5D, /**< \brief `7` digit */
220 BFONT_ICON_8 = 0x5E, /**< \brief `8` digit */
221 BFONT_ICON_9 = 0x5F, /**< \brief `9` digit */
222 BFONT_ICON_A = 0x60, /**< \brief `A` letter */
223 BFONT_ICON_B = 0x61, /**< \brief `B` letter */
224 BFONT_ICON_C = 0x62, /**< \brief `C` letter */
225 BFONT_ICON_D = 0x63, /**< \brief `D` letter */
226 BFONT_ICON_E = 0x64, /**< \brief `E` letter */
227 BFONT_ICON_F = 0x65, /**< \brief `F` letter */
228 BFONT_ICON_G = 0x66, /**< \brief `G` letter */
229 BFONT_ICON_H = 0x67, /**< \brief `H` letter */
230 BFONT_ICON_I = 0x68, /**< \brief `I` letter */
231 BFONT_ICON_J = 0x69, /**< \brief `J` letter */
232 BFONT_ICON_K = 0x6A, /**< \brief `K` letter */
233 BFONT_ICON_L = 0x6B, /**< \brief `L` letter */
234 BFONT_ICON_M = 0x6C, /**< \brief `M` letter */
235 BFONT_ICON_N = 0x6D, /**< \brief `N` letter */
236 BFONT_ICON_O = 0x6E, /**< \brief `O` letter */
237 BFONT_ICON_P = 0x6F, /**< \brief `P` letter */
238 BFONT_ICON_Q = 0x70, /**< \brief `Q` letter */
239 BFONT_ICON_R = 0x71, /**< \brief `R` letter */
240 BFONT_ICON_S = 0x72, /**< \brief `S` letter */
241 BFONT_ICON_T = 0x73, /**< \brief `T` letter */
242 BFONT_ICON_U = 0x74, /**< \brief `U` letter */
243 BFONT_ICON_V = 0x75, /**< \brief `V` letter */
244 BFONT_ICON_W = 0x76, /**< \brief `W` letter */
245 BFONT_ICON_X = 0x77, /**< \brief `X` letter */
246 BFONT_ICON_Y = 0x78, /**< \brief `Y` letter */
247 BFONT_ICON_Z = 0x79, /**< \brief `Z` letter */
248 BFONT_ICON_CHECKER_BOARD = 0x7A, /**< \brief Checker board */
249 BFONT_ICON_GRID = 0x7B, /**< \brief Grid */
250 BFONT_ICON_LIGHT_GRAY = 0x7C, /**< \brief Light gray */
251 BFONT_ICON_DIAG_GRID = 0x7D, /**< \brief Diagonal grid */
252 BFONT_ICON_PACMAN_GRID = 0x7E, /**< \brief Pacman grid */
253 BFONT_ICON_DARK_GRAY = 0x7F, /**< \brief Dark gray */
254 BFONT_ICON_EMBROIDERY = 0x80 /**< \brief Embroidery */
256/** @} */
257
258/** \name Coloring
259 \brief Methods for modifying the text color.
260 @{
261*/
262
263/** \brief Set the font foreground color.
264
265 This function selects the foreground color to draw when a pixel is opaque in
266 the font. The value passed in for the color should be in whatever pixel
267 format that you intend to use for the image produced.
268
269 \param c The color to use.
270 \return The old foreground color.
271
272 \sa bfont_set_background_color()
273*/
274uint32_t bfont_set_foreground_color(uint32_t c);
275
276/** \brief Set the font background color.
277
278 This function selects the background color to draw when a pixel is drawn in
279 the font. This color is only used for pixels not covered by the font when
280 you have selected to have the font be opaque.
281
282 \param c The color to use.
283 \return The old background color.
284
285 \sa bfont_set_foreground_color()
286*/
287uint32_t bfont_set_background_color(uint32_t c);
288
289/** \brief Set the font to draw 32-bit color.
290 \deprecated Use the bpp parameter of the bfont_draw_ex() functions.
291
292 This function changes whether the font draws colors as 32-bit or 16-bit. The
293 default is to use 16-bit.
294
295 \param on Set to 0 to use 16-bit color, 32-bit otherwise.
296 \return The old state (1 = 32-bit, 0 = 16-bit).
297*/
299 __depr("Please use the bpp function of the the bfont_draw_ex functions");
300
301/** @} */
302
303/* Constants for the function below */
304typedef enum bfont_code {
305 BFONT_CODE_ISO8859_1 = 0, /**< \brief ISO-8859-1 (western) charset */
306 BFONT_CODE_EUC = 1, /**< \brief EUC-JP charset */
307 BFONT_CODE_SJIS = 2, /**< \brief Shift-JIS charset */
308 BFONT_CODE_RAW = 3 /**< \brief Raw indexing to the BFONT */
310
311/** \brief Set the font encoding.
312
313 This function selects the font encoding that is used for the font. This
314 allows you to select between the various character sets available.
315
316 \param enc The character encoding in use
317*/
319
320/** \name Character Lookups
321 \brief Methods for finding various font characters and icons.
322 @{
323*/
324
325/** \brief Find an ISO-8859-1 character in the font.
326
327 This function retrieves a pointer to the font data for the specified
328 character in the font, if its available. Generally, you will not have to
329 use this function, use one of the bfont_draw_* functions instead.
330
331 \param ch The character to look up
332 \return A pointer to the raw character data
333*/
334uint8_t *bfont_find_char(uint32_t ch);
335
336/** \brief Find an full-width Japanese character in the font.
337
338 This function retrieves a pointer to the font data for the specified
339 character in the font, if its available. Generally, you will not have to
340 use this function, use one of the bfont_draw_* functions instead.
341
342 This function deals with full-width kana and kanji.
343
344 \param ch The character to look up
345 \return A pointer to the raw character data
346*/
347uint8_t *bfont_find_char_jp(uint32_t ch);
348
349/** \brief Find an half-width Japanese character in the font.
350
351 This function retrieves a pointer to the font data for the specified
352 character in the font, if its available. Generally, you will not have to
353 use this function, use one of the bfont_draw_* functions instead.
354
355 This function deals with half-width kana only.
356
357 \param ch The character to look up
358 \return A pointer to the raw character data
359*/
360uint8_t *bfont_find_char_jp_half(uint32_t ch);
361
362/** \brief Find a VMU icon.
363
364 This function retrieves a pointer to the icon data for the specified VMU
365 icon in the bios, if its available. The icon data is flipped both vertically
366 and horizontally. Each vmu icon has dimensions 32x32 pixels and is 128 bytes
367 long.
368
369 \param icon The VMU icon index to look up.
370 \return A pointer to the raw icon data or NULL if icon value
371 is incorrect.
372*/
374
375/** @} */
376
377/** \name Character Drawing
378 \brief Methods for rendering characters.
379 @{
380*/
381
382/** \brief Draw a single character of any sort to the buffer.
383
384 This function draws a single character in the set encoding to the given
385 buffer. This function sits under draw, draw_thin, and draw_wide, while
386 exposing the colors and bitdepths desired. This will allow the writing
387 of bfont characters to paletted textures.
388
389 \param buffer The buffer to draw to.
390 \param bufwidth The width of the buffer in pixels.
391 \param fg The foreground color to use.
392 \param bg The background color to use.
393 \param bpp The number of bits per pixel in the buffer.
394 \param opaque If non-zero, overwrite background areas with black,
395 otherwise do not change them from what they are.
396 \param c The character to draw.
397 \param wide Draw a wide character.
398 \param iskana Draw a half-width kana character.
399 \return Amount of width covered in bytes.
400*/
401size_t bfont_draw_ex(void *buffer, uint32_t bufwidth, uint32_t fg,
402 uint32_t bg, uint8_t bpp, bool opaque, uint32_t c,
403 bool wide, bool iskana);
404
405/** \brief Draw a single character to a buffer.
406
407 This function draws a single character in the set encoding to the given
408 buffer. Calling this is equivalent to calling bfont_draw_thin() with 0 for
409 the final parameter.
410
411 \param buffer The buffer to draw to (at least 12 x 24 pixels)
412 \param bufwidth The width of the buffer in pixels
413 \param opaque If non-zero, overwrite blank areas with black,
414 otherwise do not change them from what they are
415 \param c The character to draw
416 \return Amount of width covered in bytes.
417*/
418size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c);
419
420/** \brief Draw a single thin character to a buffer.
421
422 This function draws a single character in the set encoding to the given
423 buffer. This only works with ISO-8859-1 characters and half-width kana.
424
425 \param buffer The buffer to draw to (at least 12 x 24 pixels)
426 \param bufwidth The width of the buffer in pixels
427 \param opaque If non-zero, overwrite blank areas with black,
428 otherwise do not change them from what they are
429 \param c The character to draw
430 \param iskana Set to 1 if the character is a kana, 0 if ISO-8859-1
431 \return Amount of width covered in bytes.
432*/
433size_t bfont_draw_thin(void *buffer, uint32_t bufwidth, bool opaque,
434 uint32_t c, bool iskana);
435
436/** \brief Draw a single wide character to a buffer.
437
438 This function draws a single character in the set encoding to the given
439 buffer. This only works with full-width kana and kanji.
440
441 \param buffer The buffer to draw to (at least 24 x 24 pixels)
442 \param bufwidth The width of the buffer in pixels
443 \param opaque If non-zero, overwrite blank areas with black,
444 otherwise do not change them from what they are
445 \param c The character to draw
446 \return Amount of width covered in bytes.
447*/
448size_t bfont_draw_wide(void *buffer, uint32_t bufwidth, bool opaque,
449 uint32_t c);
450
451/** @} */
452
453/** \name String Drawing
454 \brief Methods for rendering formatted text.
455
456 @{
457*/
458
459/** \brief Draw a full string of any sort to any sort of buffer.
460
461 This function draws a NUL-terminated string in the set encoding to the given
462 buffer. This will automatically handle mixed half and full-width characters
463 if the encoding is set to one of the Japanese encodings. Colors and bitdepth
464 can be set.
465
466 \param b The buffer to draw to.
467 \param width The width of the buffer in pixels.
468 \param fg The foreground color to use.
469 \param bg The background color to use.
470 \param bpp The number of bits per pixel in the buffer.
471 \param opaque If non-zero, overwrite background areas with black,
472 otherwise do not change them from what they are.
473 \param str The string to draw.
474
475 \sa bfont_draw_str_ex_fmt(), bfont_draw_str_ex_va()
476*/
477void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg,
478 uint8_t bpp, bool opaque, const char *str);
479
480/** \brief Draw a full formatted string of any sort to any sort of buffer.
481
482 This function is equivalent to bfont_draw_str_ex(), except that the string
483 is formatted as with the `printf()` function.
484
485 \param b The buffer to draw to.
486 \param width The width of the buffer in pixels.
487 \param fg The foreground color to use.
488 \param bg The background color to use.
489 \param bpp The number of bits per pixel in the buffer.
490 \param opaque If non-zero, overwrite background areas with black,
491 otherwise do not change them from what they are.
492 \param fmt The printf-style format string to draw.
493 \param ... Additional printf-style variadic arguments
494
495 \sa bfont_draw_str_ex_vfmt()
496*/
497void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg,
498 uint8_t bpp, bool opaque, const char *fmt, ...)
499 __printflike(7, 8);
500
501/** \brief Draw formatted string of any sort to buffer (with va_args).
502
503 This function is equivalent to bfont_draw_str_ex_fmt(), except that the
504 variadic argument list is passed via a pointer to a va_list.
505
506 \param b The buffer to draw to.
507 \param width The width of the buffer in pixels.
508 \param fg The foreground color to use.
509 \param bg The background color to use.
510 \param bpp The number of bits per pixel in the buffer.
511 \param opaque If non-zero, overwrite background areas with black,
512 otherwise do not change them from what they are.
513 \param fmt The printf-style format string to draw.
514 \param var_args Additional printf-style variadic arguments
515
516 \sa bfont_draw_str_ex_fmt()
517*/
518void bfont_draw_str_ex_vfmt(void *b, uint32_t width, uint32_t fg, uint32_t bg,
519 uint8_t bpp, bool opaque, const char *fmt,
520 va_list *var_args);
521
522/** \brief Draw a full string to a buffer.
523
524 This function draws a NUL-terminated string in the set encoding to the given
525 buffer. This will automatically handle mixed half and full-width characters
526 if the encoding is set to one of the Japanese encodings. Draws pre-set
527 16-bit colors.
528
529 \param b The buffer to draw to.
530 \param width The width of the buffer in pixels.
531 \param opaque If one, overwrite blank areas with bfont_bgcolor,
532 otherwise do not change them from what they are.
533 \param str The string to draw.
534*/
535void bfont_draw_str(void *b, uint32_t width, bool opaque, const char *str);
536
537/** \brief Draw a full formatted string to a buffer.
538
539 This function is equvalent to bfont_draw_str(), except that the string is
540 formatted as with the `printf()` function.
541
542 \param b The buffer to draw to.
543 \param width The width of the buffer in pixels.
544 \param opaque If one, overwrite blank areas with bfont_bgcolor,
545 otherwise do not change them from what they are.
546 \param fmt The printf-style format string to draw.
547 \param ... Additional printf-style variadic arguments.
548*/
549void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt,
550 ...) __printflike(4, 5);
551
552/** @} */
553
554/** @} */
555
556__END_DECLS
557
558#endif /* __DC_BIOSFONT_H */
void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, const char *fmt,...) __printflike(7
Draw a full formatted string of any sort to any sort of buffer.
size_t bfont_draw_ex(void *buffer, uint32_t bufwidth, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, uint32_t c, bool wide, bool iskana)
Draw a single character of any sort to the buffer.
size_t bfont_draw_thin(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c, bool iskana)
Draw a single thin character to a buffer.
uint8_t * bfont_find_char_jp_half(uint32_t ch)
Find an half-width Japanese character in the font.
void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, const char *str)
Draw a full string of any sort to any sort of buffer.
bool bfont_set_32bit_mode(bool on) __depr("Please use the bpp function of the the bfont_draw_ex functions")
Set the font to draw 32-bit color.
size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c)
Draw a single character to a buffer.
void bfont_set_encoding(bfont_code_t enc)
Set the font encoding.
void void bfont_draw_str_ex_vfmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, const char *fmt, va_list *var_args)
Draw formatted string of any sort to buffer (with va_args).
uint32_t bfont_set_background_color(uint32_t c)
Set the font background color.
uint8_t * bfont_find_icon(bfont_vmu_icon_t icon)
Find a VMU icon.
void bfont_draw_str(void *b, uint32_t width, bool opaque, const char *str)
Draw a full string to a buffer.
size_t bfont_draw_wide(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c)
Draw a single wide character to a buffer.
uint32_t bfont_set_foreground_color(uint32_t c)
Set the font foreground color.
uint8_t * bfont_find_char(uint32_t ch)
Find an ISO-8859-1 character in the font.
bfont_code_t
Definition biosfont.h:304
@ BFONT_CODE_ISO8859_1
ISO-8859-1 (western) charset.
Definition biosfont.h:305
@ BFONT_CODE_RAW
Raw indexing to the BFONT.
Definition biosfont.h:308
@ BFONT_CODE_SJIS
Shift-JIS charset.
Definition biosfont.h:307
@ BFONT_CODE_EUC
EUC-JP charset.
Definition biosfont.h:306
void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt,...) __printflike(4
Draw a full formatted string to a buffer.
uint8_t * bfont_find_char_jp(uint32_t ch)
Find an full-width Japanese character in the font.
Definitions for builtin attributes and compiler directives.
bfont_vmu_icon_t
Builtin VMU Icons.
Definition biosfont.h:125
@ BFONT_ICON_INVALID_VMU
Invalid.
Definition biosfont.h:126
@ BFONT_ICON_BOAT
Boat.
Definition biosfont.h:170
@ BFONT_ICON_TREBLE_CLEF
Treble clef.
Definition biosfont.h:169
@ BFONT_ICON_CUP
Cup.
Definition biosfont.h:179
@ BFONT_ICON_GRID
Grid.
Definition biosfont.h:249
@ BFONT_ICON_HOURGLASS_FOUR
Hourglass 4.
Definition biosfont.h:130
@ BFONT_ICON_CLOCK
Clock.
Definition biosfont.h:176
@ BFONT_ICON_W
W letter
Definition biosfont.h:244
@ BFONT_ICON_TWO_STARS
Two stars.
Definition biosfont.h:200
@ BFONT_ICON_EMBROIDERY
Embroidery.
Definition biosfont.h:254
@ BFONT_ICON_HOURGLASS_THREE
Hourglass 3.
Definition biosfont.h:129
@ BFONT_ICON_Q
Q letter
Definition biosfont.h:238
@ BFONT_ICON_TEDDY_BEAR
Teddy bear.
Definition biosfont.h:191
@ BFONT_ICON_3
3 digit
Definition biosfont.h:215
@ BFONT_ICON_0
0 digit
Definition biosfont.h:212
@ BFONT_ICON_PIANO
Piano.
Definition biosfont.h:166
@ BFONT_ICON_G
G letter
Definition biosfont.h:228
@ BFONT_ICON_BULB
Bulb.
Definition biosfont.h:190
@ BFONT_ICON_CLOUD
Cloud.
Definition biosfont.h:197
@ BFONT_ICON_CACTUS
Cactus.
Definition biosfont.h:165
@ BFONT_ICON_UMBRELLA
Umbrella.
Definition biosfont.h:198
@ BFONT_ICON_TRUCK
Truck.
Definition biosfont.h:175
@ BFONT_ICON_C
C letter
Definition biosfont.h:224
@ BFONT_ICON_HOURGLASS_TWO
Hourglass 2.
Definition biosfont.h:128
@ BFONT_ICON_9
9 digit
Definition biosfont.h:221
@ BFONT_ICON_SATURN
Saturn.
Definition biosfont.h:133
@ BFONT_ICON_LAUGHING_FACE
Laughing face.
Definition biosfont.h:135
@ BFONT_ICON_CRAB
Crab.
Definition biosfont.h:154
@ BFONT_ICON_HOURGLASS_ONE
Hourglass 1.
Definition biosfont.h:127
@ BFONT_ICON_SAKURA
Sakura.
Definition biosfont.h:162
@ BFONT_ICON_MONKEY
Monkye.
Definition biosfont.h:145
@ BFONT_ICON_I
I letter
Definition biosfont.h:230
@ BFONT_ICON_K
K letter
Definition biosfont.h:232
@ BFONT_ICON_KING
King.
Definition biosfont.h:209
@ BFONT_ICON_LIGHTNING
Lightning.
Definition biosfont.h:195
@ BFONT_ICON_TELEPHONE
Telephone.
Definition biosfont.h:177
@ BFONT_ICON_BASEBALL
Baseball.
Definition biosfont.h:188
@ BFONT_ICON_BEAR
Bear.
Definition biosfont.h:147
@ BFONT_ICON_H
H letter
Definition biosfont.h:229
@ BFONT_ICON_R
R letter
Definition biosfont.h:239
@ BFONT_ICON_BOOK
Book.
Definition biosfont.h:187
@ BFONT_ICON_U
U letter
Definition biosfont.h:242
@ BFONT_ICON_4
4 digit
Definition biosfont.h:216
@ BFONT_ICON_QUARTER_MOON
Quarter moon.
Definition biosfont.h:134
@ BFONT_ICON_PANDA
Panda.
Definition biosfont.h:146
@ BFONT_ICON_CHERRIES
Cherries.
Definition biosfont.h:159
@ BFONT_ICON_LION
Lion.
Definition biosfont.h:144
@ BFONT_ICON_ANGRY_FACE
Angry face.
Definition biosfont.h:138
@ BFONT_ICON_HORSE
Horse.
Definition biosfont.h:140
@ BFONT_ICON_CROWN
Crown.
Definition biosfont.h:183
@ BFONT_ICON_F
F letter
Definition biosfont.h:227
@ BFONT_ICON_ANGLER_FISH
Angler fish.
Definition biosfont.h:157
@ BFONT_ICON_1
1 digit
Definition biosfont.h:213
@ BFONT_ICON_V
V letter
Definition biosfont.h:243
@ BFONT_ICON_B
B letter
Definition biosfont.h:223
@ BFONT_ICON_2
2 digit
Definition biosfont.h:214
@ BFONT_ICON_WHALE
Whale.
Definition biosfont.h:153
@ BFONT_ICON_X
X letter
Definition biosfont.h:245
@ BFONT_ICON_HELMET
Helmet.
Definition biosfont.h:172
@ BFONT_ICON_CLUB
Club.
Definition biosfont.h:206
@ BFONT_ICON_CHECKER_BOARD
Checker board.
Definition biosfont.h:248
@ BFONT_ICON_DIAMOND
Diamond.
Definition biosfont.h:204
@ BFONT_ICON_JACK
Jack.
Definition biosfont.h:207
@ BFONT_ICON_ISLAND
Island.
Definition biosfont.h:211
@ BFONT_ICON_APPLE
Apple.
Definition biosfont.h:163
@ BFONT_ICON_JOKER
Joker.
Definition biosfont.h:210
@ BFONT_ICON_DARK_GRAY
Dark gray.
Definition biosfont.h:253
@ BFONT_ICON_CAKE
cake
Definition biosfont.h:185
@ BFONT_ICON_VAN
Van.
Definition biosfont.h:174
@ BFONT_ICON_L
L letter
Definition biosfont.h:233
@ BFONT_ICON_CAR
Car.
Definition biosfont.h:171
@ BFONT_ICON_CASUAL_FACE
Casual face.
Definition biosfont.h:137
@ BFONT_ICON_CHICK
Chick.
Definition biosfont.h:143
@ BFONT_ICON_7
7 digit
Definition biosfont.h:219
@ BFONT_ICON_BELL
Bell.
Definition biosfont.h:182
@ BFONT_ICON_S
S letter
Definition biosfont.h:240
@ BFONT_ICON_PENGUIN
Penguin.
Definition biosfont.h:158
@ BFONT_ICON_DOG
Dog.
Definition biosfont.h:149
@ BFONT_ICON_LIGHT_GRAY
Light gray.
Definition biosfont.h:250
@ BFONT_ICON_BOW_ARROW
Bow and arrow.
Definition biosfont.h:193
@ BFONT_ICON_BOW_TIE
Bow tie.
Definition biosfont.h:192
@ BFONT_ICON_VMUICON
VMU.
Definition biosfont.h:131
@ BFONT_ICON_FOUR_STARS
Four stars.
Definition biosfont.h:202
@ BFONT_ICON_M
M letter
Definition biosfont.h:234
@ BFONT_ICON_OCTOPUS
Octopus.
Definition biosfont.h:151
@ BFONT_ICON_SNOWMAN
Snowman.
Definition biosfont.h:194
@ BFONT_ICON_FISH
Fish.
Definition biosfont.h:150
@ BFONT_ICON_SPADE
Spade.
Definition biosfont.h:205
@ BFONT_ICON_A
A letter
Definition biosfont.h:222
@ BFONT_ICON_LADYBUG
Ladybug.
Definition biosfont.h:156
@ BFONT_ICON_5
5 digit
Definition biosfont.h:217
@ BFONT_ICON_SUN
Sun.
Definition biosfont.h:196
@ BFONT_ICON_P
P letter
Definition biosfont.h:237
@ BFONT_ICON_SOCK
Sock.
Definition biosfont.h:184
@ BFONT_ICON_DIAG_GRID
Diagonal grid.
Definition biosfont.h:251
@ BFONT_ICON_D
D letter
Definition biosfont.h:225
@ BFONT_ICON_Y
Y letter
Definition biosfont.h:246
@ BFONT_ICON_E
E letter
Definition biosfont.h:226
@ BFONT_ICON_SOCCER
Soccer.
Definition biosfont.h:189
@ BFONT_ICON_RABBIT
Rabbit.
Definition biosfont.h:141
@ BFONT_ICON_EIGHTH_NOTE
Eighth note.
Definition biosfont.h:168
@ BFONT_ICON_ICECREAM
Ice cream.
Definition biosfont.h:164
@ BFONT_ICON_SILVERWARE
Silverware.
Definition biosfont.h:180
@ BFONT_ICON_LEAF
Leaf.
Definition biosfont.h:161
@ BFONT_ICON_HEART
Heart.
Definition biosfont.h:203
@ BFONT_ICON_PIG
Pig.
Definition biosfont.h:148
@ BFONT_ICON_COW
Cow.
Definition biosfont.h:139
@ BFONT_ICON_THREE_STARS
Three stars.
Definition biosfont.h:201
@ BFONT_ICON_O
O letter
Definition biosfont.h:236
@ BFONT_ICON_SMILING_FACE
Smiling face.
Definition biosfont.h:136
@ BFONT_ICON_T
T letter
Definition biosfont.h:241
@ BFONT_ICON_KEY
Key.
Definition biosfont.h:186
@ BFONT_ICON_GUITAR
Guitar.
Definition biosfont.h:167
@ BFONT_ICON_PACMAN_GRID
Pacman grid.
Definition biosfont.h:252
@ BFONT_ICON_QUEEN
Queen.
Definition biosfont.h:208
@ BFONT_ICON_CAT
Cat.
Definition biosfont.h:142
@ BFONT_ICON_EARTH
Earth.
Definition biosfont.h:132
@ BFONT_ICON_PENCIL
Pencil.
Definition biosfont.h:178
@ BFONT_ICON_ONE_STAR
One star.
Definition biosfont.h:199
@ BFONT_ICON_BUTTERFLY
Butterfly.
Definition biosfont.h:155
@ BFONT_ICON_TULIP
Tulip.
Definition biosfont.h:160
@ BFONT_ICON_HOUSE
House.
Definition biosfont.h:181
@ BFONT_ICON_SQUID
Squid.
Definition biosfont.h:152
@ BFONT_ICON_8
8 digit
Definition biosfont.h:220
@ BFONT_ICON_J
J letter
Definition biosfont.h:231
@ BFONT_ICON_Z
Z letter
Definition biosfont.h:247
@ BFONT_ICON_MOTORCYCLE
Motorcycle.
Definition biosfont.h:173
@ BFONT_ICON_N
N letter
Definition biosfont.h:235
@ BFONT_ICON_6
6 digit
Definition biosfont.h:218
#define __depr(m)
Mark something as deprecated, with an informative message.
Definition cdefs.h:119
#define __printflike(fmtarg, firstvararg)
Identify a function as accepting formatting like printf().
Definition cdefs.h:132
Common integer types.