mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #1038 from unknownbrackets/fonts
Finish implementing savestates for fonts
This commit is contained in:
commit
60732924f8
4 changed files with 46 additions and 17 deletions
|
@ -84,7 +84,7 @@ class PointerWrap
|
||||||
static void DoArray(PointerWrap *p, T *x, int count)
|
static void DoArray(PointerWrap *p, T *x, int count)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
p->DoClass(x[i]);
|
p->Do(x[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Do(PointerWrap *p, T &x)
|
static void Do(PointerWrap *p, T &x)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Core/MemMap.h"
|
#include "Core/MemMap.h"
|
||||||
#include "Core/Font/PGF.h"
|
#include "Core/Font/PGF.h"
|
||||||
|
#include "Core/HLE/HLE.h"
|
||||||
|
|
||||||
// These fonts, created by ttf2pgf, don't have complete glyph info and need to be identified.
|
// These fonts, created by ttf2pgf, don't have complete glyph info and need to be identified.
|
||||||
static bool isJPCSPFont(const char *fontName) {
|
static bool isJPCSPFont(const char *fontName) {
|
||||||
|
@ -50,19 +51,48 @@ static std::vector<int> getTable(const u8 *buf, int bpe, int length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PGF::PGF()
|
PGF::PGF()
|
||||||
: fontData(0), charMap(0), shadowCharMap(0), charPointerTable(0) {
|
: fontData(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PGF::~PGF() {
|
PGF::~PGF() {
|
||||||
|
if (fontData) {
|
||||||
delete [] fontData;
|
delete [] fontData;
|
||||||
delete [] charMap;
|
}
|
||||||
delete [] shadowCharMap;
|
|
||||||
delete [] charPointerTable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PGF::DoState(PointerWrap &p) {
|
void PGF::DoState(PointerWrap &p) {
|
||||||
// TODO!
|
p.Do(header);
|
||||||
|
p.Do(rev3extra);
|
||||||
|
|
||||||
|
p.Do(fontDataSize);
|
||||||
|
if (p.mode == p.MODE_READ) {
|
||||||
|
if (fontData) {
|
||||||
|
delete [] fontData;
|
||||||
|
}
|
||||||
|
if (fontDataSize) {
|
||||||
|
fontData = new u8[fontDataSize];
|
||||||
|
p.DoArray(fontData, fontDataSize);
|
||||||
|
}
|
||||||
|
} else if (fontDataSize) {
|
||||||
|
p.DoArray(fontData, fontDataSize);
|
||||||
|
}
|
||||||
|
p.Do(fileName);
|
||||||
|
|
||||||
|
p.DoArray(dimensionTable, ARRAY_SIZE(dimensionTable));
|
||||||
|
p.DoArray(xAdjustTable, ARRAY_SIZE(xAdjustTable));
|
||||||
|
p.DoArray(yAdjustTable, ARRAY_SIZE(yAdjustTable));
|
||||||
|
p.DoArray(advanceTable, ARRAY_SIZE(advanceTable));
|
||||||
|
p.DoArray(charmapCompressionTable1, ARRAY_SIZE(charmapCompressionTable1));
|
||||||
|
p.DoArray(charmapCompressionTable2, ARRAY_SIZE(charmapCompressionTable2));
|
||||||
|
|
||||||
|
p.Do(charmap_compr);
|
||||||
|
p.Do(charmap);
|
||||||
|
p.Do(glyphs);
|
||||||
|
p.Do(shadowGlyphs);
|
||||||
|
p.Do(firstGlyph);
|
||||||
|
|
||||||
|
p.DoMarker("PGF");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PGF::ReadPtr(const u8 *ptr, size_t dataSize) {
|
void PGF::ReadPtr(const u8 *ptr, size_t dataSize) {
|
||||||
|
@ -111,7 +141,7 @@ void PGF::ReadPtr(const u8 *ptr, size_t dataSize) {
|
||||||
const u8 *uptr = (const u8 *)wptr;
|
const u8 *uptr = (const u8 *)wptr;
|
||||||
|
|
||||||
int shadowCharMapSize = ((header.shadowMapLength * header.shadowMapBpe + 31) & ~31) / 8;
|
int shadowCharMapSize = ((header.shadowMapLength * header.shadowMapBpe + 31) & ~31) / 8;
|
||||||
shadowCharMap = new u8[shadowCharMapSize];
|
u8 *shadowCharMap = new u8[shadowCharMapSize];
|
||||||
for (int i = 0; i < shadowCharMapSize; i++) {
|
for (int i = 0; i < shadowCharMapSize; i++) {
|
||||||
shadowCharMap[i] = *uptr++;
|
shadowCharMap[i] = *uptr++;
|
||||||
}
|
}
|
||||||
|
@ -137,13 +167,13 @@ void PGF::ReadPtr(const u8 *ptr, size_t dataSize) {
|
||||||
|
|
||||||
int charMapSize = ((header.charMapLength * header.charMapBpe + 31) & ~31) / 8;
|
int charMapSize = ((header.charMapLength * header.charMapBpe + 31) & ~31) / 8;
|
||||||
|
|
||||||
charMap = new u8[charMapSize];
|
u8 *charMap = new u8[charMapSize];
|
||||||
for (int i = 0; i < charMapSize; i++) {
|
for (int i = 0; i < charMapSize; i++) {
|
||||||
charMap[i] = *uptr++;
|
charMap[i] = *uptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int charPointerSize = (((header.charPointerLength * header.charPointerBpe + 31) & ~31) / 8);
|
int charPointerSize = (((header.charPointerLength * header.charPointerBpe + 31) & ~31) / 8);
|
||||||
charPointerTable = new u8[charPointerSize];
|
u8 *charPointerTable = new u8[charPointerSize];
|
||||||
for (int i = 0; i < charPointerSize; i++) {
|
for (int i = 0; i < charPointerSize; i++) {
|
||||||
charPointerTable[i] = *uptr++;
|
charPointerTable[i] = *uptr++;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +205,10 @@ void PGF::ReadPtr(const u8 *ptr, size_t dataSize) {
|
||||||
std::vector<int> charPointers = getTable(charPointerTable, header.charPointerBpe, glyphs.size());
|
std::vector<int> charPointers = getTable(charPointerTable, header.charPointerBpe, glyphs.size());
|
||||||
std::vector<int> shadowMap = getTable(shadowCharMap, header.shadowMapBpe, shadowGlyphs.size());
|
std::vector<int> shadowMap = getTable(shadowCharMap, header.shadowMapBpe, shadowGlyphs.size());
|
||||||
|
|
||||||
|
delete [] charMap;
|
||||||
|
delete [] shadowCharMap;
|
||||||
|
delete [] charPointerTable;
|
||||||
|
|
||||||
// Pregenerate glyphs.
|
// Pregenerate glyphs.
|
||||||
for (size_t i = 0; i < glyphs.size(); i++) {
|
for (size_t i = 0; i < glyphs.size(); i++) {
|
||||||
GetGlyph(fontData, charPointers[i] * 4 * 8 /* ??? */, FONT_PGF_CHARGLYPH, glyphs[i]);
|
GetGlyph(fontData, charPointers[i] * 4 * 8 /* ??? */, FONT_PGF_CHARGLYPH, glyphs[i]);
|
||||||
|
|
|
@ -91,8 +91,7 @@ struct PGFFontStyle {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Glyph {
|
struct Glyph {
|
||||||
public:
|
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int w;
|
int w;
|
||||||
|
@ -276,10 +275,6 @@ private:
|
||||||
std::vector<int> charmapCompressionTable1[2];
|
std::vector<int> charmapCompressionTable1[2];
|
||||||
std::vector<int> charmapCompressionTable2[2];
|
std::vector<int> charmapCompressionTable2[2];
|
||||||
|
|
||||||
u8 *charMap;
|
|
||||||
u8 *shadowCharMap;
|
|
||||||
u8 *charPointerTable;
|
|
||||||
|
|
||||||
std::vector<int> charmap_compr;
|
std::vector<int> charmap_compr;
|
||||||
std::vector<int> charmap;
|
std::vector<int> charmap;
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ private:
|
||||||
class LoadedFont {
|
class LoadedFont {
|
||||||
public:
|
public:
|
||||||
// For savestates only.
|
// For savestates only.
|
||||||
LoadedFont() {
|
LoadedFont() : font_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadedFont(Font *font, u32 fontLibID, u32 handle)
|
LoadedFont(Font *font, u32 fontLibID, u32 handle)
|
||||||
|
|
Loading…
Add table
Reference in a new issue