Author Topic: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)  (Read 5239 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
I had a calendar making program spaced just right with Windows Font something happened when I went to make calendars for this year using QB64 v2.0, it turns out the Font change occurred in QB64 v1.5 just never caught it because was not working with fonts for awhile.

Something happened that stretches the f o n t  a l o n g  t h e  x - a x i s ??
  [ You are not allowed to view this attachment ]  

The upper is the look from QB64 v 1.5 and v 2.0

The lower is the look from QB64 v 1.4 (I had changed form arial rounded bold to just arial to make sure it wasn't just the one font acting different.

I also noticed this "spread out look" trying different fonts in the Crypt-O-Gram variations and had to stick with the default because it was spreading out so wide across the screen.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Big ugly font difference between QB664 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #1 on: October 23, 2021, 09:13:01 pm »
Looks to me like one is monospaced and one isn't
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #2 on: October 23, 2021, 09:16:43 pm »
Same exact code printed both those images just that one was done in QB64 v 1.4 and the other QB64 v1.5.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #3 on: October 23, 2021, 09:27:07 pm »
This is the start of the program with the font loading:
Code: QB64: [Select]
  1. CONST XMAX = 1100
  2. CONST YMAX = 700
  3. CONST tMar = 40 'top margin allows room for 3 hole binder punch on top (landscape orientation) or left side (portrait orientation)
  4. CONST sideMar = 10
  5. SCREEN _NEWIMAGE(XMAX, YMAX, 32)
  6. DIM dayNames$(0 TO 6), monthNames$(1 TO 12), monthDays(1 TO 12) AS INTEGER
  7. FOR i = 0 TO 6: READ dayNames$(i): NEXT
  8. DATA "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
  9. FOR i = 1 TO 12: READ monthNames$(i): NEXT
  10. DATA "January","February","March","April","May","June","July","August","September","October","November","December"
  11. FOR i = 1 TO 12: READ monthDays(i): NEXT
  12. DATA 31,28,31,30,31,30,31,31,30,31,30,31
  13.  
  14. ' this loads and checks fonts (Windows 10)
  15. DIM SHARED FH, CH, CW, FH2, CH2, CW2
  16. FH = _LOADFONT("Arial.ttf", 24, "MONOSPACE")
  17. IF FH <= 0 THEN PRINT "Trouble with font load file, goodbye.": SLEEP: END
  18. CH = _FONTHEIGHT(FH): CW = CH * .6 'this make printing char by char the same as printing a string for ARLRDBD.ttf
  19. 'test font, in box? for 5 above 5 below height = 30
  20. 'Line (5, 5)-Step(CW * Len(monthNames$(1) + Str$(2018)), 30), , B
  21. '_PrintString (10, 10), monthNames$(1) + Str$(2018)
  22.  
  23. FH2 = _LOADFONT("Arial.ttf", 18, "MONOSPACE")
  24. IF FH2 <= 0 THEN PRINT "Trouble with font load file, goodbye.": SLEEP: END
  25. CH2 = _FONTHEIGHT(FH2): CW2 = CH2 * .25 'this make printing char by char the same as printing a string for ARLRDBD.ttf
  26. _FONT FH2
  27. 'Line (5, 45)-Step(CW2 * Len("testing smaller font 1, 2, 3, 31"), 25), , B
  28. '_PrintString (10, 50), "testing smaller font 1, 2, 3, 31"
  29.  
  30. y = 2022 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< update for 2021
  31. DIM EasterMonth AS INTEGER, EasterDay AS INTEGER
  32. Easter y, EasterMonth, EasterDay
  33. 'PRINT EasterMonth, EasterDay, CH2
  34. 'END
  35.  

hmm looks like I set CW2 wrong but that does not make a difference to how wide it's printing.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #4 on: October 23, 2021, 09:38:36 pm »
Here is a simplified example to see it clearly:

  [ You are not allowed to view this attachment ]  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #5 on: October 23, 2021, 09:41:28 pm »
I got bit with some similar "font" bug earlier, in my Wheel of Fortune spoof. I ran perfectly in V2.0 and 1.5 but did not pick up _FONTWIDTH, _FONTHEIGHT the same in 1.3 and 1.4.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #6 on: October 23, 2021, 10:13:58 pm »
Here is a simplified example to see it clearly:

  [ You are not allowed to view this attachment ]

Looks like an obvious bug fix to me.

The left one isn't monospaced.  Those 2 "l" use up less screenspace than the single "H" does.The one on the right is spacing everything the same width as that "W", which *does* make it monospaced.

If that's not what you're wanting then remove "MONOSPACE" from the load parameters for _LOADFONT".
« Last Edit: October 23, 2021, 10:23:47 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #7 on: October 23, 2021, 10:17:51 pm »
It indeed looks like loading monospaced fonts does work as expected beginning with v1.5.

@bplus as Steve said, removing “monospaced” should give you the results you expected.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #8 on: October 23, 2021, 10:21:12 pm »
I got bit with some similar "font" bug earlier, in my Wheel of Fortune spoof. I ran perfectly in V2.0 and 1.5 but did not pick up _FONTWIDTH, _FONTHEIGHT the same in 1.3 and 1.4.

Pete

Probably the same issue.  From the screenshots, it's obvious there was a bug fix introduced into the source.  Before 1.5, that "MONOSPACE" wasn't auto-spacing fonts at all. 

Run this as a print under Bplus's "Hello World" code.

PRINT "HWHW".
PRINT "llll".

If the fonts are monospaced, both outputs should use the same screen width.  In 1.5, they do.  Before that, they're bugged.

HWHW
llll


Vs.

HWHW
llll
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #9 on: October 23, 2021, 10:50:04 pm »
Here's how I experienced the bug. I cut away non-essential code. In 1.5 up , it displays the _FONTWIDTH correctly, as 36. In 1.4 and 1.4, it displays 0, which is incorrect.

Code: QB64: [Select]
  1. DIM SHARED overlay
  2.  
  3. Screen0 = _NEWIMAGE(80, 25, 0)
  4. SCREEN Screen0
  5.  
  6. font = _LOADFONT("lucon.ttf", 60, "monospace")
  7. IF font <= 0 THEN font = 16
  8.  
  9. _DEST overlay
  10. _FONT font
  11. COLOR _RGB(255, 102, 0), 0
  12.  
  13.  
  14. y = 1: x = 1
  15. COLOR _RGB(255, 255, 255)
  16. t$ = "I'd like to solve the puzzle, please!"
  17. PSL y, x, t$
  18.  
  19. _FREEIMAGE overlay
  20.  
  21. _DELAY .66
  22.  
  23.  
  24.  
  25. SUB PSL (y, x, t$)
  26.     t$ = LTRIM$(STR$(_FONTWIDTH))
  27.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  28.     overlay_hardware = _COPYIMAGE(overlay, 33)
  29.     _PUTIMAGE (0, 0), overlay_hardware
  30.     _DISPLAY
  31.  

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #10 on: October 23, 2021, 11:08:44 pm »
It indeed looks like loading monospaced fonts does work as expected beginning with v1.5.

@bplus as Steve said, removing “monospaced” should give you the results you expected.

Thanks guys. Guess I am living in past. I remember "MONOSPACE" was required for .ttf, at one time. I do like a consistent width for characters but not the same as Height, yikes! it even looks more than that to me.

But now how can I get consistent width about .5 the height of a character? Like the default font, very easy to use and predict it's length, no matter the string, and looks normally spaced.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #11 on: October 23, 2021, 11:10:07 pm »
Here's how I experienced the bug. I cut away non-essential code. In 1.5 up , it displays the _FONTWIDTH correctly, as 36. In 1.4 and 1.4, it displays 0, which is incorrect.

Code: QB64: [Select]
  1. DIM SHARED overlay
  2.  
  3. Screen0 = _NEWIMAGE(80, 25, 0)
  4. SCREEN Screen0
  5.  
  6. font = _LOADFONT("lucon.ttf", 60, "monospace")
  7. IF font <= 0 THEN font = 16
  8.  
  9. _DEST overlay
  10. _FONT font
  11. COLOR _RGB(255, 102, 0), 0
  12.  
  13.  
  14. y = 1: x = 1
  15. COLOR _RGB(255, 255, 255)
  16. t$ = "I'd like to solve the puzzle, please!"
  17. PSL y, x, t$
  18.  
  19. _FREEIMAGE overlay
  20.  
  21. _DELAY .66
  22.  
  23.  
  24.  
  25. SUB PSL (y, x, t$)
  26.     t$ = LTRIM$(STR$(_FONTWIDTH))
  27.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  28.     overlay_hardware = _COPYIMAGE(overlay, 33)
  29.     _PUTIMAGE (0, 0), overlay_hardware
  30.     _DISPLAY
  31.  

Pete

0 is correct-- that's the result you get when the font is not loaded using MONOSPACE.

Since momospace was broken prior to v1.5, so that it didn't actually load and make fonts monospaced, then a 0 for fontwidth is the expected, and correct, result. 

V1.5 fixed the issue with loading monospace fonts, so that value will obviously change to reflect that for you.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #12 on: October 23, 2021, 11:13:57 pm »
Thanks guys. Guess I am living in past. I remember "MONOSPACE" was required for .ttf, at one time. I do like a consistent width for characters but not the same as Height, yikes! it even looks more than that to me.

But now how can I get consistent width about .5 the height of a character? Like the default font, very easy to use and predict it's length, no matter the string, and looks normally spaced.

It's not the same as height-- it sets it so each character has the same WIDTH.  Look at the width of the "W" on your screenshot and then look at the width of those "l"s.  Even from the beginning, everything had the same height (you specified it with the 24 in the second parameter), but the widths were inconsistent.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #13 on: October 23, 2021, 11:28:09 pm »
Notice the difference in the widths in the same font here, once loaded with monospace and once without:

Code: QB64: [Select]
  1. Screen _NewImage(1280, 1024, 32)
  2. t$ = "Hello World"
  3. For i = 0 To 10
  4.     text$(i) = Mid$(t$, i + 1, 1)
  5.  
  6.  
  7. FH = _LoadFont("Arial.ttf", 24)
  8. For i = 0 To 10
  9.     Locate i + 1, 1: Print text$(i); text$(i), _PrintWidth(text$(i))
  10.  
  11. FH2 = _LoadFont("Arial.ttf", 24, "MONOSPACE")
  12. _Font FH2
  13. For i = 0 To 10
  14.     Locate i + 1, 20: Print text$(i); text$(i), _PrintWidth(text$(i))
  15.  
  16.  

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Big ugly font difference between QB64 v1.4 and QB64 1.5 (and QB64 v2.0)
« Reply #14 on: October 23, 2021, 11:35:13 pm »
Repeat:
Quote
But now how can I get consistent width about .5 the height of a character? Like the default font, very easy to use and predict it's length, no matter the string, and looks normally spaced.

That Monospace is worthless to me, it's way too wide. How can I get like a guaranteed 12 X 24, 32 X 64, 48 x 96, 10 X 20 for all characters?