Commit Graph

195 Commits

Author SHA1 Message Date
Ray
e85f245ad4 REVIEWED: Remove final punctuation in code comments 2024-04-20 20:31:06 +02:00
Ray
29ce13b777 Code gardening
- Review formatting
 - Improve readability for some functions result return
 - Minimize early returns
 - Align LoadFileData() to UnloadFileData()
2024-04-20 13:53:13 +02:00
Ray
51486a0606 Update rtext.c 2024-04-19 21:13:36 +02:00
Ray
fea3395fc1 Review formatting 2024-02-29 18:50:44 +01:00
Ray
e42e3188f5 Remove some unneeded line breaks 2024-02-18 11:59:40 +01:00
Ray
401c5a8638 Minor tweaks to avoid some CodeQL warnings 2024-02-13 15:58:02 +01:00
Ray
bb741f53a8 Update rtext.c 2024-02-13 10:43:24 +01:00
Mingjie Shen
6280771dad
[rtext] Change strcpy to strncpy to fix buffer overflow (#3795) 2024-02-13 10:38:13 +01:00
Ray
e9291fa4c7 Update rtext.c 2024-02-04 22:50:54 +01:00
Ray
868d515fbc Update rtext.c 2024-02-04 11:18:46 +01:00
Ray
eed56a45d6 REVIEWED: LoadFontDataBDF() name and formating 2024-02-04 11:10:46 +01:00
Stanley Fuller
0932cd3059
[rtext] Add BDF font support (#3735)
* Add BDF font support

* Include font ascent in glyph y-offset when loading BDF font
2024-02-03 19:28:12 +01:00
Marrony Neris
c0b081fac0
Fix MeasureTextEx() height calculation (#3770) 2024-02-01 21:14:22 +01:00
Idir Carlos Aliane
cb97a8063d
[rtext.c] fixing some comments to align comments style (#3756) 2024-01-22 23:15:25 +01:00
Tim Romero
2c124c96df
[rtext] Adjust font atlas area calculation so padding area is not underestimated at small font sizes. (#3719) 2024-01-10 21:34:04 +01:00
Ray
3f1e59a7cf Update copyright to 2024 2024-01-02 20:58:12 +01:00
ubkp
5b5a2d035d
Fix TextReplace warning for const (#3687) 2023-12-28 23:13:47 +01:00
maverikou
7cfdf33ff0
TextReplace const correctness (#3678)
* TextReplace const correctness

* cleanup
2023-12-28 20:09:49 +01:00
Dongkun Lee
9de79861ea
BM Font Extender (#3536)
* loadbmfont

* bmfontextender

* bm font

* Modify LoadBM Font

* Delete loadbmfontex.diff

* REVIEWED: `LoadBMFont()` PR

* Update rtext.c

* Update rtext.c

---------

Co-authored-by: Dongkun Lee <hope81dklee@outlook.com>
Co-authored-by: Ray <raysan5@gmail.com>
2023-12-15 18:32:01 +01:00
Benjamin Schmid Ties
6083d2b9f3
fixed coding style in function TextToFloat (#3627)
* function to convert string to float

* fix code to match coding conventions
2023-12-13 21:20:13 +01:00
Ray
731b210f51 REVIEWED: WARNING: LoadFontData() avoid fallback glyphs
This is a redesign on font loading, missing glyphs are skipped instead of falling back to font `.notdef` special character (usually "tofu" character).
It is changed because not all fonts support a fallback glyph.
One improvement could be allowing users to define a custom fallback character, for example `?` glyph.
2023-12-04 17:32:55 +01:00
Ray
a016b4ded2 REVIEWED: LoadFontData(), load image only if glyph has been found in font 2023-12-03 20:17:16 +01:00
Ray
64d64cc181 REVIEWED: Potential code issues reported by CodeQL #3476 2023-11-01 15:28:18 +01:00
Ray
e4547eb422 Remove trail spaces 2023-10-26 23:56:03 +02:00
Ray
99ede0f747 Added some notes for alternative implementations #3362 2023-10-17 11:09:56 +02:00
Ray
876e6b3a0d REVIEWED: TextFormat(), added "..." for truncation #3366
It seems more standard than [TRUN]
2023-10-11 20:25:09 +02:00
Ray
61af8e7631 REVIEWED: #3399, Fix #3366 2023-10-11 12:20:03 +02:00
Murlocohol
28fb58f0ea
[rtext] TextFormat() warn user if buffer overflow occured. (#3399)
* [rtext] TextFormat now alerts user to truncation.

* Update rtext.c

* Update rcore.c

* Update rtext.c
2023-10-11 12:15:40 +02:00
Ray
e75f85ce58 REVIEWED: TextToPascal() issue when first char is uppercase 2023-09-11 19:01:24 +02:00
Ray
10e4aa32f8 Update rtext.c 2023-09-08 20:01:19 +02:00
Ray
9cce5a93ff Fix #3293 2023-09-05 20:04:21 +02:00
Ray
75e5cd86d7 Use internal default allocators, instead of user-exposed ones 2023-09-02 12:58:47 +02:00
Ray
0f447f1fb6 REVIEWED: Data size type consistency between functions #3168 2023-09-02 12:05:34 +02:00
Ray
ec6d3bb688 RENAMED: LoadFont*() parameter names for consistency and coherence 2023-09-01 23:23:01 +02:00
ashn
a86c93ebc0
Ignore unused return value of GetCodepointNext in GetCodepointCount (#3241)
* Ignore unused return value of GetCodepointNext in GetCodepointCount

Removes the last warning from non-external libraries when compiling with
the default build configuration on x64 Linux.

* Remove unnecessary void cast in GetCodepointCount
2023-08-15 00:09:27 +02:00
Ray
93f59a6f59 Review tabs and trail-spaces 2023-08-10 22:47:17 +02:00
RadsammyT
0959f6ebf6
fix typos in rmodels, rshapes, rtext modules (#3236) 2023-08-10 00:21:14 +02:00
ashn
90f1749965
Ignore unused function warnings from external headers when compiling with GCC and Clang (#3235) 2023-08-09 19:17:12 +02:00
Ray
52541b4a1f ADDED: SUPPORT_FONT_ATLAS_WHITE_REC
Support creating a 3x3 pixels white rectangle at the bottom-right corner of the generated font atlas image, useful for shapes+text drawing in a single draw call!
2023-07-18 17:57:10 +02:00
Ray
0b9fae3c53 Reviewed rcamera/rgestures file-macros for consistency #3161 2023-07-10 19:13:44 +02:00
Ray
685d47938b Reverted MeasureTextEx() change #3105 2023-07-06 12:31:01 +02:00
Ray
668b37e111 REVIEWED: GenImageFontAtlas(), make atlas size less conservative 2023-07-06 12:29:28 +02:00
Ray
58bd10edb2 Update rtext.c 2023-07-05 18:36:54 +02:00
Ray
4fc5e82e30 REVIEWED: TextToUpper(), TextToLower(), TextToPascal() 2023-07-02 11:10:42 +02:00
Ray
3e4e4b32fd WARNING: BREAKING: ADDED: SetTextLineSpacing() 2023-07-02 10:52:20 +02:00
Ray
48e2663d03 REVIEWED: Issue #3105 2023-07-02 10:51:39 +02:00
Ray
51387dfbfb tweak 2023-05-18 16:14:18 +02:00
Ray
7d68aa6869 REVIEWED: Modules description layout 2023-05-01 14:04:22 +02:00
Ray
9d38363e09 Remove trailing spaces 2023-04-17 12:18:06 +02:00
Ray
d8c7b01a3c REVIEWED: GetGlyphIndex() #3000 2023-04-06 12:49:59 +02:00
chocolate42
8367abad1a
[rtext] Fix GetCodepointNext() to return default value on invalid input with size=0 (#2997)
* Fix GetCodepointNext to return default value with size=0 on invalid input. Modify LoadCodepoints to work when GetCodepointNext returns a size of 0. All internal use of GetCodepointNext and GetCodepointPrev checked. This fix may break external code dealing with invalid input as the old code erroneously never returned a size of 0, external code that doesn't properly check for size=0 may endlessly loop or overflow a buffer on invalid input.

* Change default behaviour of GetCodepointNext to return a size of 1 instead of 0. This matches existing prod behaviour and guarantees size 1..4 is returned. Simplify internal code that uses GetCodepointNext that previously had to account for size=0.

* Simplified progressing through a UTF-8 string in ImageTextEx and MeasureTextEx. This change matches existing precedent in DrawTextEx

* GetCodepointNext: Add 10xxxxxx checks to multibyte encodings.

---------

Co-authored-by: anon <anon>
2023-04-06 12:34:37 +02:00
Ray
ecb6a6af32 Review format 2023-03-22 11:08:46 +01:00
Hanaxar
e55bdd5d8a
Fix packing logic error in ``GenImageFontAtlas`` (#2979)
Basic packing algorithm currently follows this order: Copy pixel data -> Move offsetX for current glyph -> Check remaining space for current glyph...
Since X offset already moved according current glyph, remaining space should be checked for next glyph. Because of this, occasionally, current logic causes glyphs wrapping around texture.
Proposed fix accomplishes that by moving offsetX check to the beginning of the loop.
2023-03-22 11:00:13 +01:00
Hanaxar
02a8a49961
Calculate exact image size in GenImageFontAtlas (#2963)
* Calculate exact image size in GenImageFontAtlas

Calculate exact image size with a method based on total glyph width and glyph row count
Current method seemed a little bit overkill with square root, log and power functions and only approximates image size which can be wonky with some weird fonts like cursive fonts.
Proposed method calculates image size directly with a simpler method and results exact image size needed.

* Update rtext.c

* Update rtext.c

Changed do-while to while loop, and also added an extra step to calculate maximum glyph width and excluding it from image width for extra safety.
2023-03-22 10:59:28 +01:00
Ray
a7f81b06b9 Remove trailing spaces 2023-03-13 12:08:23 +01:00
Ray
ab1e246367 REVIEWED: Data types validation 2023-03-07 20:33:45 +01:00
Ray
ca98a84d68 Update rtext.c 2023-02-24 15:27:25 +01:00
Ray
d652b95fbf ADDED: Security checks 2023-02-22 17:28:25 +01:00
Julio C. Galindo
6ae21d6581
Fixed some grammar mistakes and typos. (#2914)
* Fixed some grammar mistakes.

* Fixed some typos.
2023-02-09 13:17:47 +01:00
Ray
1fea266472 Clean trailing spaces 2023-02-05 16:30:23 +01:00
Rob Loach
83ff7b2466
ADDED: IsShaderReady(), IsImageReady(), IsFontReady(), IsWaveReady(), IsSoundReady(), IsMusicReady() (#2892)
These IsReady() functions provide a method in order to verify whether or not the object was loaded successfully. They're useful to make sure the assets are there prior to using them.
2023-01-27 19:24:03 +01:00
Rob Loach
d8af76f67c
Fix to use TRACELOG() instead of TraceLog() for internal modules (#2881)
There were a few raylib modules that continued to use TraceLog() instead of the TRACELOG() macro. This change ensures that all the internal raylib modules use the TRACELOG() pattern consistently.
2023-01-22 11:10:38 +01:00
Ray
e2a8066fca Update year to 2023 2023-01-01 16:07:51 +01:00
Ray
fc5894e734 REVIEWED: Some compilation warnings (for strict rules) 2022-11-28 14:16:59 +01:00
Ray
7459d906de Update rtext.c 2022-10-03 00:07:22 +02:00
Ray
810a0330ab WARNING: Several changes on UTF-8/Codepoints API
- ADDED: `GetCodepointPrevious()`
 - RENAMED: `GetCodepoint()` -> `GetCodepointNext()`, actually, reimplemented
 - `GetCodepoint()` has been kept for the moment, for compatibility and also because implementation is different
 - RENAMED: `TextCodepointsToUTF8()` to `LoadUTF8()`, simpler name and more aligned with raylib conventions (functions loading memory start with Load*()), parameters should be descriptive of functionailty.
 - ADDED: `UnloadUTF8()`, aligned with `LoadUTF8()` to avoid allocators issues.
2022-09-22 20:35:55 +02:00
Ray
35c777ef2c REVIEWED: Avoid crash on bad data provided 2022-08-18 15:11:23 +02:00
Dan Bechard
56072a631d
Fix Codepoint position truncation (#2636)
This truncation causes text that spans the zero coord boundary to round differently left or zero vs. right of zero, in turn causing letters to appear squished together. If you actually need the position to be an integer, you should instead `floorf()` the float, rather than doing an integer truncation, but I don't see any reason to convert it to an integer in the first place. Everything else in the equation is a float.
2022-08-13 11:18:57 +02:00
Ray
fd191a32ea Remove trailing spaces 2022-08-02 00:36:31 +02:00
Ray
bb6b43b7cb REVIEWED: GenImageFontAtlas() #2556
Just reviewed font atlas size estimation, now it considers `fontSize` instead of `chars[i].image.height`, increasing considerably the atlas size estimation.
2022-07-29 12:01:18 +02:00
veclavtalica
63568721f9
fix: precision loss, discard unused (#2541) 2022-06-24 10:59:31 +02:00
The Tophat Demon
a6e31cadbd
Changed ExportFontAsCode to use given font's padding. (#2525) 2022-06-17 00:12:21 +02:00
Ray
8294e04749 Correct typo 2022-05-29 18:23:48 +02:00
Ray
fe28aa7c9b Review log messages 2022-05-29 17:39:10 +02:00
Ray
df3f64bfd2 Corrected typo 2022-05-07 18:04:34 +02:00
Ray
666aa44a84 Reviewed some comments 2022-05-01 11:14:28 +02:00
Ray
9c2d337e99 Update rtext.c 2022-03-29 18:11:33 +02:00
megagrump
7584ce6f48
Increase atlas size guesstimate; print warnings if atlas size is too small (#2365) 2022-03-01 11:26:48 +01:00
raysan5
937e7b3dd9 REVIEWED: Some functions input parametes that should be const 2022-02-20 20:35:28 +01:00
raysan5
d4382f4a52 Removed trailing spaces 2022-02-18 20:30:46 +01:00
Ray
4bc6e0d7de Update rtext.c 2022-02-13 10:47:19 +01:00
Siddharth Roy
e5ee69a0f5
Add DrawTextCodepoints (#2308)
* Add DrawTextCodepoints

* Fixed top comment
2022-01-26 12:55:34 +01:00
Ray
2116a98745 ADDED: ExportFontAsCode() 2022-01-03 20:45:56 +01:00
raysan5
a940f41b4b Update year to 2022 2021-12-31 20:06:22 +01:00
raysan5
803ce9f44b Detected some pixel-errors due to rounding issues on position 2021-12-28 15:39:57 +01:00
Ray
fd0e3a4fdd REVIEWED: GetCodepoint() #2201 2021-12-09 20:13:53 +01:00
Ray
e637ad9d2a Support custom modules inclusion
Allow to choose which modules are compiled with raylib, if some modules are excluded from compilation, required functionality is not available but smaller builds are possible.
2021-12-04 19:56:02 +01:00
Ray
21ec8c38ae Review variables initialization
- All variables are initialized on declaration, some arrays were not properly initialized
 - Static array buffers require memset() for re-initialization on every function call
2021-11-09 11:49:03 +01:00
Luke Krasnoff
8ec5b2dc2f
Protect TextIsEqual from NULLs (#2121) 2021-11-09 11:37:55 +01:00
raysan5
bba035c20c Minor type tweak 2021-11-01 19:14:55 +01:00
Ray
83b3478fe4 Reviewed some TODO 2021-10-13 23:45:57 +02:00
Ray
a1db0220a1 REVIEWED: LoadFontFromImage()
Avoid crash on wrong sprite font
2021-10-12 23:00:00 +02:00
Ray
f869229b7f Minor format tweaks 2021-10-03 12:09:59 +02:00
Ray
00a763ea44 Reviewed some TODO comments 2021-09-23 00:18:47 +02:00
Ray
99ab4d6cb8 WARNING: MODULES RENAMING!!!
raylib modules have been slightly renamed to add some identity and note that they are independent modules that can be used as standalone separate parts of raylib if required.

The renamed modules are:
 - `core` -> `rcore`
 - `shapes` -> `rshapes`
 - `textures` -> `rtextures`
 - `text` -> `rtext`
 - `models` -> `rmodels`
 - `camera` -> `rcamera`
 - `gestures` -> `rgestures`
 - `core` -> `rcore`

All the build systems has been adapted to this change.
2021-09-22 00:15:06 +02:00