Author Topic: printing  (Read 3379 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo

  • Newbie
  • Posts: 5
    • View Profile
printing
« on: December 20, 2019, 02:48:54 pm »

    I hope a for a command in the next version, for to print in print in bold  and  double height. Sorry for my bad english, this is translated by Google

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: printing
« Reply #1 on: December 20, 2019, 04:30:01 pm »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: printing
« Reply #2 on: December 20, 2019, 04:32:25 pm »
If you want to print to the screen, just use _LOADFONT and _FONT.  If you’re wanting to print to paper, use _PRINTIMAGE.


Edit: Changed name to proper syntax, as pointed out by Fell below.  ;)
« Last Edit: December 20, 2019, 05:47:06 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: printing
« Reply #3 on: December 20, 2019, 05:18:41 pm »

Offline Theo

  • Newbie
  • Posts: 5
    • View Profile
Re: printing
« Reply #4 on: December 21, 2019, 07:27:36 am »
Thanks for the reply
I gone try all the comments

Thanks

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: printing
« Reply #5 on: December 21, 2019, 10:05:47 am »
Here is a way use the default font to any size:
Code: QB64: [Select]
  1. _TITLE "Text sub tests" 'B+ started 2019-03-25 mod 2019-12-21 twice
  2.  
  3. CONST xmax = 1200
  4. CONST ymax = 700
  5.  
  6. SCREEN _NEWIMAGE(xmax, ymax, 32)
  7. _SCREENMOVE 100, 40
  8.  
  9. DIM y, i
  10.  
  11. COLOR _RGB32(0, 0, 255), &HFFFFFFFF
  12. PRINT "Hello World, press any for Text sizing demo..."
  13.  
  14. y = ymax
  15. FOR i = 1 TO 15 STEP .5
  16.     CLS
  17.     y = y - 60 / i
  18.     cText xmax / 2, y, 240 / i, _RGB32(255, 0, 0), "So how is this looking?"
  19.     _DISPLAY
  20.     _LIMIT 2
  21. cText 600, 60, 32, &HFFFFBB00, "Hello World in orange at 2 X's normal font height."
  22. LOCATE 30, 1: PRINT "And this Back to normal PRINT and current color with this line... press any to end demo."
  23.  
  24. SUB Text (x, y, textHeight, K AS _UNSIGNED LONG, txt$)
  25.     DIM fg AS _UNSIGNED LONG, cur&, I&, mult, xlen
  26.     fg = _DEFAULTCOLOR
  27.     'screen snapshot
  28.     cur& = _DEST
  29.     I& = _NEWIMAGE(8 * LEN(txt$), 16, 32)
  30.     _DEST I&
  31.     COLOR K, _RGBA32(0, 0, 0, 0)
  32.     _PRINTSTRING (0, 0), txt$
  33.     mult = textHeight / 16
  34.     xlen = LEN(txt$) * 8 * mult
  35.     _PUTIMAGE (x, y)-STEP(xlen, textHeight), I&, cur&
  36.     COLOR fg
  37.     _FREEIMAGE I&
  38.  
  39. 'center the text
  40. SUB cText (x, y, textHeight, K AS _UNSIGNED LONG, txt$)
  41.     DIM fg AS _UNSIGNED LONG, cur&, I&, mult, xlen
  42.     fg = _DEFAULTCOLOR
  43.     'screen snapshot
  44.     cur& = _DEST
  45.     I& = _NEWIMAGE(8 * LEN(txt$), 16, 32)
  46.     _DEST I&
  47.     COLOR K, _RGBA32(0, 0, 0, 0)
  48.     _PRINTSTRING (0, 0), txt$
  49.     mult = textHeight / 16
  50.     xlen = LEN(txt$) * 8 * mult
  51.     _PUTIMAGE (x - .5 * xlen, y - .5 * textHeight)-STEP(xlen, textHeight), I&, cur&
  52.     COLOR fg
  53.     _FREEIMAGE I&
  54.  
  55.  

Update: fixed up demo, sizing does not work well really small like Richard Frost's
« Last Edit: December 21, 2019, 10:53:14 am by bplus »