ut_Font and ut_ResFontBase progress

This commit is contained in:
shibbo 2023-05-28 01:48:51 -04:00
parent a440447aa3
commit a61a4b105d
9 changed files with 481 additions and 50 deletions

View File

@ -16,33 +16,33 @@ __ct__Q34nw4r2ut19TagProcessorBase<w>Fv,ut_TagProcessorBase.o,libnw4r_ut.a,false
__dt__Q34nw4r2ut19TagProcessorBase<w>Fv,ut_TagProcessorBase.o,libnw4r_ut.a,false
Process__Q34nw4r2ut19TagProcessorBase<w>FUsPQ34nw4r2ut15PrintContext<w>,ut_TagProcessorBase.o,libnw4r_ut.a,false
CalcRect__Q34nw4r2ut19TagProcessorBase<w>FPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext<w>,ut_TagProcessorBase.o,libnw4r_ut.a,false
InitReaderFunc__Q34nw4r2ut4FontFQ34nw4r2ut12FontEncoding,ut_Font.o,libnw4r_ut.a,false
InitReaderFunc__Q34nw4r2ut4FontFQ34nw4r2ut12FontEncoding,ut_Font.o,libnw4r_ut.a,true
__dt__Q34nw4r2ut4FontFv,ut_RomFont.o,libnw4r_ut.a,false
__ct__Q44nw4r2ut6detail11ResFontBaseFv,ut_ResFontBase.o,libnw4r_ut.a,false
__dt__Q44nw4r2ut6detail11ResFontBaseFv,ut_ResFontBase.o,libnw4r_ut.a,false
SetResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFPvPQ34nw4r2ut15FontInformation,ut_ResFontBase.o,libnw4r_ut.a,false
RemoveResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetWidth__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetHeight__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetAscent__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetDescent__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetBaselinePos__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetCellHeight__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetCellWidth__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetMaxCharWidth__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetType__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetTextureFormat__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetLineFeed__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
GetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
SetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseFRCQ34nw4r2ut10CharWidths,ut_ResFontBase.o,libnw4r_ut.a,false
SetAlternateChar__Q44nw4r2ut6detail11ResFontBaseFUs,ut_ResFontBase.o,libnw4r_ut.a,false
SetLineFeed__Q44nw4r2ut6detail11ResFontBaseFi,ut_ResFontBase.o,libnw4r_ut.a,false
GetCharWidth__Q44nw4r2ut6detail11ResFontBaseCFUs,ut_ResFontBase.o,libnw4r_ut.a,false
__ct__Q44nw4r2ut6detail11ResFontBaseFv,ut_ResFontBase.o,libnw4r_ut.a,true
__dt__Q44nw4r2ut6detail11ResFontBaseFv,ut_ResFontBase.o,libnw4r_ut.a,true
SetResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFPvPQ34nw4r2ut15FontInformation,ut_ResFontBase.o,libnw4r_ut.a,true
RemoveResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetWidth__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetHeight__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetAscent__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetDescent__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetBaselinePos__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetCellHeight__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetCellWidth__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetMaxCharWidth__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetType__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetTextureFormat__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetLineFeed__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
GetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
SetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseFRCQ34nw4r2ut10CharWidths,ut_ResFontBase.o,libnw4r_ut.a,true
SetAlternateChar__Q44nw4r2ut6detail11ResFontBaseFUs,ut_ResFontBase.o,libnw4r_ut.a,true
SetLineFeed__Q44nw4r2ut6detail11ResFontBaseFi,ut_ResFontBase.o,libnw4r_ut.a,true
GetCharWidth__Q44nw4r2ut6detail11ResFontBaseCFUs,ut_ResFontBase.o,libnw4r_ut.a,true
GetCharWidths__Q44nw4r2ut6detail11ResFontBaseCFUs,ut_ResFontBase.o,libnw4r_ut.a,false
GetGlyph__Q44nw4r2ut6detail11ResFontBaseCFPQ34nw4r2ut5GlyphUs,ut_ResFontBase.o,libnw4r_ut.a,false
HasGlyph__Q44nw4r2ut6detail11ResFontBaseCFUs,ut_ResFontBase.o,libnw4r_ut.a,false
GetEncoding__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,false
FindGlyphIndex__Q44nw4r2ut6detail11ResFontBaseCFPCQ34nw4r2ut11FontCodeMapUs,ut_ResFontBase.o,libnw4r_ut.a,false
GetEncoding__Q44nw4r2ut6detail11ResFontBaseCFv,ut_ResFontBase.o,libnw4r_ut.a,true
FindGlyphIndex__Q44nw4r2ut6detail11ResFontBaseCFPCQ34nw4r2ut11FontCodeMapUs,ut_ResFontBase.o,libnw4r_ut.a,true
GetGlyphFromIndex__Q44nw4r2ut6detail11ResFontBaseCFPQ34nw4r2ut5GlyphUs,ut_ResFontBase.o,libnw4r_ut.a,false
__ct__Q34nw4r2ut7ResFontFv,ut_ResFont.o,libnw4r_ut.a,false
__dt__Q34nw4r2ut7ResFontFv,ut_ResFont.o,libnw4r_ut.a,false

1 Symbol Name Object File Library Archive Matching
16 __dt__Q34nw4r2ut19TagProcessorBase<w>Fv ut_TagProcessorBase.o libnw4r_ut.a false
17 Process__Q34nw4r2ut19TagProcessorBase<w>FUsPQ34nw4r2ut15PrintContext<w> ut_TagProcessorBase.o libnw4r_ut.a false
18 CalcRect__Q34nw4r2ut19TagProcessorBase<w>FPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext<w> ut_TagProcessorBase.o libnw4r_ut.a false
19 InitReaderFunc__Q34nw4r2ut4FontFQ34nw4r2ut12FontEncoding ut_Font.o libnw4r_ut.a false true
20 __dt__Q34nw4r2ut4FontFv ut_RomFont.o libnw4r_ut.a false
21 __ct__Q44nw4r2ut6detail11ResFontBaseFv ut_ResFontBase.o libnw4r_ut.a false true
22 __dt__Q44nw4r2ut6detail11ResFontBaseFv ut_ResFontBase.o libnw4r_ut.a false true
23 SetResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFPvPQ34nw4r2ut15FontInformation ut_ResFontBase.o libnw4r_ut.a false true
24 RemoveResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFv ut_ResFontBase.o libnw4r_ut.a false true
25 GetWidth__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
26 GetHeight__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
27 GetAscent__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
28 GetDescent__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
29 GetBaselinePos__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
30 GetCellHeight__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
31 GetCellWidth__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
32 GetMaxCharWidth__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
33 GetType__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
34 GetTextureFormat__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
35 GetLineFeed__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
36 GetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
37 SetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseFRCQ34nw4r2ut10CharWidths ut_ResFontBase.o libnw4r_ut.a false true
38 SetAlternateChar__Q44nw4r2ut6detail11ResFontBaseFUs ut_ResFontBase.o libnw4r_ut.a false true
39 SetLineFeed__Q44nw4r2ut6detail11ResFontBaseFi ut_ResFontBase.o libnw4r_ut.a false true
40 GetCharWidth__Q44nw4r2ut6detail11ResFontBaseCFUs ut_ResFontBase.o libnw4r_ut.a false true
41 GetCharWidths__Q44nw4r2ut6detail11ResFontBaseCFUs ut_ResFontBase.o libnw4r_ut.a false
42 GetGlyph__Q44nw4r2ut6detail11ResFontBaseCFPQ34nw4r2ut5GlyphUs ut_ResFontBase.o libnw4r_ut.a false
43 HasGlyph__Q44nw4r2ut6detail11ResFontBaseCFUs ut_ResFontBase.o libnw4r_ut.a false
44 GetEncoding__Q44nw4r2ut6detail11ResFontBaseCFv ut_ResFontBase.o libnw4r_ut.a false true
45 FindGlyphIndex__Q44nw4r2ut6detail11ResFontBaseCFPCQ34nw4r2ut11FontCodeMapUs ut_ResFontBase.o libnw4r_ut.a false true
46 GetGlyphFromIndex__Q44nw4r2ut6detail11ResFontBaseCFPQ34nw4r2ut5GlyphUs ut_ResFontBase.o libnw4r_ut.a false
47 __ct__Q34nw4r2ut7ResFontFv ut_ResFont.o libnw4r_ut.a false
48 __dt__Q34nw4r2ut7ResFontFv ut_ResFont.o libnw4r_ut.a false

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "NW4R",
"message": "16.908%",
"message": "18.56%",
"color": "blue"
}

View File

@ -3,4 +3,4 @@
| [libnw4r_db](https://github.com/shibbo/Petari/blob/master/libs/nw4r/docs/lib/libnw4r_db.md) | 0.0% |
| [libnw4r_lyt](https://github.com/shibbo/Petari/blob/master/libs/nw4r/docs/lib/libnw4r_lyt.md) | 22.644549763033176% |
| [libnw4r_math](https://github.com/shibbo/Petari/blob/master/libs/nw4r/docs/lib/libnw4r_math.md) | 58.139534883720934% |
| [libnw4r_ut](https://github.com/shibbo/Petari/blob/master/libs/nw4r/docs/lib/libnw4r_ut.md) | 3.746713409290096% |
| [libnw4r_ut](https://github.com/shibbo/Petari/blob/master/libs/nw4r/docs/lib/libnw4r_ut.md) | 9.333917616126206% |

View File

@ -12,9 +12,9 @@
| ut_binaryFileFormat.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| ut_CharStrmReader.o | 100.0% | 4 / 4 | 100.0% | :white_check_mark:
| ut_TagProcessorBase.o | 0.0% | 0 / 8 | 0.0% | :x:
| ut_Font.o | 0.0% | 0 / 1 | 0.0% | :x:
| ut_Font.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| ut_RomFont.o | 0.0% | 0 / 1 | 0.0% | :x:
| ut_ResFontBase.o | 0.0% | 0 / 26 | 0.0% | :x:
| ut_ResFontBase.o | 51.82481751824818% | 22 / 26 | 84.61538461538461% | :eight_pointed_black_star:
| ut_ResFont.o | 0.0% | 0 / 5 | 0.0% | :x:
| ut_CharWriter.o | 0.0% | 0 / 14 | 0.0% | :x:
| ut_TextWriterBase.o | 0.0% | 0 / 14 | 0.0% | :x:
@ -60,7 +60,7 @@
# ut_Font.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| InitReaderFunc__Q34nw4r2ut4FontFQ34nw4r2ut12FontEncoding | :x: |
| InitReaderFunc__Q34nw4r2ut4FontFQ34nw4r2ut12FontEncoding | :white_check_mark: |
# ut_RomFont.o
@ -72,31 +72,31 @@
# ut_ResFontBase.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __ct__Q44nw4r2ut6detail11ResFontBaseFv | :x: |
| __dt__Q44nw4r2ut6detail11ResFontBaseFv | :x: |
| SetResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFPvPQ34nw4r2ut15FontInformation | :x: |
| RemoveResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFv | :x: |
| GetWidth__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetHeight__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetAscent__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetDescent__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetBaselinePos__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetCellHeight__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetCellWidth__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetMaxCharWidth__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetType__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetTextureFormat__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetLineFeed__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| GetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| SetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseFRCQ34nw4r2ut10CharWidths | :x: |
| SetAlternateChar__Q44nw4r2ut6detail11ResFontBaseFUs | :x: |
| SetLineFeed__Q44nw4r2ut6detail11ResFontBaseFi | :x: |
| GetCharWidth__Q44nw4r2ut6detail11ResFontBaseCFUs | :x: |
| __ct__Q44nw4r2ut6detail11ResFontBaseFv | :white_check_mark: |
| __dt__Q44nw4r2ut6detail11ResFontBaseFv | :white_check_mark: |
| SetResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFPvPQ34nw4r2ut15FontInformation | :white_check_mark: |
| RemoveResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFv | :white_check_mark: |
| GetWidth__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetHeight__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetAscent__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetDescent__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetBaselinePos__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetCellHeight__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetCellWidth__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetMaxCharWidth__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetType__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetTextureFormat__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetLineFeed__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| GetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| SetDefaultCharWidths__Q44nw4r2ut6detail11ResFontBaseFRCQ34nw4r2ut10CharWidths | :white_check_mark: |
| SetAlternateChar__Q44nw4r2ut6detail11ResFontBaseFUs | :white_check_mark: |
| SetLineFeed__Q44nw4r2ut6detail11ResFontBaseFi | :white_check_mark: |
| GetCharWidth__Q44nw4r2ut6detail11ResFontBaseCFUs | :white_check_mark: |
| GetCharWidths__Q44nw4r2ut6detail11ResFontBaseCFUs | :x: |
| GetGlyph__Q44nw4r2ut6detail11ResFontBaseCFPQ34nw4r2ut5GlyphUs | :x: |
| HasGlyph__Q44nw4r2ut6detail11ResFontBaseCFUs | :x: |
| GetEncoding__Q44nw4r2ut6detail11ResFontBaseCFv | :x: |
| FindGlyphIndex__Q44nw4r2ut6detail11ResFontBaseCFPCQ34nw4r2ut11FontCodeMapUs | :x: |
| GetEncoding__Q44nw4r2ut6detail11ResFontBaseCFv | :white_check_mark: |
| FindGlyphIndex__Q44nw4r2ut6detail11ResFontBaseCFPCQ34nw4r2ut11FontCodeMapUs | :white_check_mark: |
| GetGlyphFromIndex__Q44nw4r2ut6detail11ResFontBaseCFPQ34nw4r2ut5GlyphUs | :x: |

View File

@ -0,0 +1,65 @@
#pragma once
#include <revolution.h>
#include "nw4r/ut/CharStrmReader.h"
#include "nw4r/ut/fontResourceFormat.h"
namespace nw4r {
namespace ut {
typedef u16 CharCode;
struct Glyph {
const void* pTexture;
CharWidths widths;
u8 height;
GXTexFmt texFormat;
u16 texWidth;
u16 texHeight;
u16 cellX;
u16 cellY;
};
class Font {
public:
enum Type {
Null,
Rom,
Res,
Pair
};
Font() : mReaderFunc(&CharStrmReader::ReadNextCharCP1252) {
}
virtual ~Font() {
}
virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual int GetAscent() const = 0;
virtual int GetDescent() const = 0;
virtual int GetBaselinePos() const = 0;
virtual int GetCellHeight() const = 0;
virtual int GetCellWidth() const = 0;
virtual int GetMaxCharWidth() const = 0;
virtual Type GetType() const = 0;
virtual GXTexFmt GetTextureFormat() const = 0;
virtual int GetLineFeed() const = 0;
virtual const CharWidths GetDefaultCharWidths() const = 0;
virtual void SetDefaultCharWidths(const CharWidths &) = 0;
virtual bool SetAlternateChar(CharCode) = 0;
virtual void SetLineFeed(int) = 0;
virtual int GetCharWidth(CharCode) const = 0;
virtual const CharWidths GetCharWidths(CharCode) const = 0;
virtual void GetGlyph(Glyph *, CharCode) const = 0;
virtual bool HasGlyph(CharCode) const = 0;
virtual FontEncoding GetEncoding() const = 0;
void InitReaderFunc(FontEncoding);
CharStrmReader::ReadNextCharFunc mReaderFunc;
};
};
};

View File

@ -0,0 +1,50 @@
#pragma once
#include "nw4r/ut/Font.h"
namespace nw4r {
namespace ut {
namespace detail {
class ResFontBase : public Font {
public:
ResFontBase();
virtual ~ResFontBase();
virtual int GetWidth() const;
virtual int GetHeight() const;
virtual int GetAscent() const;
virtual int GetDescent() const;
virtual int GetBaselinePos() const;
virtual int GetCellHeight() const;
virtual int GetCellWidth() const;
virtual int GetMaxCharWidth() const;
virtual Type GetType() const;
virtual GXTexFmt GetTextureFormat() const;
virtual int GetLineFeed() const;
virtual const CharWidths GetDefaultCharWidths() const;
virtual void SetDefaultCharWidths(const CharWidths &);
virtual bool SetAlternateChar(CharCode);
virtual void SetLineFeed(int);
virtual int GetCharWidth(CharCode) const;
virtual const CharWidths GetCharWidths(CharCode) const;
virtual void GetGlyph(Glyph *, CharCode) const;
virtual bool HasGlyph(CharCode) const;
virtual FontEncoding GetEncoding() const;
void SetResourceBuffer(void *, FontInformation *);
void* RemoveResourceBuffer();
const CharWidths& GetCharWidthsFromIndex(u16) const;
const CharWidths& GetCharWidthsFromIndex(const FontWidth *, u16) const;
u16 FindGlyphIndex(CharCode c) const;
u16 FindGlyphIndex(const FontCodeMap *, CharCode) const;
void GetGlyphFromIndex(Glyph *, u16) const;
u16 GetGlyphIndex(CharCode) const;
void* mResource;
FontInformation* mFontInfo;
mutable CharCode mLastCharCode;
mutable u16 mLastGlyphIndex;
};
};
};
};

View File

@ -0,0 +1,76 @@
#pragma once
#include <revolution.h>
namespace nw4r {
namespace ut {
enum FontEncoding {
UTF8,
UTF16,
SJIS,
CP1252
};
struct CharWidths {
s8 left;
u8 glyphWidth;
s8 charWidth;
};
struct CMapScanEntry {
u16 ccode;
u16 index;
};
struct CMapInfoScan {
u16 num;
CMapScanEntry entries[];
};
struct FontTextureGlyph {
u8 cellWidth;
u8 cellHeight;
s8 baselinePos;
u8 maxCharWidth;
u32 sheetSize;
u16 sheetNum;
u16 sheetFormat;
u16 sheetRow;
u16 sheetLine;
u16 sheetWidth;
u16 sheetHeight;
u8* sheetImage;
};
struct FontWidth {
u16 indexBegin;
u16 indexEnd;
FontWidth* pNext;
CharWidths widthTable[];
};
struct FontCodeMap {
u16 ccodeBegin;
u16 ccodeEnd;
u16 mappingMethod;
u16 pad;
FontCodeMap* pNext;
u16 mapInfo[];
};
struct FontInformation {
u8 fontType;
s8 lineFeed;
u16 alterCharIndex;
CharWidths defaultWidth;
u8 encoding;
FontTextureGlyph* pGlyph;
FontWidth* pWidth;
FontCodeMap* pMap;
u8 height;
u8 width;
u8 ascent;
u8 pad;
};
};
};

View File

@ -0,0 +1,23 @@
#include "nw4r/ut/Font.h"
namespace nw4r {
namespace ut {
void Font::InitReaderFunc(FontEncoding enc) {
switch (enc) {
case UTF8:
mReaderFunc = &CharStrmReader::ReadNextCharUTF8;
break;
case UTF16:
mReaderFunc = &CharStrmReader::ReadNextCharUTF16;
break;
case SJIS:
mReaderFunc = &CharStrmReader::ReadNextCharSJIS;
break;
case CP1252:
default:
mReaderFunc = &CharStrmReader::ReadNextCharCP1252;
break;
}
}
};
};

View File

@ -0,0 +1,217 @@
#include "nw4r/ut/ResFontBase.h"
namespace nw4r {
namespace ut {
namespace detail {
ResFontBase::ResFontBase() {
mResource = nullptr;
mFontInfo = nullptr;
}
ResFontBase::~ResFontBase() {
}
void ResFontBase::SetResourceBuffer(void *pBuf, FontInformation *pInf) {
mResource = pBuf;
mFontInfo = pInf;
}
void* ResFontBase::RemoveResourceBuffer() {
void* data = mResource;
mResource = nullptr;
mFontInfo = nullptr;
return data;
}
int ResFontBase::GetWidth() const {
return mFontInfo->width;
}
int ResFontBase::GetHeight() const {
return mFontInfo->height;
}
int ResFontBase::GetAscent() const {
return mFontInfo->ascent;
}
int ResFontBase::GetDescent() const {
return mFontInfo->height - mFontInfo->ascent;
}
int ResFontBase::GetBaselinePos() const {
return mFontInfo->pGlyph->baselinePos;
}
int ResFontBase::GetCellHeight() const {
return mFontInfo->pGlyph->cellHeight;
}
int ResFontBase::GetCellWidth() const {
return mFontInfo->pGlyph->cellWidth;
}
int ResFontBase::GetMaxCharWidth() const {
return mFontInfo->pGlyph->maxCharWidth;
}
Font::Type ResFontBase::GetType() const {
return Res;
}
GXTexFmt ResFontBase::GetTextureFormat() const {
return static_cast<GXTexFmt>(mFontInfo->pGlyph->sheetFormat);
}
int ResFontBase::GetLineFeed() const {
return mFontInfo->lineFeed;
}
const CharWidths ResFontBase::GetDefaultCharWidths() const {
return mFontInfo->defaultWidth;
}
void ResFontBase::SetDefaultCharWidths(const CharWidths &widths) {
mFontInfo->defaultWidth = widths;
}
bool ResFontBase::SetAlternateChar(CharCode c) {
u16 index = FindGlyphIndex(c);
if (index != 0xFFFF) {
mFontInfo->alterCharIndex = index;
return true;
}
return false;
}
void ResFontBase::SetLineFeed(int feed) {
mFontInfo->lineFeed = static_cast<s8>(feed);
}
int ResFontBase::GetCharWidth(CharCode c) const {
return GetCharWidths(c).charWidth;
}
const CharWidths ResFontBase::GetCharWidths(CharCode c) const {
u16 idx = GetGlyphIndex(c);
return GetCharWidthsFromIndex(idx);
}
void ResFontBase::GetGlyph(Glyph *pGlyph, CharCode c) const {
u16 idx = GetGlyphIndex(c);
GetGlyphFromIndex(pGlyph, idx);
}
u16 ResFontBase::GetGlyphIndex(CharCode c) const {
u16 idx = FindGlyphIndex(c);
return (idx != 0xFFFF) ? idx : mFontInfo->alterCharIndex;
}
FontEncoding ResFontBase::GetEncoding() const {
return (FontEncoding)mFontInfo->encoding;
}
u16 ResFontBase::FindGlyphIndex(CharCode c) const {
const FontCodeMap* pMap = mFontInfo->pMap;
while (pMap != nullptr) {
if ((pMap->ccodeBegin <= c) && (c <= pMap->ccodeEnd)) {
return FindGlyphIndex(pMap, c);
}
pMap = pMap->pNext;
}
return 0xFFFF;
}
u16 ResFontBase::FindGlyphIndex(const FontCodeMap *pMap, CharCode c) const {
u16 index = 0xFFFF;
switch (pMap->mappingMethod) {
case 0:
{
u16 offs = pMap->mapInfo[0];
index = static_cast<u16>(c - pMap->ccodeBegin + offs);
}
break;
case 1:
{
const int tbl_idx = c - pMap->ccodeBegin;
index = pMap->mapInfo[tbl_idx];
}
break;
case 2:
{
const CMapInfoScan* const scanInfo = reinterpret_cast<const CMapInfoScan*>(pMap->mapInfo);
const CMapScanEntry* first = &(scanInfo->entries[0]);
const CMapScanEntry* last = &(scanInfo->entries[scanInfo->num - 1]);
while (first <= last) {
const CMapScanEntry* mid = first + (last - first) / 2;
if (mid->ccode < c) {
first = mid + 1;
}
else if (c < mid->ccode) {
last = mid - 1;
}
else {
index = mid->index;
break;
}
}
}
break;
}
return index;
}
const CharWidths& ResFontBase::GetCharWidthsFromIndex(u16 index) const {
const FontWidth* pWidth = mFontInfo->pWidth;
while (pWidth != nullptr) {
if ((pWidth->indexBegin <= index) && (index <= pWidth->indexEnd)) {
return GetCharWidthsFromIndex(pWidth, index);
}
pWidth = pWidth->pNext;
}
return mFontInfo->defaultWidth;
}
const CharWidths& ResFontBase::GetCharWidthsFromIndex(const FontWidth *pWidth, u16 index) const {
return pWidth->widthTable[index - pWidth->indexBegin];
}
void ResFontBase::GetGlyphFromIndex(Glyph *glyph, u16 index) const {
const FontTextureGlyph& tg = *mFontInfo->pGlyph;
const u32 cellsInASheet = static_cast<u32>(tg.sheetRow * tg.sheetLine);
const u32 sheetNo = index / cellsInASheet;
const u32 cellNo = index % cellsInASheet;
const u32 cellUnitX = cellNo % tg.sheetRow;
const u32 cellUnitY = cellNo / tg.sheetRow;
const u32 cellPixelX = cellUnitX * (tg.cellWidth + 1);
const u32 cellPixelY = cellUnitY * (tg.cellHeight + 1);
const u32 offsetBytes = sheetNo * tg.sheetSize;
const void* pSheet = tg.sheetImage + offsetBytes;
glyph->pTexture = pSheet;
glyph->widths = GetCharWidthsFromIndex(index);
glyph->height = tg.cellHeight;
glyph->texFormat = static_cast<GXTexFmt>(tg.sheetFormat);
glyph->texWidth = tg.sheetWidth;
glyph->texHeight = tg.sheetHeight;
glyph->cellX = static_cast<u16>(cellPixelX + 1);
glyph->cellY = static_cast<u16>(cellPixelY + 1);
}
};
};
};