added sceFontStyleFrameGetScalePixel

This commit is contained in:
georgemoralis 2025-03-14 12:26:53 +02:00
parent 2d839cb144
commit 6b9c790698
2 changed files with 55 additions and 10 deletions

View File

@ -817,6 +817,7 @@ void PS4_SYSV_ABI sceFontRenderSurfaceSetScissor(OrbisFontRenderSurface* renderS
s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame(OrbisFontRenderSurface* renderSurface,
OrbisFontStyleFrame* styleFrame) {
if (!renderSurface) {
LOG_ERROR(Lib_Font, "Invalid Parameter");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
@ -825,6 +826,7 @@ s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame(OrbisFontRenderSurface* rende
} else {
// Validate magic number
if (styleFrame->magic != 0xF09) {
LOG_ERROR(Lib_Font, "Invalid magic");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
@ -925,21 +927,24 @@ s32 PS4_SYSV_ABI sceFontStringRefersTextCharacters() {
s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectSlant(OrbisFontStyleFrame* styleFrame,
float* slantRatio) {
if (!styleFrame) {
printf("[ERROR] Style frame is NULL.\n");
LOG_ERROR(Lib_Font, "Invalid Parameter");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
// Validate the magic number
if (styleFrame->magic != 0xF09) {
LOG_ERROR(Lib_Font, "Invalid Magic");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
// Check if the slant effect is enabled (bit 1 in flags)
if (!(styleFrame->flags & 0x02)) {
LOG_ERROR(Lib_Font, "Flag not set");
return ORBIS_FONT_ERROR_UNSET_PARAMETER;
}
if (!slantRatio) {
LOG_ERROR(Lib_Font, "Invalid Parameter");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
@ -952,16 +957,19 @@ s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectWeight(OrbisFontStyleFrame* fontStyle
float* weightXScale, float* weightYScale,
uint32_t* mode) {
if (!fontStyleFrame) {
LOG_ERROR(Lib_Font, "Invalid Parameter");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
// Validate the magic number
if (fontStyleFrame->magic != 0xF09) {
LOG_ERROR(Lib_Font, "Magic not set");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
// Check if the weight effect is enabled (bit 2 in flags)
if (!(fontStyleFrame->flags & 0x04)) {
LOG_ERROR(Lib_Font, "Flag not set");
return ORBIS_FONT_ERROR_UNSET_PARAMETER;
}
@ -985,8 +993,39 @@ s32 PS4_SYSV_ABI sceFontStyleFrameGetResolutionDpi() {
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceFontStyleFrameGetScalePixel() {
LOG_ERROR(Lib_Font, "(STUBBED) called");
s32 PS4_SYSV_ABI sceFontStyleFrameGetScalePixel(OrbisFontStyleFrame* styleFrame, float* w,
float* h) {
if (!styleFrame) {
LOG_ERROR(Lib_Font, "Invalid Parameter");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
if (styleFrame->magic != 0xF09) {
LOG_ERROR(Lib_Font, "Invalid magic");
return ORBIS_FONT_ERROR_INVALID_PARAMETER;
}
if (!(styleFrame->flags & 0x01)) {
LOG_ERROR(Lib_Font, "Scaling effect parameter not set");
return ORBIS_FONT_ERROR_UNSET_PARAMETER;
}
// Check if scaling is allowed
int isScalingEnabled = styleFrame->scalingFlag;
if (w) {
*w = styleFrame->scaleWidth;
if (isScalingEnabled && styleFrame->dpiX) {
*w *= ((float)styleFrame->dpiX / 72.0f);
}
}
if (h) {
*h = styleFrame->scaleHeight;
if (isScalingEnabled && styleFrame->dpiY) {
*h *= ((float)styleFrame->dpiY / 72.0f);
}
}
return ORBIS_OK;
}

View File

@ -40,12 +40,17 @@ struct OrbisFontRenderSurface {
};
struct OrbisFontStyleFrame {
u16 magic; // Expected to be 0xF09
u16 flags;
//
float weightXScale; // 0x1c
float weightYScale; // 0x20
float slantRatio; // 0x24
/*0x00*/ u16 magic; // Expected to be 0xF09
/*0x02*/ u16 flags;
/*0x04*/ s32 dpiX; // DPI scaling factor for width
/*0x08*/ s32 dpiY; // DPI scaling factor for height
/*0x0c*/ s32 scalingFlag; // Indicates whether scaling is enabled
/*0x10*/
/*0x14*/ float scaleWidth; // Width scaling factor
/*0x18*/ float scaleHeight; // Height scaling factor
/*0x1c*/ float weightXScale;
/*0x20*/ float weightYScale;
/*0x24*/ float slantRatio;
};
s32 PS4_SYSV_ABI sceFontAttachDeviceCacheBuffer();
@ -220,7 +225,8 @@ s32 PS4_SYSV_ABI sceFontStyleFrameGetEffectWeight(OrbisFontStyleFrame* fontStyle
float* weightXScale, float* weightYScale,
uint32_t* mode);
s32 PS4_SYSV_ABI sceFontStyleFrameGetResolutionDpi();
s32 PS4_SYSV_ABI sceFontStyleFrameGetScalePixel();
s32 PS4_SYSV_ABI sceFontStyleFrameGetScalePixel(OrbisFontStyleFrame* styleFrame, float* w,
float* h);
s32 PS4_SYSV_ABI sceFontStyleFrameGetScalePoint();
s32 PS4_SYSV_ABI sceFontStyleFrameInit();
s32 PS4_SYSV_ABI sceFontStyleFrameSetEffectSlant();