PS4 emulator for Windows,Linux,MacOS
Go to file
Valdis Bogdāns c5a809e50e
Fontlib (#3772)
* dummy fontlib libs

* register font libs

* typo fix

* added font error file

* added sceFontCharacterGetBidiLevel (from RE)

* fixup

* sceFontCharacterGetTextOrder , sceFontCharacterLooksFormatCharacters , sceFontCharacterLooksWhiteSpace RE

* sceFontCharacterRefersTextBack,sceFontCharacterRefersTextNext,sceFontRenderSurfaceInit,sceFontRenderSurfaceSetScissor  RE

* sceFontRenderSurfaceSetStyleFrame ,sceFontStyleFrameGetEffectSlant RE added

* clang fix

* sceFontStyleFrameGetEffectWeight

* added sceFontStyleFrameGetScalePixel

* Update types.h

* fixup merge

* Enhance font rendering and management system

- Integrated `stb_truetype` for advanced font rendering.
- Added support for external and system fonts with logging.
- Introduced new structures for glyphs, metrics, and kerning.
- Implemented functions for font state management and scaling.
- Improved glyph rendering, including subpixel and caching.
- Enhanced render surface initialization and scissor handling.
- Refactored stubbed functions with proper implementations.
- Added ABI compatibility checks for key structures.
- Improved logging, error handling, and code organization.
- Updated documentation and comments for better clarity.

* Fix for DC: font scale still inaccurate, cause unknown.

Refactor font library: streamline file handling, enhance layout caching, and improve scale computation.

* Remove unnecessary blank line in OrbisFontStyleFrame struct

* Loading font files from app0, some other fixes.

* restored accidentally deleted stubbs.

* Add system font path configuration and loading functionality

Config example:

[General]
...
sysFontPath = "/.../NotoSansJP-Regular.ttf"
...

* Handle missing system font by clearing font bytes and logging an error

* Remove unused <system_error> include from font.cpp

possible MacOS build crash reason.

* fontlib: refactor style frame API; config-driven system fonts

-Update style frame getters to take the frame explicitly:
--sceFontStyleFrameGetResolutionDpi(OrbisFontStyleFrame*, u32* h_dpi, u32* v_dpi)
--sceFontStyleFrameGetScalePixel(OrbisFontStyleFrame*, float* w, float* h)
--sceFontStyleFrameGetScalePoint(OrbisFontStyleFrame*, float* w, float* h)
-Ensure setters operate directly on the passed style frame (signatures unified):
--sceFontStyleFrameSetEffectSlant(OrbisFontStyleFrame*, float slantRatio)
--sceFontStyleFrameSetEffectWeight(OrbisFontStyleFrame*, float weightXScale, float weightYScale, u32 mode)
--sceFontStyleFrameSetResolutionDpi(OrbisFontStyleFrame*, u32 h_dpi, u32 v_dpi)
--sceFontStyleFrameSetScalePixel(OrbisFontStyleFrame*, float w, float h)
--sceFontStyleFrameSetScalePoint(OrbisFontStyleFrame*, float w, float h)
-Remove/streamline unused declarations from font.h to tighten the interface
-Call sites using style frame getters must pass an OrbisFontStyleFrame* now

Config: define system fonts path and default filename overrides

-Add [General].sysFontPath to set the base directory for system fonts
-Add [SystemFonts]:
--fallback = "SST-Roman.otf" (lowercase key) for the default face when no set is requested
--Per-font overrides using lowerCamelCase keys (start with fontSet...), e.g.:
---fontSetSstStdJapaneseJpArBold = "SSTJpPro-Bold.otf"
--Override values are filenames resolved under sysFontPath (paths are rejected and logged)
-Back-compat: still accept legacy SysFontPath and Fallback if present
-Logging: emit errors when sysFontPath is missing/invalid, fallback missing, or an override includes a path
-Configs should switch to sysFontPath and [SystemFonts].fallback with override keys

* font.cpp

Added full glyph tracking/outline plumbing plus mutex-protected generated-glyph tracking and helpers (BuildTrueOutline, true-outline extraction, glyf detection, system-font cache/fallback logic, etc.).
Swapped OTF defaults for several JP/JP_AR sets (and CJK sets used by Death Stranding / Anywhere VR) to SSTAribStdB24-Regular.ttf or other TTFs so we load glyf faces.
Wrapped every LOG_* call in INFO/DEBUG pairs: INFO just announces the call, DEBUG lists each parameter on its own line with an extra trailing newline; warnings/errors remain for validation/fallback.
Implemented TTF detection for cache loading and fallback with logging.
Renamed glyph param struct/members, moved glyph handle struct into the header, and renamed the glyph API parameters/fields accordingly.
font.h

Added the new glyph outline/glyph handle definitions and renamed OrbisFontGenerateGlyphParams members (id, res0, form_options, mem, res1/2).
Updated function prototypes to use the renamed types and pointers (e.g., sceFontGenerateCharGlyph signature now matches the new names).
fontft.cpp

Reworked sceFontSelectLibraryFt/sceFontSelectRendererFt logging to follow the same INFO/DEBUG pattern (INFO announces that selection is requested, DEBUG dumps all params).

* clang

* Scaling and font state

Removed env‑driven debug scaling (ScaleMode, GetScaleMode, GetScaleBias, SHADPS4_FONT_SCALE_*).
Added FontState::is_otf_cff and storing of external vmetrics (ext_ascent, ext_descent, ext_lineGap).
Introduced ComputeScaleExtPoint, ComputeScaleExtPixel, IsEmProfileExternalFont and ComputeScaleExtForState to choose ascender‑ vs EM‑based scaling per font (system fonts + CFF → ascender; selected TTF profiles → EM).
Updated callers (sceFontGetCharGlyphMetrics, glyph cache, layout, renderer, clones, scale setters) to use ComputeScaleExtForState instead of ComputeScale / ComputeScaleExt.
System font handling

Added ReportSystemFaceRequest helper to centralize “attach system font or log why not” and avoid repeating the logic at each call site.
Slightly adjusted when system_requested is set and how fallback/system attach errors are reported.
Horizontal layout

sceFontGetHorizontalLayout now logs invalid parameter/handle and, when an external face is present, uses that face’s vmetrics and the per‑state scale to compute baselineOffset and lineAdvance.
(Fallback still uses the simple scale_h‑based approximation.)
Glyph rendering (horizontal)

Reworked sceFontRenderCharGlyphImageHorizontal:
Resolves effective pixel scale from the attached style frame + point/pixel API via ResolveStyleFrameScale.
Uses ComputeScaleExtForState to compute scale_y (and derived scale_x), rather than a single global scale.
Always computes metrics from stbtt_GetCodepointHMetrics + GetCodepointBitmapBoxSubpixel, with metrics->h_bearing_* and h_adv in sync with those scales.
Introduces a clearer origin/gravity model:
System fonts: (x,y) treated as raw top‑left.
Certain external TTFs (EM‑profile) : (x,y) treated as baseline.
Other external fonts (CFF/point etc.): (x,y) treated as line‑top with baseline offset.
Validates surfaces more strictly and returns NO_SUPPORT_SURFACE when buffer/size/bpp are invalid; supports only 1‑bpp and 4‑bpp.
Uses a local glyph_bitmap and a straightforward blit with scissor/clipping, instead of the older mix of cached bitmaps/PUA logging.
Removed PUA/placeholder glyph debug tracing and the more ad‑hoc baseline “adjusted_y” heuristic.
Logging clean‑up

Standardized LOG_INFO/LOG_DEBUG in sceFont* functions:
Info: usually just "called" or a short description (“scale pixel set requested”, etc.).
Debug: "parameters:\n"/"result:\n"/"template state:\n" followed by values on separate lines.
LOG_ERROR messages no longer repeat the function name (logger already prints it); they now say "invalid parameter", "invalid font handle", "no support glyph (face/scale)", "no support surface (buffer)", etc.
Added missing error logs before some early returns (allocation failures, page_count == 0, invalid parameters), and upgraded a few previous LOG_DEBUG “invalid params” to LOG_ERROR where they correspond to an error return.

* Add internal font handling structures and layout computation functions

This commit introduces a new header file `fontft_internal.h` containing
various structures and functions for managing font handles, layout metrics,
and rendering operations. Key additions include:

- Definitions for `FontHandleOpenInfo`, `FontHandleStyleStateTail`,
  and `FontHandleOpaqueNative` to encapsulate font state and properties.
- Layout-related structures such as `HorizontalLayoutBlocks`,
  `VerticalLayoutBlocks`, and their respective I/O structures for
  managing layout metrics and effects.
- Functions for computing horizontal and vertical layout blocks,
  along with utility functions for handling layout words in byte format.
- Stubs for library functions related to font management and rendering.

These changes aim to enhance the font rendering capabilities of the
shadPS4 Emulator Project, providing a robust foundation for future
font-related features.

* Add FreeType submodule for GitHub CI workflows

* Refactor font rendering and path resolution logic to fix Metaphor: ReFantazio glyphs cropping and anywhereVR  "thin" glyphs.

- Updated RenderCodepointToSurface and RenderCodepointToSurfaceWithScale functions to set result->transImage to nullptr instead of result->stage.
- Modified font definitions to use updated font file names for various language sets.
- Introduced ResolveSystemFontPathCandidate function to streamline font path resolution, allowing for better handling of font directories.
- Enhanced LoadFontFile function to check for font files in "font" and "font2" directories based on the parent directory name.
- Improved error logging for font path overrides in ResolveSystemFontPath function.

* clang

* Update fontft_internal.cpp

typo fix

* Fix: fypo

* create sys_fonts in users folder and instructions.txt of what to put inside

* cut version of emulator settings to support custom sysfonts folder

* load settings

* cmakelist

* using new saving system but i can't understand the fallback mechanism

* removed lle versions

* Enhance error logging in font metrics functions and update comments for clarity

* Refactor font library functions and improve thread safety

- Updated function signatures in font.h to include the OrbisFontLib parameter for cache clearing and outline buffer management.
- Introduced a mutex in font_internal.cpp to ensure thread safety by protecting access to global font state and library state.
- Added a RemoveState function to safely remove font states.
- Enhanced memory allocation functions in fontft_internal.cpp to use Core::ExecuteGuest for better integration with the guest environment.
- Simplified font loading logic in LibraryOpenFontMemoryStub to improve readability and maintainability.
- Removed redundant code related to file opening and memory allocation, streamlining the font loading process.
This potentially fixes emulator crashes in games that use parallel font initialization, such as Dragon’s Crown.

* Add system font path and override config support

Introduce new config options for system font directory, fallback font name, and per-font overrides. Update config load/save logic to handle a [SystemFonts] TOML section, supporting both fallback and individual font overrides. Improve user instructions for custom font setup and clarify related code comments. These changes enhance flexibility and user experience for system font configuration.

* clang

* Add system font path management functions and refactor font directory retrieval

* Restored support for loading the libSceAudiodec system module

* Refactor font path handling and remove unused functions

* Fix include order for emulator settings and key manager (Clang)

* Remove unused emulator settings files and clean up includes in main and config files

* Remove unused instructions file creation from user paths initialization

* Consolidate internal font/ft internals

Move internal font structs, aliases, and helpers out of font.cpp into shared internal headers/sources.
Promote shared ABI-facing types (including FontHandleOpaqueNative and layout/system-use structs) into font internal headers and remove function-local duplicates.
Move FreeType driver/renderer table construction into fontft_internal.cpp and wire fontft.cpp to internal getters.
Ensure internal.cpp implementations are declared in headers; deduplicate declarations and clean includes.

* Refactor memory allocation and deallocation calls to remove Core::ExecuteGuest wrapper

* clang

* Add conditional linking for freetype library in shadps4 target

* Add new fixed-point arithmetic functions for font rendering

This commit introduces several new functions to handle fixed-point arithmetic operations, specifically for converting and scaling values related to font rendering. The added functions include:
- FixedMulUnitsToF26Dot6
- Cvttss2siCompat
- RoundMul16x16ToS32
- TruncFixed16x16ToInt
- RoundFixedMulValueScaleToS32
- TruncMulUnitsToS64
- RoundFixedMul16x16ToS64

These functions will enhance the precision and performance of font rendering calculations.

* Refactor: Replace Config usage with EmulatorSettings for font directory retrieval

* Sysmodule: Stop forcing HLE for font modules

* Add support for built-in font handling and fallback mechanisms

- Introduced a new structure `BuiltinFontBlob` to manage built-in font data.
- Implemented decompression functions for loading built-in fonts from compressed data.
- Added functions to resolve and load built-in fonts, including `LoadBuiltinFontBytesShared` and `IsBuiltinFontPath`.
- Enhanced `AttachSystemFont` to utilize built-in fonts as fallbacks when system fonts are unavailable.
- Implemented `AddBuiltinFallbackFaces` to add necessary fallback fonts based on font set types.
- Updated font selection logic to include Thai and symbol fonts in `ResolveSysFontCodepoint`.
- Modified `LibraryOpenFontMemoryStub` to handle loading built-in fonts directly from shared data.
- Added notifications for users when system fonts are not found, indicating fallback usage.
- Updated header files to declare new structures and functions related to built-in font handling.

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2026-06-10 15:57:11 +03:00
.ci Bump to Clang 19 (#2434) 2025-02-18 15:55:13 +02:00
.github Do not run CI again for every prerelease (#4540) 2026-06-07 16:09:43 +03:00
cmake Submodules updates (libusb,libressl,cpp-http,CLI11,openal) (#4428) 2026-05-15 17:06:33 +03:00
dist tagged 0.16.0 release 2026-06-01 18:47:16 +03:00
documents Refactoring of the nix file. (#4494) 2026-05-31 23:56:16 +03:00
externals Fontlib (#3772) 2026-06-10 15:57:11 +03:00
LICENSES audio: Accurate audio output timing. (#1986) 2024-12-31 12:38:52 +02:00
scripts Rewrite Save Data & Impl Save Data Dialog (#824) 2024-09-20 12:34:19 +03:00
src Fontlib (#3772) 2026-06-10 15:57:11 +03:00
tests Reset controller colours on emulator shutdown (#4537) 2026-06-08 00:39:50 +03:00
.gitignore Addition of Nix flake development shell (#4184) 2026-03-30 23:35:57 +03:00
.gitmodules Fontlib (#3772) 2026-06-10 15:57:11 +03:00
CMakeDarwinPresets.json Add CMake presets for macOS. (#3748) 2025-10-24 16:55:41 -07:00
CMakeLinuxPresets.json Specify compiler on linux preset (#3177) 2025-06-29 23:35:59 +02:00
CMakeLists.txt Fontlib (#3772) 2026-06-10 15:57:11 +03:00
CMakePresets.json Remove Qt from emulator (#3733) 2025-10-31 10:28:39 +02:00
CMakeSettings.json Remove Qt from emulator (#3733) 2025-10-31 10:28:39 +02:00
CMakeWindowsPresets.json Fix CMake presets for Linux (#3173) 2025-06-29 22:14:52 +02:00
CONTRIBUTING.md Fix typo in CONTRIBUTING.md comment 2024-08-23 18:29:00 -07:00
flake.lock Refactoring of the nix file. (#4494) 2026-05-31 23:56:16 +03:00
flake.nix Bump version from 0.15.1 to 0.16.1 (#4502) 2026-06-01 20:06:09 +03:00
LICENSE Initial commit 2022-10-24 12:48:38 +03:00
README.md Implement screenshot functionality with overlays and game-only options (#4248) 2026-04-12 17:41:01 +03:00
REUSE.toml Imgui: make imgui emulator settings accessible with hotkey (#4345) 2026-05-04 13:51:08 +03:00



shadPS4

Bloodborne by From Software Hatsune Miku Project DIVA Future Tone by SEGA
Bloodborne screenshot Project DIVA screenshot
Yakuza 0 by SEGA DRIVECLUB™ by Evolution Studios
Yakuza screenshot DRIVECLUB screenshot

General information

shadPS4 is an early PlayStation 4 emulator for Windows, Linux and macOS written in C++.

Important

This is the emulator core, which does not include a GUI. If you just want to use the emulator as an end user, download the QtLauncher instead.

If you encounter problems or have doubts, do not hesitate to look at the Quickstart.
To verify that a game works, you can look at shadPS4 Game Compatibility.
To discuss shadPS4 development, suggest ideas or to ask for help, join our Discord server.
To get the latest news, go to our X (Twitter) or our website.
You can donate to the project via our Kofi page.

Status

Important

shadPS4 is early in development, don't expect a flawless experience.

Currently, the emulator can successfully run games like Bloodborne, Dark Souls Remastered, Red Dead Redemption, and many other games.

Why

This project began for fun. Given our limited free time, it may take some time before shadPS4 can run more complex games, but we're committed to making small, regular updates.

Building

Docker

For building shadPS4 in a containerized environment using Docker and VSCode, check the instructions here:
Docker Build Instructions

Windows

Check the build instructions for Windows.

Linux

Check the build instructions for Linux.

macOS

Check the build instructions for macOS.

Important

macOS users need at least macOS 15.4 to run shadPS4. Due to GPU issues there are currently heavy bugs on Intel Macs.

Usage examples

Important

For a user-friendly GUI, download the QtLauncher.

To get the list of all available commands and also a more detailed description of what each command does, please refer to the --help flag's output.

Below is a list of commonly used command patterns:

shadPS4 CUSA00001 # Searches for a game folder called CUSA00001 in the list of game install folders, and boots it.
shadPS4 --fullscreen true --config-clean CUSA00001    # the game argument is always the last one,
shadPS4 -g CUSA00001 --fullscreen true --config-clean # ...unless manually specified otherwise.
shadPS4 /path/to/game.elf # Boots a PS4 ELF file directly. Useful if you want to boot an executable that is not named eboot.bin.
shadPS4 CUSA00001 -- -flag1 -flag2 # Passes '-flag1' and '-flag2' to the game executable in argv.

Debugging and reporting issues

For more information on how to test, debug and report issues with the emulator or games, read the Debugging documentation.

Keyboard and Mouse Mappings

Note

Some keyboards may also require you to hold the Fn key to use the F* keys. Mac users should use the Command key instead of Control, and need to use Command+F11 for full screen to avoid conflicting with system key bindings.

Button Function
F10 FPS Counter
Ctrl+F10 Video Debug Info
F11 Fullscreen
F12 Trigger RenderDoc Capture (or game-only screenshot if RenderDoc is unavailable)
Alt+F12 Capture screenshot including HUD/dialog overlays

Note

Xbox and DualShock controllers work out of the box.

Controller button Keyboard equivalent
LEFT AXIS UP W
LEFT AXIS DOWN S
LEFT AXIS LEFT A
LEFT AXIS RIGHT D
RIGHT AXIS UP I
RIGHT AXIS DOWN K
RIGHT AXIS LEFT J
RIGHT AXIS RIGHT L
TRIANGLE Numpad 8 or C
CIRCLE Numpad 6 or B
CROSS Numpad 2 or N
SQUARE Numpad 4 or V
PAD UP UP
PAD DOWN DOWN
PAD LEFT LEFT
PAD RIGHT RIGHT
OPTIONS RETURN
BACK BUTTON / TOUCH PAD SPACE
L1 Q
R1 U
L2 E
R2 O
L3 X
R3 M

Keyboard and mouse inputs can be customized in the settings menu by clicking the Controller button, and further details and help on controls are also found there. Custom bindings are saved per-game. Inputs support up to three keys per binding, mouse buttons, mouse movement mapped to joystick input, and more.

Firmware files

shadPS4 can load some PlayStation 4 firmware files. The following firmware modules are supported and must be placed in shadPS4's sys_modules folder.

Modules Modules Modules Modules
libSceAudiodec.sprx libSceCesCs.sprx libSceFont.sprx libSceFontFt.sprx
libSceFreeTypeOt.sprx libSceJpegDec.sprx libSceJpegEnc.sprx libSceJson.sprx
libSceJson2.sprx libSceLibcInternal.sprx libSceNgs2.sprx libScePngEnc.sprx
libSceRtc.sprx libSceSystemGesture.sprx libSceUlt.sprx

Caution

The above modules are required to run the games properly and must be dumped from your legally owned PlayStation 4 console.

Main team

Logo is done by Xphalnos

Contributing

If you want to contribute, please read the CONTRIBUTING.md file.
Open a PR and we'll check it :)

Special Thanks

A few noteworthy teams/projects who've helped us along the way are:

  • Panda3DS: A multiplatform 3DS emulator from our co-author wheremyfoodat. They have been incredibly helpful in understanding and solving problems that came up from natively executing the x64 code of PS4 binaries

  • fpPS4: The fpPS4 team has assisted massively with understanding some of the more complex parts of the PS4 operating system and libraries, by helping with reverse engineering work and research.

  • yuzu: Our shader compiler has been designed with yuzu's Hades compiler as a blueprint. This allowed us to focus on the challenges of emulating a modern AMD GPU while having a high-quality optimizing shader compiler implementation as a base.

  • felix86: A new x86-64 → RISC-V Linux userspace emulator

  • emudev.org: A network of people interested in the documentation, emulation, simulation and re-implementation of hardware near extinction . Belongs to my friend skmp and me (shadow) also a member of it

License