mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-10 03:31:30 -06:00
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.
This commit is contained in:
parent
c3948bff95
commit
59785a020d