-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fontlib #3772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fontlib #3772
Conversation
…, sceFontCharacterLooksWhiteSpace RE
…RenderSurfaceInit,sceFontRenderSurfaceSetScissor RE
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).
|
It must fix Death Stranding. @georgemoralis, please review it. Do not forget to use sys_fonts. |
it is working :D |
|
Nice! |
|
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? |
|
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 |
|
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. |
|
But, on the other hand, we can always return to the state we are in now. |
i think @StevenMiller123 managed to run games that have embedded fonts that aren't working with LLE either |
|
Yeah, LLE font libs don't show fonts at all in titles like DIGIMON STORY CYBER SLEUTH (which uses embedded fonts). |
|
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. |
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.
|
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. |
You did mention RE-ing this with Ghidra, so I assume the difference isn't due to a logic change in SDK versions? |
|
@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: |
|
I'm against applying game-specific hacks. |
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. |
Ok, I am working on it. Maybe on next commit. |
|
anywhereVR fonts now render properly (along with the rest of the game, guess recent GPU fixes helped it too) |
|
DRIVECLUB fonts are broken. |
|
@w1naenator any update? |
In progress. But I am very busy now at work. |











No description provided.