QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Theo on December 20, 2019, 02:48:54 pm

Title: printing
Post by: Theo 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
Title: Re: printing
Post by: Petr on December 20, 2019, 04:30:01 pm
Hi Theo,
Try using this https://www.qb64.org/forum/index.php?topic=1958.msg111894#msg111894
Title: Re: printing
Post by: SMcNeill 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.  ;)
Title: Re: printing
Post by: FellippeHeitor on December 20, 2019, 05:18:41 pm
Code: QB64: [Select]
Title: Re: printing
Post by: Theo on December 21, 2019, 07:27:36 am
Thanks for the reply
I gone try all the comments

Thanks
Title: Re: printing
Post by: bplus 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