Commit graph

238 commits

Author SHA1 Message Date
Filippos Karapetis
4e7752b923 GRAPHICS: Use C++ 11 range-based for loops 2025-03-27 13:47:57 +08:00
Eugene Sandulenko
ab68b92df5
GRAPHICS: FONTS: Load DPI information from WinFonts 2025-03-02 00:25:33 +01:00
tunnelsociety
b792ba090d GRAPHICS: Handle seek-only case in TTFLibrary readCallback
As documented in FreeType API Reference. This avoids passing
a null buffer to ttfFile->read().
2024-12-19 22:51:20 +02:00
sluicebox
b4f8be5174 GRAPHICS: Fix memory leak in WinFont when reloading
Occurs during Hugo 1 introduction
2024-09-18 12:41:01 -07:00
sluicebox
cd755fc663 GRAPHICS: Fix memory leak in TTF font 2024-08-25 12:26:47 -07:00
Cameron Cawley
7e0dfe0081 GRAPHICS: Use custom stream callbacks for loading TTF fonts 2024-07-23 15:33:43 +01:00
Cameron Cawley
1357bfe672 COMMON: Avoid including engine headers in common code for DebugChannelDef 2024-06-20 20:15:57 +01:00
Cameron Cawley
f3fbd2477c GRAPHICS: Allow specifying separate xdpi and ydpi values in loadTTFFont 2024-01-08 23:41:50 +01:00
Le Philousophe
226de788c8 GRAPHICS: Make API use the Path class 2023-12-24 13:19:25 +01:00
Le Philousophe
802c91554f COMMON: Make extrapath a Path object 2023-12-24 13:19:25 +01:00
Matthew Duggan
0b4aa788ff GRAPHICS: Correct cleanup loop on BDF load failure
Identified by xcode analysis, the cleanup code would have crashed before as it
was using the wrong loop variable.
2023-12-10 10:04:30 +11:00
Eugene Sandulenko
b7fd4cb8af
GRAPHICS: Fix crash while trying fonts-cjk.dat 2023-12-09 15:33:16 +01:00
Eugene Sandulenko
0e18527d36
GRAPHICS: Use fonts-cjk.dat for loading path 2023-11-20 20:59:17 +01:00
Torbjörn Andersson
53d149b45b GRAPHICS: Make Mac font rendering more like the original
By applying italics before outline, not after, and slanting italics
characters from the bottom up instead of top down, I now get pixel
perfect rendering for my experimental About dialogs for Loom and Indiana
Jones and the Last Crusade.
2023-11-18 18:47:39 +01:00
Torbjörn Andersson
16ac86cdeb GRAPHICS: Calculate bitmapOffset correctly. Again.
Add, don't set, the extra bitmap offset for italics to keep glyphs from
overlapping in memory.
2023-11-18 18:47:39 +01:00
Torbjörn Andersson
e5e5f049be GRAPHICS: Implement kMacFontCondense and kMacFontExtend
Judging by the experiments I made in a Mac emulator, condensed and
extended slant simply decreases and increases the glyph width by one.
You'd think it would depend on the font size, but apparently not. It is
possible to use both condensed and extended slant at the same time, and
it's just as useless as it sounds.
2023-10-16 17:40:29 +02:00
Torbjörn Andersson
3e0a726cb4 GRAPHICS: Calculate bitmapOffset correctly
We have to take into consideration that text can use any combination of
slants. Otherwise, glyphs may spill into memory used for other glyphs.
This was probably only an issue when the glyph storage crossed the
boundary from one byte length into another.
2023-10-16 17:40:29 +02:00
Torbjörn Andersson
789f2dfaf1 GRAPHICS: Make sure outline glyphs aren't cropped on the left side
This will offset all outlined glyphs one pixel to the right. I hope that
doesn't cause issues elsewhere.
2023-10-16 17:40:29 +02:00
Torbjörn Andersson
5009bb67e4 GRAPHICS: Fix bold text to be more (hopefully exeactly) like the original
QuickDraw appears to simply draw the character once normally and once
shifted one pixel to the right. This was perhaps most noticeable on
small characters with lots of edges. (I noticed it first on "W" in
Geneva 9.)
2023-10-16 17:40:29 +02:00
Torbjörn Andersson
e22310c2ad GRAPHICS: Fix building with DEBUGSCALING 2023-10-16 17:40:29 +02:00
D G Turner
dcf3bf3a1d GRAPHICS: Fix GCC Compiler Warnings on Realloc Usage in Freetype Interface
Calling realloc() with a size of 0 is implementation dependent and thus
should be avoided for portability.
2023-09-04 14:31:34 +01:00
Walter Agazzi
1856e56202 GRAPHICS: Add Init/Done_FreeType_With_Mem to common freetype
These are needed for the new alfont implementation in AGS
2023-09-03 22:27:43 +02:00
elasota
cffd2b00f7 GRAPHICS: Fix OOB writes when drawing underlined text where the underline doesn't fit in bounds. 2023-08-16 19:12:49 +03:00
D G Turner
c674de750d GRAPHICS: Remove Unused Variables Causing GCC Warnings from BDF Font Code 2023-07-09 03:53:44 +01:00
Harishankar Kumar
9b6d9b0c27 GRAPHICS: Fix WinFont scaling memory leak when scaling fonts.
Memory leak happened because the scaled generated fonts were not
being cached or saved anywhere, thus they were not being destructed
and freed. Added logic to cache generated font in _winFontRegistry
itself.

Leaks observed in `trektech-win` of director engine in first few frames itself.
2023-07-08 22:13:28 +03:00
elasota
44eb2540cb GRAPHICS: Improve BDF scaling quality.
Instead of doing bbox-to-bbox scales, fill pixels based on distance to a reference coordinate, which ensures the same rounding behavior at each scanline.
2023-07-08 22:07:48 +03:00
Eugene Sandulenko
8c5c3f6ecc
GRAPHICS: Lower graylevel for scaled BDF fonts
This fixes higher resolution OpenGL GUI
2023-06-27 13:56:16 +02:00
Harishankar Kumar
96008586c6 GRAPHICS: Add scaling for winfont
Allow scaling of window font, ie FON, FNT. Internally this uses
same implementation as BDFScaling and MacFontScaling. Uses function
scaleSingleGlyph to scale each glyph.

Fonts in `mcluhan-win` used some of these fonts where the sizes
were different than parsed.
2023-06-27 13:00:29 +03:00
Eugene Sandulenko
bbfd43264a
GRAPHICS: Drop offsets when scaling BDF fonts 2023-06-26 15:05:32 +02:00
Harishankar Kumar
4e6886c2a2
GRAPHICS: Fix BDF font scaling 2023-06-26 15:01:16 +02:00
Eugene Sandulenko
ae89982ded
GRAPHICS: Handle null advances and boxes in BdfFonts::scaleFont 2023-06-23 12:03:16 +02:00
Harishankar Kumar
6552dae1a5 GRAPHICS: Fixed irregular fonts height in macfonts
leading of a font is added to the height of the font when returning font
height, additionally the definition of leading says:
`Alternatively called line spacing, leading is the space between lines`

This fixes alignment of texts in `warlock-100` while also fixing the
line heights in `theapartment`.
2023-06-21 20:18:39 +03:00
Eugene Sandulenko
fbb238bb91
GRAPHICS: Fix include 2023-04-29 13:39:21 +02:00
Vladimir Serbinenko
eb2c55fe04 COMMON: Move DOS font from AGI to common
It's useful for Chinese EOB2 as well
2023-04-29 13:37:45 +02:00
NischayDiwan
aaa32cf118 GRAPHICS: Fix scaling for BDF fonts
- The primary change is to fix or improve the scaling of BDF fonts
 - Now uses the same approach as in MacFonts scaling that is creating another surface and refactor it with a grayscalemap
 - Bugs - there are still some problems when testing in capital letters
2023-04-16 21:13:50 +02:00
NischayDiwan
4b83dd78d6 GRAPHICS: Refactor MacFont scaling into reusable methods
- The refactoring code for MacFont that magnifies the font on a surface and then uses a grayscalemap to refactor the scaling, is pushed back into a resuable method in the base font class.
 - surface magnigy funtion transfer and scaleSingleGlyph method add to the font class.
2023-04-16 21:13:50 +02:00
Eugene Sandulenko
9bb24b21f3
GRAPHICS: Use better rounding for BDF font scaling 2023-03-18 20:18:11 +01:00
Eugene Sandulenko
4ef840d93d
GRAPHICS: Const correctness 2023-02-25 15:29:30 +01:00
Eugene Sandulenko
58ca66a5d6
GRAPHICS: Added option for debug output to BDF font scaling 2023-02-25 15:29:30 +01:00
Cameron Cawley
08375cafdf GRAPHICS: Improve TTF rendering quality with RGB332 surfaces 2023-02-07 23:42:42 +01:00
Le Philousophe
bc343edb42 GRAPHICS: Fix BDF font loading
When the character is out of range, just go to the next character.
2023-01-29 13:18:54 +01:00
Le Philousophe
b8f1f64d00 GRAPHICS: Delete archive when it's not needed 2023-01-26 07:42:48 +01:00
Marcus Comstedt
9203d278dd GRAPHICS: Add Latin Extended-A to small GUI font
This fixes incorrectly rendered characters in the about crawler.

The big GUI font was already fixed in commit 20eb91cb.

The following BDF file was used as source:
https://opensource.apple.com/source/X11fonts/X11fonts-14/font-schumacher-misc/font-schumacher-misc-1.1.2/clR6x12.bdf
2023-01-22 19:47:29 +01:00
Cameron Cawley
28d7b361ea COMMON: Move more file format code into common/formats 2022-12-11 22:33:23 +01:00
Eugene Sandulenko
fb7095f5a4
COMMON: Move all compression-related files to a separate directory 2022-12-01 11:53:02 +01:00
sluicebox
74d94f14f1 GRAPHICS: Fix WinFontDirEntry parsing regression
Fixes HUGO1 crash on startup

Incorrect offset introduced in 8cb2e1bb07

https://learn.microsoft.com/en-us/windows/win32/menurc/fontdirentry
2022-11-22 00:30:36 -08:00
sluicebox
b578f5be7b GRAPHICS: Expose Font leading and descent values
The leading value in Macintosh fonts is the space between lines,
defined as the space between a descent line and the ascent line
below it. Clients need this to draw text and calculate its height
as classic Macintosh did.
2022-11-06 23:05:20 -08:00
sluicebox
2775987cba MACGUI: Expose font families in MacFontManager
MacFontManager didn't have a mechanism to report which fonts it loaded
from an external resource. It also requires that any fonts that aren't
built-in be explicitly registered by name by the client before they can
be used. This combination meant that a client couldn't load fonts from
an external file and use them by their properties (id / size / style).

SCI contains Mac fonts in its executable along with a table that maps
each SCI font id to a Mac font id and size. The font name isn't a part
of this since the Classic Mac Toolbox API took id / size / style as
input when drawing text.

Now MacFontManager exposes the font families it has loaded along with
their names. This allows a client to see which fonts were loaded,
register them by name, and proceed to use them with the existing API.
2022-11-06 23:05:20 -08:00
Le Philousophe
3aa220fdb4 GRAPHICS: Don't use unsafe strcat and strcpy 2022-10-23 22:46:19 +02:00
Roland van Laar
b517ab6635 GRAPHICS: MACGUI: Fix memory leak in scaleFont
Free all surfaces after use.
2022-09-20 11:04:58 +02:00