LB Booster
Programming >> Liberty BASIC language >> Font smoothing?
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1436966528

Font smoothing?
Post by Monkfish on Jul 15th, 2015, 1:22pm

When I print text into a graphics box the text is displayed with smoothing under Vista and Win8 (if the user has this feature enabled under the desktop settings).

Is there a way I can print text into a graphics box without the smoothing and without the user having to change their desktop settings?
Re: Font smoothing?
Post by Richard Russell on Jul 15th, 2015, 4:12pm

on Jul 15th, 2015, 1:22pm, Monkfish wrote:
Is there a way I can print text into a graphics box without the smoothing and without the user having to change their desktop settings?

If by "smoothing" you mean antialiasing one way would be to create the font using the Windows API, which gives you full control (you could for example adapt code for printing text on a slope). But why would you want to reduce the text quality?

Richard.

Re: Font smoothing?
Post by Monkfish on Jul 15th, 2015, 10:18pm

Well I have to print the text into the graphics box at 8pt size and at this size the AA makes the characters look ugly and indistinct. I really need them to be nice and crisp like standard 8pt texts.

The setting that needs to be changed is under Windows Color & Appearance > Open Classic Appearance Properties > Effects > Use Following Method to Smooth Edges > (Clear or Standard). I need it set to Standard.
Re: Font smoothing?
Post by Richard Russell on Jul 15th, 2015, 10:51pm

on Jul 15th, 2015, 10:18pm, Monkfish wrote:
Well I have to print the text into the graphics box at 8pt size and at this size the AA makes the characters look ugly and indistinct. I really need them to be nice and crisp like standard 8pt texts.

Here's a direct comparison (Arial, 8pt):

User Image

I actually prefer the antialiased version; I wouldn't call it "ugly and indistinct", but YMMV.

Richard.
Re: Font smoothing?
Post by Rod on Jul 16th, 2015, 06:25am

Perhaps the ugliness is more to do with the SIZE parameter since this has an influence over resolution. What pixel width is your drawing and what SIZE parameter are you using to print the image?
Re: Font smoothing?
Post by Richard Russell on Jul 16th, 2015, 08:55am

on Jul 16th, 2015, 06:25am, Rod wrote:
Perhaps the ugliness is more to do with the SIZE parameter since this has an influence over resolution. What pixel width is your drawing and what SIZE parameter are you using to print the image?

I didn't realise the OP was doing any (hardcopy) printing; his only reference was to "printing text into a graphics box". If indeed output to a printer is involved then that puts a quite different complexion on the issue.

Richard.
Re: Font smoothing?
Post by Monkfish on Jul 16th, 2015, 2:55pm

Well I am using 8pt Lucida Console which has characters 7*11 pixels in size. Here is what they look like on the screen and when magnified 2x. Yes I am printing it too.

https://www.dropbox.com/s/3b26v49xrq4quxp/hello%20world.gif?dl=0

Got the antialiased and non-antialiased the wrong way round but you see what I mean. Look at the "W" for example. Not sure how I insert images into these posts.
Re: Font smoothing?
Post by Richard Russell on Jul 16th, 2015, 8:43pm

on Jul 16th, 2015, 2:55pm, Monkfish wrote:
Here is what they look like on the screen and when magnified 2x.

Was that created using LBB v3.00? What puzzles me is that several of the letters (including the W) appear to have been clipped, which is one reason why they look so ugly. But LBB is not supposed to clip characters printed to a graphics window.

Here is what I get with 8pt Lucida Console at 96 DPI (magnified 2x):

User Image

The characters are not clipped in this case. huh

Richard.
Re: Font smoothing?
Post by Monkfish on Jul 17th, 2015, 11:21am

The word "clipped" got me thinking. Yes, I expect they are clipped, because I am drawing them with a 7 pixel spacing (as they should be) but the antialiasing seems to overlap from one character to the next, so when I print the following character it clips the previous one. I expect I can change the print options to merge with what is already there.

Anyway, for reasons to long to explain, I need the characters without antialiasing and ideally without the user needing to change their windows settings. Is there no easy way?

I suppose I could create a copy of the standard character set and copy each character into position using the drawbmp command?

Your characters still look different to mine. I'm using the statement:

print #main.gfx, "font Lucida_Console 0 11"

I need the characters to be 7x11

Yes I am using version 3.0
Re: Font smoothing?
Post by Richard Russell on Jul 17th, 2015, 1:10pm

on Jul 17th, 2015, 11:21am, Monkfish wrote:
Your characters still look different to mine. I'm using the statement:
print #main.gfx, "font Lucida_Console 0 11"

Ah, you said you were drawing 8pt text so that's what I specified in my program.

Quote:
I need the characters to be 7x11

So why don't you explicitly specify a width of 7 pixels rather than allowing Windows to choose the width (which may be 7 pixels, but there's no guarantee):

Code:
print #main.gfx, "font Lucida_Console 7 11" 

Quote:
Is there no easy way?

Well, as I said, the most straightforward way is to call the CreateFont API directly - I would class that as relatively easy, and it's the method I used to create the bitmap I uploaded. Here's my program, adapted to force the cell width and height; if it doesn't give identical results to yours now I'm mystified:

Code:
    open "Test" for graphics as #w
    #w "font Lucida_Console 7 11"
    #w "\\Hello World! (antialiased)"

    calldll #gdi32, "CreateFontA", 11 as long, 7 as long, _
      0 as long, 0 as long, 400 as long, 0 as long, 0 as long, _
      0 as long, 0 as long, 0 as long, 0 as long, _
      _NONANTIALIASED_QUALITY as long, 0 as long, _
      "Lucida Console" as ptr, hf as ulong

    hw = hwnd(#w)
    calldll #user32, "GetDC", hw as ulong, hdc as ulong
    calldll #gdi32, "SelectObject", hdc as ulong, hf as ulong, _
      oldhf as ulong
    calldll #gdi32, "DeleteObject", oldhf as ulong, ret as long

    #w "\Hello World! (non-antialiased)"

    #w "getbmp bitmap 0 0 210 24"
    bmpsave "bitmap", "C:\temp\lbbaa.bmp"
    wait 

Richard.

Re: Font smoothing?
Post by Monkfish on Jul 17th, 2015, 2:58pm

Thanks Richard, I'll give it a whirl. smiley
Re: Font smoothing?
Post by Monkfish on Jul 17th, 2015, 7:48pm

I would like to make a donation Richard for all the help you have given me and all your efforts with LBB. Does that $6.99 at the bottom go to you?
Re: Font smoothing?
Post by RobM on Jul 17th, 2015, 8:24pm

on Jul 17th, 2015, 7:48pm, Monkfish wrote:
... Does that $6.99 at the bottom go to you?


No, that goes directly to Conforums, this forum's host.
Re: Font smoothing?
Post by Monkfish on Jul 17th, 2015, 8:48pm

I'm sure that conforums are very deserving too smiley
Re: Font smoothing?
Post by Richard Russell on Jul 17th, 2015, 8:54pm

on Jul 17th, 2015, 1:10pm, Richard Russell wrote:
Here's my program...

Something to be aware of if you care about LB 4.04 compatibility: my program works but seemingly only once; thereafter the 'native' font selection seems to be broken. Perhaps it's necessary to select the original font back before exit; I don't know (and TBH I don't really care, since it works fine in LBB as is).

Richard.
Re: Font smoothing?
Post by Monkfish on Jul 18th, 2015, 07:17am

That's okay, I don't use LB anymore wink
LBB error reporting - an apology.
Post by Richard Russell on Jul 18th, 2015, 10:09am

on Jul 18th, 2015, 07:17am, Monkfish wrote:
That's okay, I don't use LB anymore wink

In that case I need to apologise to you, and to other LBB users, for the shockingly poor error reporting of LBB compared with LB. Even I find myself occasionally running a program under LB 4.04 if LBB throws an incomprehensible error (typically with the line number given as zero!); usually LB will identify the cause.

In my, feeble, defence I would explain that in the early days LB Booster was envisaged only as something you ran to 'boost' an existing, tested and debugged, program. The assumption was that, as the program was known to run in LB, LBB didn't need to do comprehensive error checking.

Sadly, when LBB was developed into more of a standalone product the error reporting wasn't improved, as it should have been. My efforts went into checking for bugs and in maximising compatibility, all of which involved running only error-free programs, not programs with faults. sad

I have a longish wish-list of possible enhancements to LBB's error reporting, if and when I release an upgrade. That's only likely to happen if the LB community change their attitude to LBB, and my ban from the forums is rescinded. As things stand that seems very unlikely.

Richard.
Re: Font smoothing?
Post by Monkfish on Jul 18th, 2015, 1:22pm

I'm surprised the entire LB community hasn't jumped ship!

I wish you had a link to allow those of us who appreciate your efforts to reward you in some small way. If there was some issue with that it could always be presented as a contribution for your support, rather than for the program itself.
Re: Font smoothing?
Post by Richard Russell on Jul 18th, 2015, 2:38pm

on Jul 18th, 2015, 1:22pm, Monkfish wrote:
I wish you had a link to allow those of us who appreciate your efforts to reward you in some small way.

The greatest reward you can possibly offer is to spread the word about LBB. The efforts of the wider LB community to prevent users finding out about it, and if they do to knock it as being "not Liberty BASIC"*, are sadly all too successful.

But if you particularly want to make a monetary contribution - even though it doesn't go to me - you can click on the Donate button at the bottom of the page. Each donation gives us another ad-free month (the forum was ad-free for a long time owing to the generosity of one member, but his contributions have now run out).

Richard.

*I went to great trouble to make sure the OOP and SEH extensions to LBB did not affect compatibility with LB4, but that didn't stop Carl claiming that they do, and that, somehow, they make LBB less attractive to LB users.