| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file font.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 3rd February 2009: Created font.h from parts of OpenJazz.h |
| 11 | * |
| 12 | * @par Licence: |
| 13 | * Copyright (c) 2005-2010 AJ Thomson |
| 14 | * |
| 15 | * OpenJazz is distributed under the terms of |
| 16 | * the GNU General Public License, version 2.0 |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #ifndef OJ_FONT_H |
| 21 | #define OJ_FONT_Hcxx . . $ `src/io/gfx/font.h:21:9`! |
| 22 | |
| 23 | #include "OpenJazz.h"cxx . . $ `<file>/src/OpenJazz.h`/ |
| 24 | |
| 25 | #ifdef OJ_SDL3 |
| 26 | #include <SDL3/SDL.h> |
| 27 | #else |
| 28 | #include <SDL.h> |
| 29 | #endif |
| 30 | |
| 31 | #define MAX_FONT_CHARScxx . . $ `src/io/gfx/font.h:31:9`! 128 |
| 32 | |
| 33 | // Classes |
| 34 | |
| 35 | /// Font |
| 36 | class Fontcxx . . $ Font# { |
| 37 | |
| 38 | private: |
| 39 | void commonSetupcxx . . $ Font#commonSetup(49f6e7a06ebc5aa8).(); |
| 40 | void cleanMappingcxx . . $ Font#cleanMapping(49f6e7a06ebc5aa8).(); |
| 41 | SDL_Surface *characterAtlascxx . . $ Font#characterAtlas.; ///< Symbol images |
| 42 | SDL_Rect atlasRectscxx . . $ Font#atlasRects.[MAX_FONT_CHARScxx . . $ `src/io/gfx/font.h:31:9`!]; ///< Symbol positions |
| 43 | bool isOkcxx . . $ Font#isOk.; ///< Font is loaded and usable |
| 44 | int nCharacterscxx . . $ Font#nCharacters.; ///< Number of symbols |
| 45 | unsigned char spaceWidthcxx . . $ Font#spaceWidth.; ///< Horizontal spacing of displayed characters |
| 46 | unsigned char lineHeightcxx . . $ Font#lineHeight.; ///< Vertical spacing of displayed characters |
| 47 | unsigned int mapcxx . . $ Font#map.[MAX_FONT_CHARScxx . . $ `src/io/gfx/font.h:31:9`!]; ///< Maps ASCII values to symbol indices |
| 48 | |
| 49 | public: |
| 50 | explicit Fontcxx . . $ Font#Font(85c52e162fed56f9).(const char *fileName); |
| 51 | Fontcxx . . $ Font#Font(ff9db7b1d71f489c).(unsigned char *pixels, bool big); |
| 52 | explicit Fontcxx . . $ Font#Font(b45ddcbc8423892c).(bool bonus); |
| 53 | ~cxx . . $ Font#`~Font`(49f6e7a06ebc5aa8).Fontcxx . . $ Font#(); |
| 54 | |
| 55 | Pointcxx . . $ Point# showStringcxx . . $ Font#showString(7e50a619d5a117f1). (const char *s, int x, int y, alignXcxx . . $ alignX# xAlign = alignXcxx . . $ alignX#::Leftcxx . . $ alignX#Left., alignYcxx . . $ alignY# yAlign = alignYcxx . . $ alignY#::Topcxx . . $ alignY#Top.); |
| 56 | Pointcxx . . $ Point# showStringCenteredcxx . . $ Font#showStringCentered(dffc78c69bf84bb8). (const char *s); |
| 57 | int showSceneStringcxx . . $ Font#showSceneString(98fdf16c90fffe93). (const unsigned char *s, int x, int y); |
| 58 | void showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b). (int n, int x, int y); |
| 59 | void mapPalettecxx . . $ Font#mapPalette(748afa4755bc9595). (int start, int length, int newStart, int newLength); |
| 60 | void restorePalettecxx . . $ Font#restorePalette(49f6e7a06ebc5aa8). (); |
| 61 | int getHeightcxx . . $ Font#getHeight(455f465bc33b4cdf). () const; |
| 62 | int getSpaceWidthcxx . . $ Font#getSpaceWidth(455f465bc33b4cdf). () const; |
| 63 | int getStringWidthcxx . . $ Font#getStringWidth(5c4306d8553b3696). (const char *string); |
| 64 | int getStringHeightcxx . . $ Font#getStringHeight(5c4306d8553b3696). (const char *string); |
| 65 | int getSceneStringWidthcxx . . $ Font#getSceneStringWidth(b84ccf4e0bb14b06). (const unsigned char *string); |
| 66 | #ifdef DEBUG_FONTS |
| 67 | void saveAtlasAsBMP (const char *fileName); |
| 68 | #endif |
| 69 | |
| 70 | }; |
| 71 | |
| 72 | // Inline functions |
| 73 | |
| 74 | inline int Fontcxx . . $ Font#::getHeightcxx . . $ Font#getHeight(455f465bc33b4cdf).() const { return lineHeightcxx . . $ Font#lineHeight.; } ///< Get the height of a single line of any text. |
| 75 | inline int Fontcxx . . $ Font#::getSpaceWidthcxx . . $ Font#getSpaceWidth(455f465bc33b4cdf).() const { return spaceWidthcxx . . $ Font#spaceWidth.; } ///< Get the width of a space. |
| 76 | |
| 77 | // Variables |
| 78 | |
| 79 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *font2cxx . . $ font2.; /** Taken from .0FN file name */ |
| 80 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *fontbigcxx . . $ fontbig.; /** Taken from .0FN file name */ |
| 81 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *fontinycxx . . $ fontiny.; /** Taken from .0FN file name */ |
| 82 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *fontmn1cxx . . $ fontmn1.; /** Taken from .0FN file name */ |
| 83 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *fontmn2cxx . . $ fontmn2.; /** Taken from .0FN file name */ |
| 84 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *panelBigFontcxx . . $ panelBigFont.; /** Found in PANEL.000 */ |
| 85 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Fontcxx . . $ Font# *panelSmallFontcxx . . $ panelSmallFont.; /** Found in PANEL.000 */ |
| 86 | |
| 87 | #endif |