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

0 Members and 1 Guest are viewing this topic.

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 #15 on: October 23, 2021, 11:44:04 pm »
Repeat:
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?

Choose a font designed in that 2:1 ratio by its designer.  Arial isn't a monospaced font natively, as that "W" is 3 times the width as that "l".  Check your system for monospace fonts and see how they're designed.  Many are on a .5 ratio, a few are .6, and I've seen some that are .8 ratios.  It all depends on how they were created at design time.

The only monospaced TrueType fonts shipped by Microsoft are Courier New, which shipped with Windows 3.1, and Lucida Sans Typewriter, which was included in the TrueType Font Pack. All other TrueType fonts included with Windows 3.1 and the TrueType Font Pack are proportional fonts.

If neither of those work for you, get one from here that you like: https://www.1001fonts.com/monospaced-fonts.html
« Last Edit: October 23, 2021, 11:49:30 pm by SMcNeill »
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 #16 on: October 24, 2021, 12:04:21 am »
Thankyou Steve, that link looks perfect but I will try the two as well.

Well looks like I have to rewrite my calendar code to fit in boxes, I am testing sub for centering unpredictable length text on x, y midpoints:

Code: QB64: [Select]
  1. Screen _NewImage(600, 600, 32)
  2. _Delay .25
  3.  
  4. Line (300, 50)-(500, 200), , B
  5. FH = _LoadFont("Arial.ttf", 24)
  6. If FH <= 0 Then Print "Trouble with font load file, goodbye.": Sleep: End
  7. CH = _FontHeight(FH): CW = _FontWidth(FH)
  8. Print "Hello World", CW, CH, _PrintWidth("Hello World")
  9. centerText (500 + 300) / 2, 100, "Hello World"
  10. FH2 = _LoadFont("Arial.ttf", 18)
  11. CH2 = _FontHeight(FH): CW2 = _FontWidth(FH2)
  12. _Font FH2
  13. Locate 2, 1
  14. Print "Hello World", CW, CH, _PrintWidth("Hello World")
  15. centerText (500 + 300) / 2, 150, "Hello World"
  16.  
  17.  
  18. Sub centerText (midx, midy, s$)
  19.     ' if you want to center fit a string between two goal posts x1, and x2
  20.     ' for midx plug in (x1+x2)/2 and let the computer do the calcs
  21.     pw = _PrintWidth(s$)
  22.     _PrintString (midx - pw / 2, midy - _FontHeight(_Font) / 2), s$
  23.  
  24.  
  25.  

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 #17 on: October 24, 2021, 12:18:14 am »
As long as you're using PRINTWIDTH and not FONTWIDTH, the only real change you'll probably need to make is to remove that last parameter from your LOADFONT statement.
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 #18 on: October 24, 2021, 12:44:01 am »
Courier and Lucinda pretty good as Monospaced:
Code: QB64: [Select]
  1. Screen _NewImage(600, 600, 32)
  2. _Delay .25
  3.  
  4. 'center lines
  5. Line (300, 50)-(500, 200), , B
  6. Line (300, 100)-(500, 100)
  7. Line (300, 150)-(500, 150)
  8. Line (400, 50)-(400, 200)
  9.  
  10. FH = _LoadFont("courbd.ttf", 24, "MONOSPACE") 'Courier New Bold
  11. If FH <= 0 Then Print "Trouble with font load file, goodbye.": Sleep: End
  12. CH = _FontHeight(FH): CW = _FontWidth(FH)
  13. Print "Hello World"; CW; CH; _PrintWidth("Hello World")
  14. centerText 500, 300, 100, "Hello World"
  15. FH2 = _LoadFont("LTYPEB.TTF", 10, "MONOSPACE") 'Lucinda Sans Typewriter  Bold
  16. CH2 = _FontHeight(FH2): CW2 = _FontWidth(FH2)
  17. _Font FH2
  18. Locate 4, 1
  19. Print "Hello World"; CW2; CH2; _PrintWidth("Hello World")
  20. centerText 500, 300, 150, "Hello World"
  21.  
  22.  
  23. Sub centerText (x1, x2, midy, s$) ' ' if you want to center fit a string between two goal posts x1, and x2
  24.     _PrintString ((x1 + x2) / 2 - _PrintWidth(s$) / 2, midy - _FontHeight(_Font) / 2), s$
  25.  
  26.  
  27.  

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 #19 on: October 24, 2021, 10:01:53 am »
Update: Just removing the "MONOSPACE" did easily fix my calendar update, thanks again plus, I now have a couple ways to manage fonts either by Monospace with a proper Monospace font or use CenterText sub perhaps with a mod for destination handle. I just got a new printer going and I am sure this issue of fitting font inside rectangles will come up again.

PS learned MONOSPACE no longer required for .ttf type files.