Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions core/libs/prx/libSceFont/src/Style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,21 @@ int APS5_VABI sceFontGetRenderEffectSlant(FontHandle fontHandle, float* slantRat
}

int APS5_VABI sceFontGetRenderEffectWeight(FontHandle fontHandle, float* weightXScale, float* weightYScale, std::uint32_t* mode) {
const int rc = ReadRenderStyle(fontHandle, true, [&](FontHandleNative* font) { return StyleStateGetWeightScale(&font->cached_style.state, weightXScale, weightYScale, mode); });
if (rc != SCE_FONT_OK) ResetWeightOutputs(weightXScale, weightYScale, mode);
return rc;
float localX = 1.0f;
float localY = 1.0f;
std::uint32_t localMode = 0;
const int rc = ReadRenderStyle(fontHandle, true, [&](FontHandleNative* font) {
if (!weightXScale && !weightYScale && !mode) return SCE_FONT_ERROR_INVALID_PARAMETER;
return StyleStateGetWeightScale(&font->cached_style.state, weightXScale ? &localX : nullptr, weightYScale ? &localY : nullptr, mode ? &localMode : nullptr);
});
if (rc != SCE_FONT_OK) {
ResetWeightOutputs(weightXScale, weightYScale, mode);
return rc;
}
if (weightXScale && !CopyOutGuest(weightXScale, localX)) return SCE_FONT_ERROR_INVALID_PARAMETER;
if (weightYScale && !CopyOutGuest(weightYScale, localY)) return SCE_FONT_ERROR_INVALID_PARAMETER;
if (mode && !CopyOutGuest(mode, localMode)) return SCE_FONT_ERROR_INVALID_PARAMETER;
return SCE_FONT_OK;
}

int APS5_VABI sceFontStyleFrameInit(FontStyleFrame* styleFrame) {
Expand Down
11 changes: 11 additions & 0 deletions core/libs/tests/GuestFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,17 @@ static void CheckRenderEffects(FontHandle font, FontRenderer renderer) {
Require(sceFontSetupRenderEffectWeight(font, 1.02f, 0.98f, 1) == SCE_FONT_ERROR_INVALID_PARAMETER);
Require(sceFontSetupRenderEffectWeight(font, 1.02f, 0.98f, 0) == SCE_FONT_OK);
Require(sceFontGetRenderEffectWeight(font, &weightX, &weightY, &mode) == SCE_FONT_OK && approximately(weightX, 1.02f) && approximately(weightY, 0.98f) && mode == 0);
Require(sceFontGetRenderEffectWeight(nullptr, reinterpret_cast<float*>(0x10), nullptr, nullptr) == SCE_FONT_ERROR_INVALID_FONT_HANDLE);
Require(sceFontGetRenderEffectWeight(font, nullptr, nullptr, nullptr) == SCE_FONT_ERROR_INVALID_PARAMETER);
errno = 71;
Require(sceFontGetRenderEffectWeight(font, reinterpret_cast<float*>(0x10), &weightY, &mode) == SCE_FONT_ERROR_INVALID_PARAMETER);
Require(errno == 71);
errno = 71;
Require(sceFontGetRenderEffectWeight(font, &weightX, reinterpret_cast<float*>(0x10), &mode) == SCE_FONT_ERROR_INVALID_PARAMETER);
Require(errno == 71);
errno = 71;
Require(sceFontGetRenderEffectWeight(font, &weightX, &weightY, reinterpret_cast<std::uint32_t*>(0x10)) == SCE_FONT_ERROR_INVALID_PARAMETER);
Require(errno == 71);
Require(sceFontSetupRenderEffectWeight(font, 1.5f, 0.5f, 0) == SCE_FONT_OK);
Require(sceFontGetRenderEffectWeight(font, &weightX, &weightY, nullptr) == SCE_FONT_OK && approximately(weightX, 1.04f) && approximately(weightY, 0.96f));
Require(sceFontSetupRenderEffectSlant(nullptr, 0.0f) == SCE_FONT_ERROR_INVALID_FONT_HANDLE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# libSceFont

## add Functional

- [sceFontGetRenderEffectWeight guest output](../../../core/libs/prx/libSceFont/src/Style.cpp) (libSceFont) - returning SCE_FONT_ERROR_INVALID_PARAMETER with caller errno preserved for unwritable weight or mode pointers via GuestCopyOut_nid_no_patch is a host-safety fallback; whether the console faults or returns an argument error on unmapped memory is unmeasured.
Loading