- 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.
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.
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.
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).
* Avoid storing the Tcb pointer on the stack
* Just return the already stored pointer in GetTcbBase
* Replace uses of GetTcbBase with g_curthread->tcb
* copyright 2025
* sir clang offnir, the all-formatting
* Earlier initialization of elf info.
Everything used for elf info initialization comes from the param.sfo, so we can initialize this earlier to have this information accessible during memory init.
* Extract compiled SDK version from pubtoolinfo string
Up until now, we've been using the game's reported "firmware version" as our compiled SDK version. This behavior is inaccurate, and is something that has come up in my hardware tests before.
For the actual compiled SDK version, we should use the SDK version in the PUBTOOLINFO string of the param.sfo, only falling back on the firmware version when that the sdk_ver component isn't present.
* Store compiled SDK version in ElfInfo
* Limit address space for compiled SDK version at or above FW 3
Sony placed a hard cap at 0xfc00000000, with a slight extension for stack mappings. For now, though stack mappings aren't implemented, there's no harm in keeping a slightly extended address space (since this cap is lower than our old user max).
Limiting the max through address space is necessary for Windows due to performance issues, in the future I plan to properly implement checks in memory manager code to properly handle this behavior for all platforms.
* Use compiled SDK version for sceKernelGetCompiledSdkVersion
I think this is pretty self explanatory.
* Log SDK version
Since this value is what most internal firmware version checks are against, logging the value will help with debugging.
* Update address_space.cpp
* Update emulator.cpp
* Backwards compatible logging
Because that's apparently an issue now
-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