libSceFont: scale layout metrics with font size and accept layout pointer in rdx (#1008)
sceFontGetHorizontalLayout returned fixed 16px-era values regardless of the scale set with sceFontSetScalePixel. Games that size their render surfaces from the reported baseline (Astro Bot) ended up with surfaces too short for the requested glyph size, so DrawGlyph cropped the bottom half of every character. The layout values now derive from the font's current pixel height, matching the ascent convention already used by glyph metrics and the rasterizer. Some callers pass the layout output pointer in rdx instead of rsi, which the stub read exclusively, causing an INVALID_ARGUMENT return and Astro Bot's own assert in FontSystem.cpp followed by the string being skipped entirely. Fall back to rdx before failing.
This commit is contained in:
parent
e007d43181
commit
8e1c6255b8
|
|
@ -148,13 +148,21 @@ public static class FontExports
|
|||
{
|
||||
var layoutAddress = ctx[CpuRegister.Rsi];
|
||||
if (layoutAddress == 0)
|
||||
{
|
||||
layoutAddress = ctx[CpuRegister.Rdx];
|
||||
}
|
||||
if (layoutAddress == 0)
|
||||
{
|
||||
return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
// Baseline, line advance, decoration extent: the same invented geometry
|
||||
// as GetRenderCharGlyphMetrics.
|
||||
var values = new[] { 12.0f, 16.0f, 0.0f };
|
||||
// Baseline, line advance, decoration extent: scaled to the font's
|
||||
// current pixel height, matching the ascent convention (height * 0.75)
|
||||
// used by glyph metrics and the rasterizer. A font never given a
|
||||
// scale falls back to the default height of 16, reproducing the
|
||||
// original fixed geometry.
|
||||
var fontHeight = GetFontHeight(ctx[CpuRegister.Rdi]);
|
||||
var values = new[] { fontHeight * 0.75f, (float)fontHeight, 0.0f };
|
||||
for (var index = 0; index < values.Length; index++)
|
||||
{
|
||||
if (!TryWriteUInt32(
|
||||
|
|
@ -178,6 +186,10 @@ public static class FontExports
|
|||
{
|
||||
var layoutAddress = ctx[CpuRegister.Rsi];
|
||||
if (layoutAddress == 0)
|
||||
{
|
||||
layoutAddress = ctx[CpuRegister.Rdx];
|
||||
}
|
||||
if (layoutAddress == 0)
|
||||
{
|
||||
return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
|
@ -185,7 +197,10 @@ public static class FontExports
|
|||
// Baseline (horizontal offset), line advance, decoration extent.
|
||||
// Mirrors the same three-float layout as GetHorizontalLayout, but
|
||||
// interpreted for vertical writing (e.g. CJK text rendered top-to-bottom).
|
||||
var values = new[] { 8.0f, 16.0f, 0.0f };
|
||||
// Scaled to the font's current pixel height; the default height of 16
|
||||
// reproduces the original fixed geometry.
|
||||
var fontHeight = GetFontHeight(ctx[CpuRegister.Rdi]);
|
||||
var values = new[] { fontHeight * 0.5f, (float)fontHeight, 0.0f };
|
||||
for (var index = 0; index < values.Length; index++)
|
||||
{
|
||||
if (!TryWriteUInt32(
|
||||
|
|
|
|||
Loading…
Reference in New Issue