Added full glyph tracking/outline plumbing plus mutex-protected generated-glyph tracking and helpers (BuildTrueOutline, true-outline extraction, glyf detection, system-font cache/fallback logic, etc.).
Swapped OTF defaults for several JP/JP_AR sets (and CJK sets used by Death Stranding / Anywhere VR) to SSTAribStdB24-Regular.ttf or other TTFs so we load glyf faces.
Wrapped every LOG_* call in INFO/DEBUG pairs: INFO just announces the call, DEBUG lists each parameter on its own line with an extra trailing newline; warnings/errors remain for validation/fallback.
Implemented TTF detection for cache loading and fallback with logging.
Renamed glyph param struct/members, moved glyph handle struct into the header, and renamed the glyph API parameters/fields accordingly.
font.h

Added the new glyph outline/glyph handle definitions and renamed OrbisFontGenerateGlyphParams members (id, res0, form_options, mem, res1/2).
Updated function prototypes to use the renamed types and pointers (e.g., sceFontGenerateCharGlyph signature now matches the new names).
fontft.cpp

Reworked sceFontSelectLibraryFt/sceFontSelectRendererFt logging to follow the same INFO/DEBUG pattern (INFO announces that selection is requested, DEBUG dumps all params).
This commit is contained in:
w1naenator 2025-11-22 01:14:32 +02:00
parent a6280053b7
commit e3e8561d58
3 changed files with 764 additions and 202 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,17 +12,19 @@ struct OrbisFontHandleOpaque {
u32 reserved[64];
};
using OrbisFontLib = void*;
using OrbisFontHandle = OrbisFontHandleOpaque*;
using OrbisFontRendererCreateParams = void*;
using OrbisFontRenderer = void*;
using OrbisFontLibCreateParams = void*;
struct OrbisFontOpenParams {
u16 tag;
u16 pad16;
u32 flags;
u32 subfont_index;
using OrbisFontLib = void*;
using OrbisFontHandle = OrbisFontHandleOpaque*;
using OrbisFontRendererCreateParams = void*;
using OrbisFontRenderer = void*;
using OrbisFontLibCreateParams = void*;
struct OrbisFontMem;
struct OrbisFontOpenParams {
u16 tag;
u16 pad16;
u32 flags;
u32 subfont_index;
s32 unique_id;
const void* reserved_ptr2;
const void* reserved_ptr1;
@ -46,20 +48,62 @@ struct OrbisFontKerning {
float py;
};
struct OrbisFontGlyphImageMetrics {
float bearing_x;
float bearing_y;
float dv;
float stride;
u32 width;
u32 height;
};
struct OrbisFontResultStage {
u8* p_00;
u32 u32_08;
u32 u32_0C;
u32 u32_10;
struct OrbisFontGlyphImageMetrics {
float bearing_x;
float bearing_y;
float dv;
float stride;
u32 width;
u32 height;
};
struct OrbisFontGenerateGlyphParams {
u16 id;
u16 res0;
u16 form_options;
u8 glyph_form;
u8 metrics_form;
const OrbisFontMem* mem;
void* res1;
void* res2;
};
struct OrbisFontGlyphOutlinePoint {
float x;
float y;
};
struct OrbisFontGlyphOutline {
s16 contours_cnt;
s16 points_cnt;
u32 outline_flags;
OrbisFontGlyphOutlinePoint* points_ptr;
u8* tags_ptr;
u16* contour_end_idx;
};
struct OrbisFontGlyphOpaque {
u16 magic;
u16 flags;
u8 glyph_form;
u8 metrics_form;
u16 em_size;
u16 baseline;
u16 height_px;
u16 origin_x;
u16 origin_y;
float scale_x;
float base_scale;
const OrbisFontMem* memory;
};
using OrbisFontGlyph = OrbisFontGlyphOpaque*;
struct OrbisFontResultStage {
u8* p_00;
u32 u32_08;
u32 u32_0C;
u32 u32_10;
};
struct OrbisFontResultSlot {
@ -69,23 +113,21 @@ struct OrbisFontResultSlot {
u8 maybe_pixelFmt;
};
struct OrbisFontRenderOutput {
const OrbisFontResultStage* stage;
OrbisFontResultSlot slot;
u32 new_x;
u32 new_y;
u32 new_w;
u32 new_h;
OrbisFontGlyphImageMetrics ImageMetrics;
};
struct OrbisFontMem;
using OrbisFontAllocFn = void*(void* object, u32 size);
using OrbisFontFreeFn = void(void* object, void* p);
using OrbisFontReallocFn = void*(void* object, void* p, u32 newSize);
using OrbisFontCallocFn = void*(void* object, u32 nBlock, u32 size);
using OrbisFontMspaceCreateFn = void*(void* parent, const char* name, void* address, u32 size,
struct OrbisFontRenderOutput {
const OrbisFontResultStage* stage;
OrbisFontResultSlot slot;
u32 new_x;
u32 new_y;
u32 new_w;
u32 new_h;
OrbisFontGlyphImageMetrics ImageMetrics;
};
using OrbisFontAllocFn = void*(void* object, u32 size);
using OrbisFontFreeFn = void(void* object, void* p);
using OrbisFontReallocFn = void*(void* object, void* p, u32 newSize);
using OrbisFontCallocFn = void*(void* object, u32 nBlock, u32 size);
using OrbisFontMspaceCreateFn = void*(void* parent, const char* name, void* address, u32 size,
u32 attr);
using OrbisFontMspaceDestroyFn = void(void* parent, void* mspace);
using OrbisFontMemDestroyFn = void(OrbisFontMem* fontMemory, void* object, void* destroyArg);
@ -216,20 +258,22 @@ s32 PS4_SYSV_ABI sceFontCreateRenderer(const OrbisFontMem* memory,
s32 PS4_SYSV_ABI sceFontCreateRendererWithEdition(const OrbisFontMem* memory,
OrbisFontRendererCreateParams create_params,
u64 edition, OrbisFontRenderer* pRenderer);
s32 PS4_SYSV_ABI sceFontCreateString();
s32 PS4_SYSV_ABI sceFontCreateWords();
s32 PS4_SYSV_ABI sceFontCreateWritingLine();
s32 PS4_SYSV_ABI sceFontDefineAttribute();
s32 PS4_SYSV_ABI sceFontDeleteGlyph();
s32 PS4_SYSV_ABI sceFontCreateString();
s32 PS4_SYSV_ABI sceFontCreateWords();
s32 PS4_SYSV_ABI sceFontCreateWritingLine();
s32 PS4_SYSV_ABI sceFontDefineAttribute();
s32 PS4_SYSV_ABI sceFontDeleteGlyph(const OrbisFontMem* memory, OrbisFontGlyph* glyph);
s32 PS4_SYSV_ABI sceFontDestroyGraphicsDevice();
s32 PS4_SYSV_ABI sceFontDestroyGraphicsService();
s32 PS4_SYSV_ABI sceFontDestroyLibrary(OrbisFontLib* pLibrary);
s32 PS4_SYSV_ABI sceFontDestroyRenderer(OrbisFontRenderer* pRenderer);
s32 PS4_SYSV_ABI sceFontDestroyString();
s32 PS4_SYSV_ABI sceFontDestroyWords();
s32 PS4_SYSV_ABI sceFontDestroyWritingLine();
s32 PS4_SYSV_ABI sceFontDettachDeviceCacheBuffer();
s32 PS4_SYSV_ABI sceFontGenerateCharGlyph();
s32 PS4_SYSV_ABI sceFontDestroyWords();
s32 PS4_SYSV_ABI sceFontDestroyWritingLine();
s32 PS4_SYSV_ABI sceFontDettachDeviceCacheBuffer();
s32 PS4_SYSV_ABI sceFontGenerateCharGlyph(OrbisFontHandle glyph_handle, u32 codepoint,
const OrbisFontGenerateGlyphParams* gen_params,
OrbisFontGlyph* glyph_out);
s32 PS4_SYSV_ABI sceFontGetAttribute();
s32 PS4_SYSV_ABI sceFontGetCharGlyphCode();
s32 PS4_SYSV_ABI sceFontGetCharGlyphMetrics(OrbisFontHandle fontHandle, u32 code,
@ -265,16 +309,16 @@ s32 PS4_SYSV_ABI sceFontGetVerticalLayout(OrbisFontHandle fontHandle,
s32 PS4_SYSV_ABI sceFontGlyphDefineAttribute();
s32 PS4_SYSV_ABI sceFontGlyphGetAttribute();
s32 PS4_SYSV_ABI sceFontGlyphGetGlyphForm();
s32 PS4_SYSV_ABI sceFontGlyphGetMetricsForm();
s32 PS4_SYSV_ABI sceFontGlyphGetScalePixel();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetrics();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetricsHorizontal();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetricsHorizontalAdvance();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetricsHorizontalX();
s32 PS4_SYSV_ABI sceFontGlyphRefersOutline();
s32 PS4_SYSV_ABI sceFontGlyphRenderImage();
s32 PS4_SYSV_ABI sceFontGlyphRenderImageHorizontal();
s32 PS4_SYSV_ABI sceFontGlyphRenderImageVertical();
s32 PS4_SYSV_ABI sceFontGlyphGetMetricsForm();
s32 PS4_SYSV_ABI sceFontGlyphGetScalePixel();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetrics();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetricsHorizontal();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetricsHorizontalAdvance();
s32 PS4_SYSV_ABI sceFontGlyphRefersMetricsHorizontalX();
OrbisFontGlyphOutline* PS4_SYSV_ABI sceFontGlyphRefersOutline(OrbisFontGlyph glyph);
s32 PS4_SYSV_ABI sceFontGlyphRenderImage();
s32 PS4_SYSV_ABI sceFontGlyphRenderImageHorizontal();
s32 PS4_SYSV_ABI sceFontGlyphRenderImageVertical();
s32 PS4_SYSV_ABI sceFontGraphicsBeginFrame();
s32 PS4_SYSV_ABI sceFontGraphicsDrawingCancel();
s32 PS4_SYSV_ABI sceFontGraphicsDrawingFinish();

View File

@ -138,9 +138,12 @@ s32 PS4_SYSV_ABI sceFontSelectGlyphsFt() {
const OrbisFontLibrarySelection* PS4_SYSV_ABI sceFontSelectLibraryFt(int value) {
if (!g_library_selected) {
g_library_selected = true;
LOG_INFO(Lib_FontFt, "SelectLibraryFt: using default FreeType shim");
LOG_INFO(Lib_FontFt, "library selection requested (FreeType shim)");
}
LOG_INFO(Lib_FontFt, "SelectLibraryFt: value={}", value);
LOG_DEBUG(Lib_FontFt,
"library selection params:\n"
" value={}\n",
value);
if (value == 0) {
return &kDefaultLibrarySelection;
}
@ -150,9 +153,12 @@ const OrbisFontLibrarySelection* PS4_SYSV_ABI sceFontSelectLibraryFt(int value)
const OrbisFontRendererSelection* PS4_SYSV_ABI sceFontSelectRendererFt(int value) {
if (!g_renderer_selected) {
g_renderer_selected = true;
LOG_INFO(Lib_FontFt, "SelectRendererFt: using stb_truetype renderer backend");
LOG_INFO(Lib_FontFt, "renderer selection requested (stb_truetype backend)");
}
LOG_INFO(Lib_FontFt, "SelectRendererFt: value={}", value);
LOG_DEBUG(Lib_FontFt,
"renderer selection params:\n"
" value={}\n",
value);
if (value == 0) {
return &kDefaultRendererSelection;
}