diff --git a/src/core/libraries/font/font.cpp b/src/core/libraries/font/font.cpp index ef4ea7a12..2b1c43505 100644 --- a/src/core/libraries/font/font.cpp +++ b/src/core/libraries/font/font.cpp @@ -757,7 +757,7 @@ void PS4_SYSV_ABI sceFontRenderSurfaceInit(OrbisFontRenderSurface* renderSurface // Initialize unknown fields (likely reserved or flags) renderSurface->unkn_0xd = 0; - renderSurface->unkn_0xe = 0; + renderSurface->styleFlag = 0; renderSurface->unkn_0xf = 0; // Ensure width and height are non-negative @@ -814,9 +814,26 @@ void PS4_SYSV_ABI sceFontRenderSurfaceSetScissor(OrbisFontRenderSurface* renderS } } -s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame() { - LOG_ERROR(Lib_Font, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame(OrbisFontRenderSurface* renderSurface, + OrbisFontStyleFrame* styleFrame) { + if (!renderSurface) { + return ORBIS_FONT_ERROR_INVALID_PARAMETER; + } + + if (!styleFrame) { + renderSurface->styleFlag &= 0xFE; // Clear style flag + } else { + // Validate magic number + if (styleFrame->magic != 0xF09) { + return ORBIS_FONT_ERROR_INVALID_PARAMETER; + } + + renderSurface->styleFlag |= 1; // Set style flag + } + + // Assign style frame pointer + renderSurface->unkn_28[0] = styleFrame; + *(uint32_t*)(renderSurface->unkn_28 + 1) = 0; // Reset related field } s32 PS4_SYSV_ABI sceFontSetEffectSlant() { @@ -904,8 +921,29 @@ s32 PS4_SYSV_ABI sceFontStringRefersTextCharacters() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectSlant() { - LOG_ERROR(Lib_Font, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectSlant(OrbisFontStyleFrame* styleFrame, + float* slantRatio) { + if (!styleFrame) { + printf("[ERROR] Style frame is NULL.\n"); + return ORBIS_FONT_ERROR_INVALID_PARAMETER; + } + + // Validate the magic number + if (styleFrame->magic != 0xF09) { + return ORBIS_FONT_ERROR_INVALID_PARAMETER; + } + + // Check if the slant effect is enabled (bit 1 in flags) + if (!(styleFrame->flags & 0x02)) { + return ORBIS_FONT_ERROR_UNSET_PARAMETER; + } + + if (!slantRatio) { + return ORBIS_FONT_ERROR_INVALID_PARAMETER; + } + + // Retrieve slant ratio + *slantRatio = styleFrame->slantRatio; return ORBIS_OK; } diff --git a/src/core/libraries/font/font.h b/src/core/libraries/font/font.h index c3bae6c51..e62dc9d78 100644 --- a/src/core/libraries/font/font.h +++ b/src/core/libraries/font/font.h @@ -29,14 +29,21 @@ struct OrbisFontRenderSurface { s32 widthByte; s8 pixelSizeByte; u8 unkn_0xd; - u8 unkn_0xe; + u8 styleFlag; u8 unkn_0xf; s32 width, height; u32 sc_x0; u32 sc_y0; u32 sc_x1; u32 sc_y1; - u32 unkn_28[22]; + void* unkn_28[3]; +}; + +struct OrbisFontStyleFrame { + u16 magic; // Expected to be 0xF09 + u16 flags; + // + float slantRatio; //0x24 }; s32 PS4_SYSV_ABI sceFontAttachDeviceCacheBuffer(); @@ -186,7 +193,8 @@ void PS4_SYSV_ABI sceFontRenderSurfaceInit(OrbisFontRenderSurface* renderSurface int heightPixel); void PS4_SYSV_ABI sceFontRenderSurfaceSetScissor(OrbisFontRenderSurface* renderSurface, int x0, int y0, int w, int h); -s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame(); +s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame(OrbisFontRenderSurface* renderSurface, + OrbisFontStyleFrame* styleFrame); s32 PS4_SYSV_ABI sceFontSetEffectSlant(); s32 PS4_SYSV_ABI sceFontSetEffectWeight(); s32 PS4_SYSV_ABI sceFontSetFontsOpenMode(); @@ -204,7 +212,8 @@ s32 PS4_SYSV_ABI sceFontStringGetTerminateOrder(); s32 PS4_SYSV_ABI sceFontStringGetWritingForm(); s32 PS4_SYSV_ABI sceFontStringRefersRenderCharacters(); s32 PS4_SYSV_ABI sceFontStringRefersTextCharacters(); -s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectSlant(); +s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectSlant(OrbisFontStyleFrame* styleFrame, + float* slantRatio); s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectWeight(); s32 PS4_SYSV_ABI sceFontStyleFrameGetResolutionDpi(); s32 PS4_SYSV_ABI sceFontStyleFrameGetScalePixel();