feat(font): implement sceFontGetPixelResolution
Report the sub-pixel resolution of the library's driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e7bf72d503
commit
c0d293ff7b
|
|
@ -297,6 +297,15 @@ int APS5_VABI sceFontRendererSetOutlineBufferPolicy(FontRenderer fontRenderer, s
|
|||
return SCE_FONT_OK;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetPixelResolution(FontLibrary library, std::uint32_t* subPixelCount) {
|
||||
if (!subPixelCount) return SCE_FONT_ERROR_INVALID_PARAMETER;
|
||||
*subPixelCount = 0;
|
||||
const auto* lib = static_cast<const FontLibNative*>(library);
|
||||
if (!lib || lib->magic != LIBRARY_MAGIC || !lib->sys_driver || !lib->sys_driver->pixel_resolution) return SCE_FONT_ERROR_INVALID_LIBRARY;
|
||||
*subPixelCount = lib->sys_driver->pixel_resolution();
|
||||
return SCE_FONT_OK;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontAttachDeviceCacheBuffer(FontLibrary library, void* buffer, std::uint32_t size) {
|
||||
auto* lib = static_cast<FontLibNative*>(library);
|
||||
if (!lib || lib->magic != LIBRARY_MAGIC) return SCE_FONT_ERROR_INVALID_LIBRARY;
|
||||
|
|
|
|||
|
|
@ -117,11 +117,6 @@ int APS5_VABI sceFontGetGlyphExpandBufferState() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetPixelResolution() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceFontGetScriptLanguage() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "prx/libSceFont/include/FontTypes.hpp"
|
||||
#include "prx/libSceFont/include/FontDriver.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
|
@ -15,6 +15,7 @@ int APS5_VABI sceFontCreateLibrary(const FontMemory*, const void*, FontLibrary*)
|
|||
int APS5_VABI sceFontDestroyLibrary(FontLibrary*);
|
||||
int APS5_VABI sceFontCreateRenderer(const FontMemory*, const void*, FontRenderer*);
|
||||
int APS5_VABI sceFontDestroyRenderer(FontRenderer*);
|
||||
int APS5_VABI sceFontGetPixelResolution(FontLibrary, std::uint32_t*);
|
||||
int APS5_VABI sceFontSupportSystemFonts(FontLibrary);
|
||||
int APS5_VABI sceFontSupportExternalFonts(FontLibrary, std::uint32_t, std::uint32_t);
|
||||
int APS5_VABI sceFontOpenFontSet(FontLibrary, std::uint32_t, std::uint32_t, const FontOpenDetail*, FontHandle*);
|
||||
|
|
@ -51,6 +52,10 @@ static void APS5_VABI Release(void*, void* pointer) {
|
|||
std::free(pointer);
|
||||
}
|
||||
|
||||
static std::uint32_t APS5_VABI CoarsePixelResolution() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
static void Put16(std::vector<unsigned char>& out, int value) {
|
||||
out.push_back(static_cast<unsigned char>((value >> 8) & 0xFF));
|
||||
out.push_back(static_cast<unsigned char>(value & 0xFF));
|
||||
|
|
@ -114,6 +119,25 @@ int main() {
|
|||
Require(sceFontCreateLibrary(&memory, nullptr, &library) == SCE_FONT_ERROR_INVALID_PARAMETER && library == nullptr);
|
||||
Require(sceFontCreateLibrary(&memory, sceFontSelectLibraryFt(0), &library) == SCE_FONT_OK && library != nullptr);
|
||||
|
||||
std::uint32_t subPixelCount = 1;
|
||||
Require(sceFontGetPixelResolution(library, &subPixelCount) == SCE_FONT_OK && subPixelCount == 64);
|
||||
Require(sceFontGetPixelResolution(library, nullptr) == SCE_FONT_ERROR_INVALID_PARAMETER);
|
||||
Require(sceFontGetPixelResolution(nullptr, nullptr) == SCE_FONT_ERROR_INVALID_PARAMETER);
|
||||
subPixelCount = 1;
|
||||
Require(sceFontGetPixelResolution(nullptr, &subPixelCount) == SCE_FONT_ERROR_INVALID_LIBRARY && subPixelCount == 0);
|
||||
FontHandleOpaque notALibrary{};
|
||||
subPixelCount = 1;
|
||||
Require(sceFontGetPixelResolution(¬ALibrary, &subPixelCount) == SCE_FONT_ERROR_INVALID_LIBRARY && subPixelCount == 0);
|
||||
Font::SysDriver coarseDriver = *static_cast<const Font::SysDriver*>(sceFontSelectLibraryFt(0));
|
||||
coarseDriver.pixel_resolution = CoarsePixelResolution;
|
||||
FontLibrary coarseLibrary = nullptr;
|
||||
Require(sceFontCreateLibrary(&memory, &coarseDriver, &coarseLibrary) == SCE_FONT_OK && coarseLibrary != nullptr);
|
||||
Require(sceFontGetPixelResolution(coarseLibrary, &subPixelCount) == SCE_FONT_OK && subPixelCount == 16);
|
||||
Require(sceFontGetPixelResolution(library, &subPixelCount) == SCE_FONT_OK && subPixelCount == 64);
|
||||
coarseDriver.pixel_resolution = nullptr;
|
||||
Require(sceFontGetPixelResolution(coarseLibrary, &subPixelCount) == SCE_FONT_ERROR_INVALID_LIBRARY && subPixelCount == 0);
|
||||
Require(sceFontDestroyLibrary(&coarseLibrary) == SCE_FONT_OK && coarseLibrary == nullptr);
|
||||
|
||||
FontHandle font = reinterpret_cast<FontHandle>(&memory);
|
||||
Require(sceFontOpenFontSet(library, SystemFontSet, 1, nullptr, &font) == SCE_FONT_ERROR_NO_SUPPORT_FUNCTION && font == nullptr);
|
||||
Require(sceFontSupportSystemFonts(library) == SCE_FONT_OK);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ Throughout the project, every function at every stage either **does exactly what
|
|||
- [AMPR WriteAddressFromCounterPairOnCompletion](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - the pair of an even counter n is assumed to give counter n in the low 32 bits and n + 1 in the high 32 bits. Wait compare values, wait flush and counter index ranges follow the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation; the flush is accepted and has no effect, as commands run in order
|
||||
- [AMPR markers](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - signatures taken from the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation, not confirmed on a title: `sceAmprCommandBufferSetMarkerWithColor` takes the color by pointer, the push and measure variants by value. Colors are not recorded
|
||||
- [sceFontGetRenderScaledKerning](../../core/libs/prx/libSceFont/src/Render.cpp) (libSceFont) - arguments, the cleared output and the bound renderer check taken from `cellFontGetRenderScaledKerning` in [RPCS3](https://github.com/RPCS3/rpcs3/blob/master/rpcs3/Emu/Cell/Modules/cellFont.cpp) (PS3 predecessor of the library), not confirmed on a title. The kerning is the `sceFontGetKerning` one at the render scale
|
||||
- [sceFontGetPixelResolution](../../core/libs/prx/libSceFont/src/Library.cpp) (libSceFont) - signature taken from the IDA type database of [Orbital](https://github.com/AlexAltea/orbital/blob/master/tools/ida/db_types.json), not confirmed on a title. The value is the one the library's driver reports (64 for FreeType); the argument checks and the cleared output follow `sceFontGetLibrary`
|
||||
- [sceAgcSetSubmitMode](../../core/libs/prx/libSceAgc/Misc/src/Suspend.cpp) (libSceAgc) - mode values unknown; only 0 is accepted
|
||||
- [zARR5aCmkoY](../../core/libs/prx/libSceAgc/DcbFlow/src/Control.cpp) (libSceAgc) - unknown name, signature
|
||||
- [qj7QZpgr9Uw](../../core/libs/prx/libSceAgc/DcbState/src/ContextState.cpp) (libSceAgc) - unknown name
|
||||
|
|
|
|||
Loading…
Reference in New Issue