Merge pull request #3138 from MarcZX100/codex/carry-font-script-3125
feat(font): retain script language and typographic design settings
This commit is contained in:
commit
2b5d119fc5
|
|
@ -7,6 +7,7 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
|
@ -28,6 +29,8 @@ struct FontState {
|
|||
FT_Face face = nullptr;
|
||||
float scaleW = 16.0f;
|
||||
float scaleH = 16.0f;
|
||||
std::map<int, int> scriptLanguages;
|
||||
std::map<int, int> typographicFeatures;
|
||||
|
||||
FontState() = default;
|
||||
FontState(const FontState&) = delete;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,30 @@ int ReadFontStyle(FontHandle fontHandle, bool checkMagic, Getter&& getter) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
template<typename Access>
|
||||
int AccessFontSettings(FontHandle fontHandle, Access&& access) {
|
||||
return ReadFontStyle(fontHandle, true, [&](FontHandleNative*) {
|
||||
FontState* state = TryGetState(fontHandle);
|
||||
return state ? access(*state) : SCE_FONT_ERROR_INVALID_FONT_HANDLE;
|
||||
});
|
||||
}
|
||||
|
||||
int SetFontSetting(FontHandle fontHandle, std::map<int, int> FontState::*table, int key, int value) {
|
||||
return AccessFontSettings(fontHandle, [&](FontState& state) {
|
||||
(state.*table)[key] = value;
|
||||
return SCE_FONT_OK;
|
||||
});
|
||||
}
|
||||
|
||||
int GetFontSetting(FontHandle fontHandle, std::map<int, int> FontState::*table, int key, int* value) {
|
||||
if (!value) return SCE_FONT_ERROR_INVALID_PARAMETER;
|
||||
return AccessFontSettings(fontHandle, [&](FontState& state) {
|
||||
const auto found = (state.*table).find(key);
|
||||
*value = found == (state.*table).end() ? 0 : found->second;
|
||||
return SCE_FONT_OK;
|
||||
});
|
||||
}
|
||||
|
||||
void ResetScaleOutputs(float* w, float* h) {
|
||||
if (w) *w = 0.0f;
|
||||
if (h) *h = 0.0f;
|
||||
|
|
@ -77,6 +101,22 @@ float ClampWeightDelta(float scale) {
|
|||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceFontSetScriptLanguage(FontHandle fontHandle, int fontScript, int fontLanguage) {
|
||||
return SetFontSetting(fontHandle, &FontState::scriptLanguages, fontScript, fontLanguage);
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetScriptLanguage(FontHandle fontHandle, int fontScript, int* fontLanguage) {
|
||||
return GetFontSetting(fontHandle, &FontState::scriptLanguages, fontScript, fontLanguage);
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontSetTypographicDesign(FontHandle fontHandle, int typographic, int feature) {
|
||||
return SetFontSetting(fontHandle, &FontState::typographicFeatures, typographic, feature);
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetTypographicDesign(FontHandle fontHandle, int typographic, int* feature) {
|
||||
return GetFontSetting(fontHandle, &FontState::typographicFeatures, typographic, feature);
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontSetScalePixel(FontHandle fontHandle, float w, float h) {
|
||||
return UpdateFontStyle(fontHandle, [&](FontHandleNative* font) {
|
||||
const int changed = StyleStateSetScalePixel(&font->style, w, h);
|
||||
|
|
|
|||
|
|
@ -88,16 +88,6 @@ int APS5_VABI sceFontGetGlyphExpandBufferState() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetScriptLanguage() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetTypographicDesign() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGlyphGetAttribute() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
|
|
@ -368,16 +358,6 @@ int APS5_VABI sceFontGraphicsUpdateShapeFillPlot() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontSetScriptLanguage() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontSetTypographicDesign() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontSupportGlyphs() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ int APS5_VABI sceFontSupportExternalFonts(FontLibrary, std::uint32_t, std::uint3
|
|||
int APS5_VABI sceFontOpenFontSet(FontLibrary, std::uint32_t, std::uint32_t, const FontOpenDetail*, FontHandle*);
|
||||
int APS5_VABI sceFontOpenFontMemory(FontLibrary, const void*, std::uint32_t, const FontOpenDetail*, FontHandle*);
|
||||
int APS5_VABI sceFontCloseFont(FontHandle);
|
||||
int APS5_VABI sceFontSetScriptLanguage(FontHandle, int, int);
|
||||
int APS5_VABI sceFontGetScriptLanguage(FontHandle, int, int*);
|
||||
int APS5_VABI sceFontSetTypographicDesign(FontHandle, int, int);
|
||||
int APS5_VABI sceFontGetTypographicDesign(FontHandle, int, int*);
|
||||
int APS5_VABI sceFontSetResolutionDpi(FontHandle, std::uint32_t, std::uint32_t);
|
||||
int APS5_VABI sceFontGetResolutionDpi(FontHandle, std::uint32_t*, std::uint32_t*);
|
||||
int APS5_VABI sceFontSetScalePixel(FontHandle, float, float);
|
||||
|
|
@ -203,6 +207,17 @@ int main() {
|
|||
|
||||
const std::vector<unsigned char> fontData = EmptyGlyphFont();
|
||||
Require(sceFontOpenFontMemory(library, fontData.data(), static_cast<std::uint32_t>(fontData.size()), nullptr, &font) == SCE_FONT_OK && font != nullptr);
|
||||
int setting = -1;
|
||||
Require(sceFontGetScriptLanguage(font, 3, &setting) == SCE_FONT_OK && setting == 0);
|
||||
Require(sceFontSetScriptLanguage(font, 3, 7) == SCE_FONT_OK && sceFontSetScriptLanguage(font, 4, 9) == SCE_FONT_OK);
|
||||
Require(sceFontGetScriptLanguage(font, 3, &setting) == SCE_FONT_OK && setting == 7);
|
||||
Require(sceFontGetScriptLanguage(font, 4, &setting) == SCE_FONT_OK && setting == 9);
|
||||
Require(sceFontGetScriptLanguage(font, 3, nullptr) == SCE_FONT_ERROR_INVALID_PARAMETER);
|
||||
Require(sceFontSetScriptLanguage(nullptr, 3, 7) == SCE_FONT_ERROR_INVALID_FONT_HANDLE);
|
||||
Require(sceFontSetTypographicDesign(font, 1, 2) == SCE_FONT_OK);
|
||||
Require(sceFontGetTypographicDesign(font, 1, &setting) == SCE_FONT_OK && setting == 2);
|
||||
Require(sceFontGetTypographicDesign(font, 5, &setting) == SCE_FONT_OK && setting == 0);
|
||||
Require(sceFontGetTypographicDesign(nullptr, 1, &setting) == SCE_FONT_ERROR_INVALID_FONT_HANDLE);
|
||||
std::uint32_t hDpi = 1;
|
||||
std::uint32_t vDpi = 1;
|
||||
Require(sceFontGetResolutionDpi(font, &hDpi, &vDpi) == SCE_FONT_OK && hDpi == 72 && vDpi == 72);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ Throughout the project, every function at every stage either **does exactly what
|
|||
|
||||
- [sceVideoOutGetOutputStatusWithVrr](../../core/libs/prx/libSceVideoOut/Unimplemented.cpp) (libSceVideoOut, NID `gWT7X8H0bYs`) - the name hashes to the imported NID. PPSA26344 version 02.002.000 passes a VideoOut handle and an output pointer at three call sites. It compares a 32-bit value at byte 4 with 2, tests bit 0x10 at byte 16, and, when set, compares low 16-bit values at bytes 48, 50 and 52 with 48, 60 and 120. The full output layout, size, field meanings and console errors are unknown. Every call throws without reading or writing caller memory.
|
||||
- [getuid, geteuid, getgid, getegid and issetugid](../../core/libs/prx/libkernel/System/src/Process.cpp) (libkernel) report the root identity (0) and a process that never changed credentials (`issetugid` 0), as a jailbroken process has; the host user and group are not exposed to the guest. The values a title sees on a console are unverified
|
||||
- [sceFontSetScriptLanguage, sceFontGetScriptLanguage, sceFontSetTypographicDesign, sceFontGetTypographicDesign](../../core/libs/prx/libSceFont/src/Style.cpp) (libSceFont) - signatures follow [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/main/src/SharpProspero/Interop/Font/SceFont.cs), not confirmed for the PS5. The handle keeps the language set for each script and the feature set for each typographic design and returns them, with 0 for one never set; the console default and its valid ranges are unknown, so any value is accepted. Neither setting changes shaping or rendering yet
|
||||
- [Packed pixel ancillary word](../../core/shader/recompiler/Optimization/src/ConstantFolder.cpp) (shader recompiler) - the sample index at bits 8-11 and the render target index at bits 16-28 follow #295, and their equality with the SampleId and Layer builtins is inferred, not measured. A value passed through a select, move or phi is rebuilt from those two fields with bits 0-7, 12-15 and 29-31 zero. That is exact only because every read of the word must be an extract inside one modelled field; any other read throws. The other bits are unmodelled and their RDNA 2 layout is unknown: the RDNA 3.5 ISA is reported to give prim type at bits 0-1, VRS rates at bits 2-5 and eye id at bit 7, which was not checked against RDNA 2
|
||||
- [sceAudioPropagationSourceSetAudioPath](../../core/libs/prx/libSceAudioPropagation/Export.cpp) (libSceAudioPropagation, NID `tKSmk2JsMAA`) - `(uint64_t path, const void* data, float gain)` follows [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Audio/AudioPropagation.cs) and SAROS's call, which passes a handle from `sceAudioPropagationSourceGetAudioPath`, path data and gain 1.0. Path updates are unsupported and every call throws without reading or writing caller memory. The no-propagation model yields no path handles; path allocation, ownership, rendering and console error codes remain unknown.
|
||||
- [Color comparison descriptor forms](../../core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp): emulated color comparison supports UNORM, SNORM and float formats for 2D, 2D-array and cube views. sRGB formats, anisotropic filters and bilinear cube comparisons without `DISABLE_CUBE_WRAP` are refused; cube-edge sampling behavior and console coverage on PS5's gfx1013 remain unverified.
|
||||
|
|
|
|||
Loading…
Reference in New Issue