Commit Graph
29 Commits
Author SHA1 Message Date
James0124andClaude Opus 5 8afa18c21c sceFont: match hardware's glyph blending and destination combine
sceFontGetCharGlyphImage_Clip stored the glyph over the destination buffer.
Hardware adds it with saturation instead, so on hardware a glyph never erases
what was already in the buffer - the transparent parts contribute zero - while
we cleared them to 0. Text drawn as overlapping glyphs lost the earlier ones.

Measured on a PSP-1000 against a dumped ltn0.pgf, sweeping the pen position's
fractional part, both 4bpp and 8bpp, and several destination pre-fill values so
that "wrote a 0 here" could be told apart from "did not write here":

- The result is min(dst + blend, max), not blend.
- The two horizontal weights are rounded in opposite directions, down for the
  left neighbour and up for the pixel itself. That is not a free choice: it is
  what makes the pair sum to exactly the format's full scale whenever both
  samples are full ink, for every fraction. Rounding the combined sum once, as
  before, disagrees with hardware on about a fifth of the blended pixels.
- 4bpp blends the raw nibble and 8bpp the value swizzled to 8 bit. Blending at
  8 bit and narrowing afterwards is not the same thing and misses ~0.6%.
- The fractional part of yPos64 is discarded entirely. There is no vertical
  blending and the rectangle never grows downwards, so renderY2 loses its +1
  and the two render loops collapse into one - xFrac == 0 needs no special
  case, the first term vanishes and the second collapses to exactly b.

Only PSP_FONT_PIXELFORMAT_4 and _8 render at all. _4_REV, _24 and _32 return 0
and leave the buffer completely untouched, which is also the answer to the
"not sure how to make these produce an image" note in pspautotests'
charglyphimageclip.cpp. They are skipped now, with a report so that a game
relying on them can be found - only one buffer configuration was measured.

Verified with pspautotests: the new charglyphimagexfrac goes from 388 of 601
differing lines to passing, and charglyphimage and charglyphimageclip improve
from 57 differing lines to 3. No other font test changes. The remaining 3 are
a separate, pre-existing issue with bytesPerLine of 0 and 1.

Not covered: clip rectangles that actually clip, negative pen positions, and
the shadow glyph entry points.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-10 19:49:55 +09:00
Henrik Rydgård 5117ded378 Remove ELOG/ILOG/WLOG from the Android C++ code (mostly) 2020-08-15 19:08:39 +02:00
Unknown W. Brackets 1860180c2e Font: Implement subpixel rendering. 2016-01-23 15:37:19 -08:00
Unknown W. Brackets d65af7353b Avoid some ChunkFile includes. 2014-03-15 11:32:57 -07:00
lioncash b9886942a7 Fix some vertical alignments in misc Core source files. 2014-03-03 11:16:53 -05:00
Unknown W. Brackets 131cbc073c Implement sceFontGetShadowInfo(). 2014-03-01 00:18:19 -08:00
Unknown W. Brackets 29d2e81676 Cleanup errors in sceFontGet*ImageRect(). 2014-02-28 23:04:34 -08:00
Unknown W. Brackets ab6b998710 Correct clipping in sceFontGetCharGlyphImage_Clip.
It was not clipping completely, and didn't handle negative clip w/h.
Also, reduce to debug log (seems to work fine now and has been working
fine in most games.)
2014-02-27 00:19:40 -08:00
Unknown W. Brackets 603c1dd614 Improve error codes in sceFontOpen*().
Fixes some unlikely cases of crashes as well.  I think there are leaks
here...
2014-02-22 20:35:58 -08:00
Unknown W. Brackets 916768d938 Kill the "packagedFont" hack, correctly fixed now. 2013-12-10 23:19:25 -08:00
Unknown W. Brackets 0bd7d7ad19 Minor correctness: don't zero extend bpp bits. 2013-11-16 23:39:19 -08:00
Unknown W. Brackets 8f6315e375 Support replacement chars in sceFontGetCharInfo(). 2013-11-16 23:32:13 -08:00
Unknown W. Brackets d955d9b303 Cut down on unnecessary allocs in font loading. 2013-11-16 22:53:05 -08:00
Unknown W. Brackets 769ffbd33b Read in the shadow flags and give them to the game.
Yay, now this struct seems to match the PSP.
2013-11-16 21:08:34 -08:00
Unknown W. Brackets e77b8bc5b5 Check for non-indexed glyph advance values.
This change from JPCSP:
http://code.google.com/p/jpcsp/source/detail?r=3350
2013-11-16 18:35:15 -08:00
Unknown W. Brackets 2d7741a433 Return # of glyphs, not charmaps, in font info.
This makes it match the value from the PSP, and seems logical (the charmap
value is hardly useful, and might lead me to overallocate space for the
glyph bitmaps...)
2013-11-16 18:33:10 -08:00
raven02 98cbd90178 Regression font alignment fix 2013-11-02 20:31:39 +08:00
raven02 92042e6b55 Apply offset by 1px to our provided PSP fonts 2013-10-27 10:02:13 +08:00
CPkmn 2a5b20a5a0 Update PGF.h 2013-08-13 05:59:10 -07:00
Unknown W. Brackets 0b5bdeb1d3 Fix some compile failures under big endian. 2013-07-28 21:04:17 -07:00
Unknown W. Brackets 8da6259aff More carefully check defines for endianness. 2013-07-25 22:25:50 -07:00
Henrik Rydgard 1533b588e3 Argh, this really shouldn't be needed but is. 2013-07-26 01:18:40 +02:00
Henrik Rydgard b3ea250122 typo 2013-07-26 00:57:29 +02:00
Henrik Rydgard 144a5849e2 Uhm, fix the second part of the BIG_ENDIAN #define error... 2013-07-26 00:54:39 +02:00
Henrik Rydgård 9fc57894ab Mac build fix (weird, BIG_ENDIAN really shouldn't be defined) 2013-07-25 19:21:43 +02:00
Unknown W. Brackets 5e87d6e45d Add _le typedefs to font handling stuff. 2013-07-25 08:04:36 -07:00
Unknown W. Brackets 95823a776b Don't pass quite so many args to DrawCharacter(). 2013-05-05 21:13:50 -07:00
Unknown W. Brackets 339b2839b3 Finish implementing savestates for fonts.
Oops, missed this before.  Was crashing FF3 and games using custom fonts.
2013-03-20 23:37:57 -07:00
Henrik Rydgard ba0362d817 PGF font support. Mostly an adaptation and cleanup of JPCSP's font system. 2013-02-27 17:41:39 +01:00