packages feed

h-raylib 4.6.0.1 → 4.6.0.2

raw patch · 7 files changed

+31/−32 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # h-raylib changelog
 
+## Version 4.6.0.2
+_8 April, 2023_
+
+- Fixed a bug in `clamp`
+- Updated raylib to the master branch
+
 ## Version 4.6.0.1
 _2 April, 2023_
 
ROADMAP.md view
@@ -10,5 +10,5 @@ - Make it easier to pass shader parameters (Added in `4.5.3.0`)
 - Allow manual unloading of assets for larger projects (Added in `4.5.3.1`)
 - Bind `rlgl` (Added in `4.5.3.2`)
-- Bind `rcamera` (Not published to hackage)
-- Bind `raymath` (Not published to hackage)
+- Bind `rcamera` (Added in `4.6.0.1`)
+- Bind `raymath` (Added in `4.6.0.1`)
h-raylib.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4
 name:               h-raylib
-version:            4.6.0.1
+version:            4.6.0.2
 synopsis:           Raylib bindings for Haskell
 category:           graphics
 description:
raylib/src/rtext.c view
@@ -1071,10 +1071,6 @@         int codepoint = GetCodepointNext(&text[i], &codepointByteCount);
         int index = GetGlyphIndex(font, codepoint);
 
-        // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
-        // but we need to draw all the bad bytes using the '?' symbol moving one byte
-        if (codepoint == 0x3f) codepointByteCount = 1;
-
         if (codepoint == '\n')
         {
             // NOTE: Fixed line spacing of 1.5 line-height
@@ -1205,7 +1201,7 @@     int letter = 0;                 // Current character
     int index = 0;                  // Index position in sprite font
 
-    for (int i = 0; i < size; i++)
+    for (int i = 0; i < size;)
     {
         byteCounter++;
 
@@ -1213,10 +1209,7 @@         letter = GetCodepointNext(&text[i], &next);
         index = GetGlyphIndex(font, letter);
 
-        // NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
-        // but we need to draw all the bad bytes using the '?' symbol so to not skip any we set next = 1
-        if (letter == 0x3f) next = 1;
-        i += next - 1;
+        i += next;
 
         if (letter != '\n')
         {
@@ -1246,17 +1239,17 @@ // NOTE: If codepoint is not found in the font it fallbacks to '?'
 int GetGlyphIndex(Font font, int codepoint)
 {
-#ifndef GLYPH_NOTFOUND_CHAR_FALLBACK
-    #define GLYPH_NOTFOUND_CHAR_FALLBACK     63      // Character used if requested codepoint is not found: '?'
-#endif
-
-// Support charsets with any characters order
+    int index = 0;
+    
 #define SUPPORT_UNORDERED_CHARSET
 #if defined(SUPPORT_UNORDERED_CHARSET)
-    int index = GLYPH_NOTFOUND_CHAR_FALLBACK;
+    int fallbackIndex = 0;      // Get index of fallback glyph '?'
 
+    // Look for character index in the unordered charset
     for (int i = 0; i < font.glyphCount; i++)
     {
+        if (font.glyphs[i].value == 63) fallbackIndex = i;
+        
         if (font.glyphs[i].value == codepoint)
         {
             index = i;
@@ -1264,10 +1257,12 @@         }
     }
 
-    return index;
+    if ((index == 0) && (font.glyphs[0].value != codepoint)) index = fallbackIndex;
 #else
-    return (codepoint - 32);
+    index = codepoint - 32;
 #endif
+
+    return index;
 }
 
 // Get glyph font info data for a codepoint (unicode character)
@@ -1734,8 +1729,7 @@         int next = 0;
         int letter = GetCodepointNext(ptr, &next);
 
-        if (letter == 0x3f) ptr += 1;
-        else ptr += next;
+        ptr += next;
 
         length++;
     }
@@ -1896,28 +1890,31 @@ {
     const char *ptr = text;
     int codepoint = 0x3f;       // Codepoint (defaults to '?')
-    *codepointSize = 0;
+    *codepointSize = 1;
 
     // Get current codepoint and bytes processed
     if (0xf0 == (0xf8 & ptr[0]))
     {
         // 4 byte UTF-8 codepoint
+        if(((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80) || ((ptr[3] & 0xC0) ^ 0x80)) { return codepoint; } //10xxxxxx checks
         codepoint = ((0x07 & ptr[0]) << 18) | ((0x3f & ptr[1]) << 12) | ((0x3f & ptr[2]) << 6) | (0x3f & ptr[3]);
         *codepointSize = 4;
     }
     else if (0xe0 == (0xf0 & ptr[0]))
     {
         // 3 byte UTF-8 codepoint */
+        if(((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80)) { return codepoint; } //10xxxxxx checks
         codepoint = ((0x0f & ptr[0]) << 12) | ((0x3f & ptr[1]) << 6) | (0x3f & ptr[2]);
         *codepointSize = 3;
     }
     else if (0xc0 == (0xe0 & ptr[0]))
     {
         // 2 byte UTF-8 codepoint
+        if((ptr[1] & 0xC0) ^ 0x80) { return codepoint; } //10xxxxxx checks
         codepoint = ((0x1f & ptr[0]) << 6) | (0x3f & ptr[1]);
         *codepointSize = 2;
     }
-    else
+    else if (0x00 == (0x80 & ptr[0]))
     {
         // 1 byte UTF-8 codepoint
         codepoint = ptr[0];
raylib/src/rtextures.c view
@@ -1266,17 +1266,13 @@     // Create image to store text
     imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
 
-    for (int i = 0; i < size; i++)
+    for (int i = 0; i < size;)
     {
         // Get next codepoint from byte string and glyph index in font
         int codepointByteCount = 0;
         int codepoint = GetCodepointNext(&text[i], &codepointByteCount);    // WARNING: Module required: rtext
         int index = GetGlyphIndex(font, codepoint);                         // WARNING: Module required: rtext
 
-        // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
-        // but we need to draw all the bad bytes using the '?' symbol moving one byte
-        if (codepoint == 0x3f) codepointByteCount = 1;
-
         if (codepoint == '\n')
         {
             // NOTE: Fixed line spacing of 1.5 line-height
@@ -1296,7 +1292,7 @@             else textOffsetX += font.glyphs[index].advanceX + (int)spacing;
         }
 
-        i += (codepointByteCount - 1);   // Move text bytes counter to next codepoint
+        i += codepointByteCount;   // Move text bytes counter to next codepoint
     }
 
     // Scale image depending on text size
src/Raylib/Util/Camera.hs view
@@ -139,7 +139,7 @@   where
     angle' = if not lockView then angle else clamp angle maxAngleDown maxAngleUp
     maxAngleUp = vector3Angle up viewVec - 0.001
-    maxAngleDown = (- vector3Angle (additiveInverse up) viewVec) - 0.001
+    maxAngleDown = (- vector3Angle (additiveInverse up) viewVec) + 0.001
 
     viewVec = target |-| pos
     viewRot = vector3RotateByAxisAngle viewVec right angle'
src/Raylib/Util/Math.hs view
@@ -111,7 +111,7 @@ clamp value low high
   | value < low = low
   | value > high = high
-  | otherwise = 0
+  | otherwise = value
 
 -- | Calculate linear interpolation between two floats
 lerp ::