Confusing Chr$ explanation - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Confusing Chr$ explanation (/showthread.php?tid=1820) |
RE: Confusing Chr$ explanation - PhilOfPerth - 07-12-2023 While experimenting with Chr$(), I find that Chr$(95) (the underscore) is the only one that is not displayed in a 16-bit screen mode. (it displays in 32 - bit mode) I suspect this is because the character uses the lowest row of the cell (row 8). Is this the reason? But Chr$ 92, 93, 103, 106, 112, 113, and 121 (mostly serif characters) all appear to use row 8, and they display in full. RE: Confusing Chr$ explanation - SagaraS - 07-15-2023 (07-12-2023, 06:03 AM)PhilOfPerth Wrote: While experimenting with Chr$(), I find that Chr$(95) (the underscore) is the only one that is not displayed in a 16-bit screen mode. (it displays in 32 - bit mode)Screen Mode 0 is text based exklusiv screen SCREEN 0 or SCREEN _NEWIMAGE(640, 400, 0) Screen Mode 1-15 are palette based exklusiv screens. As an example: SCREEN 13 or SCREEN _NEWIMAGE(320, 200, 13) SCREEN 10 or SCREEN _NEWIMAGE(640, 350, 10) Screen Mode 256 is a full 256 palette based screen. Almost identical to Screen Mode 13. SCREEN _NEWIMAGE(800, 600, 256) Screen Mode 32 is the True color Mode SCREEN _NEWIMAGE(800, 600, 32) 16 Bit color or High color Mode does not exist in QB64. However, 16-bit graphics can be displayed on 32-bit. Each screen mode has its own text width and height. This is calculated from the screen width, screen height, font width and font height As an example: 640 x 480 Screen courbd.ttf in 32 height have a 22 width 640 / 22 = about 29,1 Text width on screen 480 / 32 = 15 Text height on screen You have a 29,1 x 15 Text Screen on a 640x480 Screen with the courbd.ttf font in 32 height An error would then occur as soon as the 'Locate' command addresses the 16th row or 30nd cell. CHR$(95) may not be displayed because the text height may be an odd number? Example: 320 x 200 Screen + courbd.ttf in 32 height have a 22 width 320 / 22 = about 14,55 Text width on screen 200 / 32 = 6,25 Text height on screen You can displayed the text with 'Locate' command. Code: (Select All)
You can't displayed the text with normal Print for the last rows when text height have odd numbers With the normal print command you can displayed 4 rows. With ; on the print command, you can displayed 5 rows. When the last row is reached, the content moves up the screen, leaving the last row empty. The font cannot be scaled to comma values. That means you need integers for it. QB64 convert all Fonts to a new Raster fonts with fixed width and height. A filter scales the characters down to a certain size. Could be 'Nearest Neighbor' filter. Then some sizes of the fonts would explain that they can't be displayed. Example by courbd.ttf ✅ show the CHR$(95) ❌ Do not show CHF$(95) is the Font height 32, then the width is 22 ✅ is the Font height 31, then the width is 22 ✅ is the Font height 30, then the width is 22 ✅ is the Font height 29, then the width is 23 ✅ is the Font height 28, then the width is 20 ✅ is the Font height 27, then the width is 17 ✅ is the Font height 26, then the width is 18 ✅ is the Font height 25, then the width is 18 ❌ is the Font height 24, then the width is 18 ✅ is the Font height 23, then the width is 19 ✅ is the Font height 22, then the width is 19 ✅ is the Font height 21, then the width is 11 ✅ is the Font height 20, then the width is 13 ✅ is the Font height 19, then the width is 11 ✅ is the Font height 18, then the width is 18 ✅ is the Font height 17, then the width is 12 ✅ is the Font height 16, then the width is 12 ❌ is the Font height 15, then the width is 12 ❌ is the Font height 14, then the width is 10 ✅ is the Font height 13, then the width is 10 ❌ is the Font height 12, then the width is 10 ❌ is the Font height 11, then the width is 10 ✅ is the Font height 10, then the width is 8 ✅ is the Font height 9, then the width is 8 ❌ is the Font height 8, then the width is 5 ❌ is the Font height 7, then the width is 4 ✅ is the Font height 6, then the width is 4 ✅ ... Code: (Select All)
Uses only the memory for the character. And ends after the char.Code: (Select All)
Still uses the memory for CR + LF. And only ends afterwards.Example for the last row: Code: (Select All)
First Picture without ; The text is wrote in the 26th row, because the screen is move down. (See the right picture with background color) Second Picture with ; RE: Confusing Chr$ explanation - PhilOfPerth - 07-16-2023 (07-15-2023, 08:47 AM)SagaraS Wrote:(07-12-2023, 06:03 AM)PhilOfPerth Wrote: While experimenting with Chr$(), I find that Chr$(95) (the underscore) is the only one that is not displayed in a 16-bit screen mode. (it displays in 32 - bit mode)Screen Mode 0 is text based exklusiv screen Thanks SagaraS. A very detailed explanation. Thank you for your work. But a lot of that goes over my head; I'm not very experienced, only experimental - maybe experi- and -mental ? The examples with "pass" or "fail" should help clarify things though... I'll put some time into going through those. And the Locate... Print... seems to work too. RE: Confusing Chr$ explanation - SagaraS - 07-16-2023 Here you have a code that demonstrates the whole thing With the arrow keys left and right can you change the height of the TTF Font Code: (Select All)
RE: Confusing Chr$ explanation - mnrvovrfc - 07-16-2023 It's not recommended to use FIX() to wrap a division. Do this instead: Code: (Select All) ' Rounding down the TEXTfield to a Integer The larger "slash" key which is the directory separator in Windows, which in QBasic/QB64 is called "integer division". There are other fonts that have that problem with displaying underscores and stuff like that. On Linux as well. While using Geany I had to change a font because of it, although it looked great for source code. PRINT on the bottom-most line of SCREEN 0 should be avoided as much as possible and otherwise, use a trailing semicolon for anything used with PRINT. RE: Confusing Chr$ explanation - bplus - 07-16-2023 Looks good to me! Fine demo @SagaraS (almost a palindrome). A <= 100 LOC demo is worth a 1000 words ;-)) RE: Confusing Chr$ explanation - mnrvovrfc - 07-16-2023 Should have been "Saragaras" but I guess that was already taken... RE: Confusing Chr$ explanation - SagaraS - 07-16-2023 (07-16-2023, 07:35 PM)mnrvovrfc Wrote: Should have been "Saragaras" but I guess that was already taken...Nope. SagaraS is correct. Originates from Sousuke Sagara from the anime Full Metal Panic. RE: Confusing Chr$ explanation - SMcNeill - 07-16-2023 (07-12-2023, 06:03 AM)PhilOfPerth Wrote: While experimenting with Chr$(), I find that Chr$(95) (the underscore) is the only one that is not displayed in a 16-bit screen mode. (it displays in 32 - bit mode)This should actually be fixed, if you use the new UPrintString functions. The issue here is a glitch in the print routines with certain fonts basically suffering from clipping/truncating in the old versions of QB64 with PRINT. Kindly share what version of QB64 you were testing on which had the underscore disappear on you, (and then give it a shot in the latest release and see if the issue still persists), along with the font name and size, and we'll test it and see if it's something we can fix, if it's a bug in QB64's side of thing. Properly rendering fonts is a little more complex than most folks think it is, and clipping due to rounding issues and other such things isn't all that uncommon. Sometimes, it takes a little persistence and a lot of debugging grease, before everything works 100% as expected. (If it ever does.) RE: Confusing Chr$ explanation - PhilOfPerth - 07-16-2023 Thanks Steve. It's comforting to know that there really is an issue, and not just my dumbness . I'll do that test and let you know the version and stuff. My choice of screen size may also be a factor, as it seems I'm choosing some "illegal" sizes. |