Skip to content

Conversation

@w1naenator
Copy link
Contributor

No description provided.

w1naenator and others added 4 commits November 22, 2025 01:14
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).
@w1naenator
Copy link
Contributor Author

It must fix Death Stranding. @georgemoralis, please review it. Do not forget to use sys_fonts.

@georgemoralis
Copy link
Collaborator

εικόνα εικόνα εικόνα

it is working :D
shad_log.txt

@w1naenator
Copy link
Contributor Author

Nice!

@w1naenator
Copy link
Contributor Author

I need as many logs as possible from games that use the font library. Maybe ask people in Discord to set the log filter to “*:Critical Lib.Font:Trace Lib.FontFt:Trace” and then go through all the games and send the logs?

@georgemoralis
Copy link
Collaborator

as known , ppl doesn't test if it isn't in main . I would suggest to clean it up if needed and we can merge for further testing . Since it is already working better than LLE i think we won't fall into major issues :D

@w1naenator
Copy link
Contributor Author

w1naenator commented Nov 23, 2025

HLE currently has the advantage that it can load games which request system fonts, while LLE cannot. However, games that use their own embedded fonts still render glyphs inaccurately. Because of this, I think it should be merged into main only if support for loading the original font library modules. It also needed for me to compare result.

@w1naenator
Copy link
Contributor Author

But, on the other hand, we can always return to the state we are in now.

@georgemoralis
Copy link
Collaborator

HLE currently has the advantage that it can load games which request system fonts, while LLE cannot. However, games that use their own embedded fonts still render glyphs inaccurately. Because of this, I think it should be merged into main only if support for loading the original font library modules. It also needed for me to compare result.

i think @StevenMiller123 managed to run games that have embedded fonts that aren't working with LLE either

@StevenMiller123
Copy link
Collaborator

Yeah, LLE font libs don't show fonts at all in titles like DIGIMON STORY CYBER SLEUTH (which uses embedded fonts).
From what I know, there are a variety of issues breaking the LLEs. Even if this PR isn't perfect, it's far better than running broken LLE modules in my opinion.

@w1naenator
Copy link
Contributor Author

I plan to rebuild sceFontGlyphRenderImageHorizontal() to resolve issues with text positioning and incorrect visual output. The current implementation has become unnecessarily complex due to repeated attempts to achieve the desired result.

w1naenator and others added 2 commits November 24, 2025 22:05
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.
@w1naenator
Copy link
Contributor Author

After spending several hours with Ghidra, the FreeType manuals, and the FreeType source code, I fully recreated sceFontRenderCharGlyphImageHorizontal. It should now render more precise glyphs in most games. There are still some irregularities with Driveclub’s font scaling; for the moment, I applied a per-game workaround because I cannot determine why its scaling differs from other titles. I now need as many logs as possible to gain further insight. Logging has been prepared to extract the required data from game requests.

@kalaposfos13
Copy link
Member

There are still some irregularities with Driveclub’s font scaling; for the moment, I applied a per-game workaround because I cannot determine why its scaling differs from other titles.

You did mention RE-ing this with Ghidra, so I assume the difference isn't due to a logic change in SDK versions?

@w1naenator
Copy link
Contributor Author

@georgemoralis, @StevenMiller123, please test it with the titles you own. I need all logs; if you encounter any issues, please also include the required screenshots and a clear problem description. If possible, use the following log filter:
*:Critical Loader:Trace Lib.Font:Trace Lib.FontFt:Trace

@StevenMiller123
Copy link
Collaborator

I'm against applying game-specific hacks.
I'll do my testing in a moment with the requested log filters. As a reminder, Trace logs will only appear on debug compiles of shadPS4. I'll compile this locally to test, but others may not be equipped for that.

@w1naenator
Copy link
Contributor Author

There are still some irregularities with Driveclub’s font scaling; for the moment, I applied a per-game workaround because I cannot determine why its scaling differs from other titles.

You did mention RE-ing this with Ghidra, so I assume the difference isn't due to a logic change in SDK versions?

My first implementation of this function was heavily simplified. At that point I had not yet gone deep into reverse-engineering the original code, so most of the logic was written by myself in a very simplified form. Because of that, it didn’t accurately represent the real behaviour seen in the SDK libraries.

@w1naenator
Copy link
Contributor Author

I'm against applying game-specific hacks. I'll do my testing in a moment with the requested log filters. As a reminder, Trace logs will only appear on debug compiles of shadPS4. I'll compile this locally to test, but others may not be equipped for that.

Ok, I am working on it. Maybe on next commit.

@StevenMiller123
Copy link
Collaborator

anywhereVR fonts now render properly (along with the rest of the game, guess recent GPU fixes helped it too)
image
image
image
CUSA08643.log

@StevenMiller123
Copy link
Collaborator

DRIVECLUB fonts are broken.
image
CUSA00093.zip

@StevenMiller123
Copy link
Collaborator

DIGIMON STORY CYBER SLEUTH fonts are still too small.
image

CUSA02966.log

@georgemoralis
Copy link
Collaborator

DIGIMON STORY CYBER SLEUTH fonts are still too small. image

CUSA02966.log

you got the original for reference ? size seems not bad for me

@StevenMiller123
Copy link
Collaborator

Can't test this one right now, but psOff has working font LLE, so here a reference from there.
17646777163043681673365169942275
Here's an old (but should still be accurate) screenshot from this PR in the same page.
17646778378165683966229105084369

Not the perfect comparison, I'm not able to test this PR at all anymore though.

@georgemoralis
Copy link
Collaborator

@w1naenator any update?

@w1naenator
Copy link
Contributor Author

@w1naenator any update?

In progress. But I am very busy now at work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants