93 Commits

Author SHA1 Message Date
Le Philousophe b49cb8e61f GRAPHICS: Don't call Font::drawChar if the char is too far left
The call will be a noop as the font code is epxected to not write if the
right of the char is negative.
2026-04-26 11:55:32 +02:00
AndywinXp 802abe1a2d GRAPHICS: FONTS: Add allowCharClipping parameter
This parameter allows for drawing the string until the very end of the allowed boundary,
instead of completely skipping the affected characters.
2026-02-11 23:53:58 +01:00
Cameron Cawley 6767fe7dbb GRAPHICS: Add variants of Font::drawChar that preserve the alpha channel 2025-06-15 15:10:21 +03:00
Matthew Duggan 8bc2db262f GRAPHICS: Add wrapping mode that ignores trailing space
The DGDS engine word wrapping algorithm appends any amount of whitepsace on the
end of the line before wrapping, allowing the nominal line length to go beyond
the limit specified. The drawn length will still be within the limit.

Add a WordWrapMode flag that does the same.
2024-10-26 10:08:56 +03:00
hecmar007 c6c80b9313 GRAPHICS: MACGUI: Process extra long words (#5703)
GRAPHICS:  MACGUI: Process extra long words

Added functionality to rewrap words that split into different lines.
2024-03-13 17:39:21 +01:00
Eugene Sandulenko 69aee0d228 GRAPHICS: Fix regression in font scaling code 2023-09-17 00:56:28 +02:00
Harishankar Kumar 4e6886c2a2 GRAPHICS: Fix BDF font scaling 2023-06-26 15:01:16 +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
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
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Thierry Crozat a3f3d71c57 GRAPHICS: Expose ascent value in font class 2021-03-23 20:25:23 +00:00
Paul Gilbert 4142f7b7f8 GRAPHICS: Allow TTFFont to handle ManagedSurfaces with transparent pixels 2021-02-26 17:58:19 -08:00
antoniou79 5e467e1bbc GRAPHICS: FONT: Clarification for combo of wrapping flags
for the wordWrapTextImpl and the kWordWrapEvenWidthLines, kWordWrapOnExplicitNewLines bit flags
2020-12-09 18:53:42 +02:00
Eugene Sandulenko 87beb98b95 GRAPHICS: Turn set of bool parameters for wordWrap() to a bitfield 2020-10-16 23:52:18 +02:00
aryanrawlani28 546fe374df GRAPHICS: Properly assign chars in handleEllipsis according to stringtype 2020-08-30 14:43:41 +02:00
aryanrawlani28 aa33fc2354 GRAPHICS: Use template for handleEllipsis 2020-08-30 14:43:41 +02:00
aryanrawlani28 ad78777bc6 GUI: Handle ellipsis shortening of text when drawing u32 strings 2020-08-30 14:43:41 +02:00
aryanrawlani28 51d95f8978 GRAPHICS: move start + end to Graphics::TextAlign 2020-06-22 00:03:02 +02:00
aryanrawlani28 5a093e4e95 GUI: RTL: Improve right align text drawing
- Fix last chars being eaten
- Add support for input in right-align mode editables
- Fix issue with dirtyness of editables after clicking
- Improve spacing for lists and popup
- Make numbers reversed in lists
2020-06-22 00:03:02 +02:00
Thanasis Antoniou 1bca3de594 COMMON: Support text wrapping with even width line segments
The new arguments are optional. The lines segments will be close to the same width.

The algorithm is similar to the one we had for Blade Runner but not exactly the same, since that one would wrap a line at a white space after the theoretical split point (quotient of full line text width divided by target lines number)
2019-08-02 00:08:38 +02:00
Paul Gilbert e5b73b2899 GRAPHICS: Add deltax optional parameter to Font drawString U32String version 2018-11-14 19:00:17 -08:00
Bastien Bouclet 7362060c47 GRAPHICS: Improve check to test if text fits in the target surface
When rendering text, especially truetype fonts, we would use the next
character avance metric to check if the character fits in the target
surface. This commit changes it to use the bounding box metric. The
bounding box represents the actual pixels that will be touched when
drawing the character.

This fixes an issue noticed on the main menu of Myst ME where the last
character of the string "OPTIONEN" would not be rendered despite there
being enough room to render it. More precisely, this ensures that
calling Font::getBoundingBox for a string, and then passing a surface
exactly the size of the returned bounding box to the draw function
actually renders all the characters.
2018-08-03 22:35:16 +02:00
Ľubomír Remák d9b3853dec COMMON: Fix kerning issue in wordWrapText. 2018-08-02 18:54:13 +02:00
Eugene Sandulenko dc640ab50a GRAPHICS: Added optional initial line width ot text wrapper 2017-01-29 18:41:07 +01:00
stevenhoefel feab260c98 GRAPHICS: Fix oversight on length value to return. 2017-01-17 22:14:58 +11:00
stevenhoefel 2e48529fa1 DIRECTOR: Utilise MacText class to provide Text Wrapping. 2017-01-15 18:42:50 +11:00
Torbjörn Andersson bf851cc525 GRAPHICS: Handle Windows and Mac line breaks when word-wrapping text
This seems like the right place to do it. Hopefully it's also the
right way. It fixes line breaks in the MacVenture engine, where the
text apparently uses Mac line breaks.
2016-09-05 18:41:40 +02:00
Johannes Schickel ce1be463c2 GRAPHICS: Implement convenience Font::drawChar taking ManagedSurface. 2016-03-21 02:03:12 +01:00
Johannes Schickel 2e5ef74848 GRAPHICS: Use correct bounding rect in Font::drawString taking Common::String. 2016-03-20 20:03:54 +01:00
Johannes Schickel 71c649f8d9 GRAPHICS: Mark actual dirty area as dirty in Font::drawString. 2016-03-20 19:59:55 +01:00
Paul Gilbert 433a2daa6a GRAPHICS: Added ManagedSurface and Screen classes 2016-03-14 20:56:14 -04:00
Johannes Schickel d55cd8f3b4 GRAPHICS: Allow to query the bounding box of chars/strings drawn with Font API. 2014-09-03 22:55:48 +02:00
Johannes Schickel 53332e8066 GRAPHICS: Make GPL headers consistent in themselves. 2014-02-18 02:39:34 +01:00
Johannes Schickel 9da09f5846 GRAPHICS: Allow Font to accept U32String as strings. 2013-11-23 21:34:54 +01:00
Johannes Schickel afa3f50b8a GRAPHICS: Let Font take uint32 as character codes.
This is required to support UTF-32 strings but does not make them work
automatically!
2013-11-23 21:34:54 +01:00
Narek Mailian 887a99e211 GRAPHICS: Added changes and improved code from inisider/scummvm (partial text)
Includes code from https://github.com/inisider/scummvm/ , which has been
squashed and bugfixed
2013-08-16 20:54:08 +02:00
Max Horn 4f8665fc83 COMMON: Move isFoo functions to namespace Common, add doxygen comments 2012-02-20 16:18:27 +01:00
Max Horn 658080deed ALL: Avoid using is* macros from ctype.h
On some systems, passing signed chars to macros like isspace() etc. lead
to a runtime error. Hence, mark these macros as forbidden by default,
and introduce otherwise equivalent alternatives for them.
2012-02-15 16:51:37 +01:00
Johannes Schickel 9f3fbe1bd7 GRAPHICS/GUI: Implement kerning support for Font.
This adapts the related graphics code, which is the generic Font API and the
TTF font implementation.

It furthermore adapts the GUI to properly take care of kerning in text input
widgets.
2012-01-29 16:26:20 +01:00
Johannes Schickel 8201df7bb6 GRAPHICS: Move NewFont code to a separate file. 2011-07-01 21:10:25 +02:00
Littleboy b694a78f62 ANALYSIS: Add static casts to is* functions
This fixes a potential problem with passing char values that would be sign-extended and yield unexpected results.
See http://msdn.microsoft.com/en-us/library/ms245348.aspx
2011-06-23 08:52:52 -04:00
Julien 8a5bda72cc BACKENDS/GRAPHICS: Silence non zero-terminated terminated buffers warnings by initializing the buffers to 0 2011-06-23 15:11:37 +08:00
Max Horn 90d3fc9f5b GRAPHICS: Rename some members of NewFont 2011-05-23 12:13:02 +02:00
strangerke 69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Johannes Schickel 71bdb86e02 Merge pull request #16 "Add a PixelFormat to Graphics::Surface.".
For further discussion check here:
https://github.com/scummvm/scummvm/pull/16

Conflicts:
	graphics/png.cpp
2011-05-01 16:54:45 +02:00
Ori Avtalion 9414d7a6e2 JANITORIAL: Reduce header dependencies in shared code
Some backends may break as I only compiled SDL
2011-04-28 15:08:58 +03:00
Johannes Schickel 3fd919060c GRPAHICS: Do not access Surface::bytesPerPixel anymore. 2011-04-17 20:58:08 +02:00
Filippos Karapetis cc0b2b210f GRAPHICS: Fixed code analysis warnings (bug #3087917)
svn-id: r54964
2010-12-19 16:16:25 +00:00
Johannes Schickel c8aabe77e8 GUI: Fix font cache.
The bounding boxes of the glyphs use signed coordinates. We stored only
unsigned coordinates, which resulted in incorrect glyph positioning.

Conrecte example: the bounding box of the glyphs for clR6x12-iso-8859-5.bdf
used:

x y  w h
0 -3 6 12

We on the other hand interpreted that as:

x y     w h
0 65533 6 12

when loading the font from our font cache.

svn-id: r51586
2010-08-01 19:31:37 +00:00
Max Horn c934642bdb COMMON: Move typedef StringList from str.h to new header str-array.h
This removes the dependency on array.h from str.h.
Also, begun migration from the confusing type name "StringList" to
the more appropriate StringArray.

svn-id: r48282
2010-03-18 15:09:24 +00:00