The trouble with italic

Discussions related to graphics (2D and 3D), animation and games programming
User avatar
5against4
Posts: 21
Joined: Tue 03 Apr 2018, 11:57
Location: The Cotswolds

The trouble with italic

Post by 5against4 »

i'm guessing that this is simply a by-product of the way BB4W works with fonts, but is there any way to avoid the nasty clipping effects that occur when using italic? Namely:

Image

It's purely an aesthetic concern rather than a functional one, of course, but all the same…
DDRM

Re: The trouble with italic

Post by DDRM »

I think the issue is that in the "normal" print mode the background of letters is opaque (overwrites whatever was underneath with background colour).

One solution would be to use VDU 5 mode, when text is written at the graphics cursor. In this mode the character backgrounds are transparent, so won't overwrite the previous character. I tried this, but it doesn't work unless you print each character individually, which means you have to take responsibility for the kerning, which would be a major undertaking... I tried using WIDTH, but as it says in the manual, it can't really handle proportionally spaced and/or italic fonts - and asking it to handle single characters is probably unreasonable (and certainly unsuccessful in my hands!).

Here's one of my attempts, which is probably worse than just printing it!

Code: Select all

      *FONT Times New Roman,24,I
      PROCPString(100,100, "Hello world")
      PRINT "And again Hello!"
      END
      DEFPROCPString(px%,py%,s$)
      LOCAL x%,c$,dx%
      VDU 5
      FOR x%=0 TO LEN(s$)-1
        c$=MID$(s$,x%+1,1)
        dx%=WIDTH(c$)+4
        px%+=dx%
        MOVE px%,py%
        PRINT c$
      NEXT x%
      VDU4
      ENDPROC
User avatar
5against4
Posts: 21
Joined: Tue 03 Apr 2018, 11:57
Location: The Cotswolds

Re: The trouble with italic

Post by 5against4 »

DDRM wrote: Wed 20 Jun 2018, 08:27 I think the issue is that in the "normal" print mode the background of letters is opaque (overwrites whatever was underneath with background colour).

One solution would be to use VDU 5 mode, when text is written at the graphics cursor. In this mode the character backgrounds are transparent, so won't overwrite the previous character. I tried this, but it doesn't work unless you print each character individually…
Ah, i hadn't realised that VDU5 uses transparent character backgrounds. That's solved the problem (this problem was only occurring in a section of the program where i hadn't been using VDU5) - i haven't experienced the issues you found where you needed to print each character individually, it was fine straight away:

Image

Thanks for another quick and easy solution! :D
RichardRussell

Re: The trouble with italic

Post by RichardRussell »

DDRM wrote: Wed 20 Jun 2018, 08:27I tried this, but it doesn't work unless you print each character individually, which means you have to take responsibility for the kerning, which would be a major undertaking
There's a double misunderstanding here. One is that to take advantage of the transparent background in VDU 5 mode you must output each character individually: that's not the case, you can output an entire italic string without clipping. The other is that you "have to take responsibility for kerning": BBC BASIC doesn't natively support kerning at all, whether you output characters individually or as a string there will be no kerning! Even the Windows GetTextExtentPoint32 function returns the dimensions of a string without taking into account kerning.