MinGW AlphaBlend

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Kotlov
Posts: 266
Joined: Fri Jul 10, 2015 9:23 pm
Location: Russia

Re: MinGW AlphaBlend

Post by Kotlov »

Why not use TrueType fonts?
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: MinGW AlphaBlend

Post by hgm »

WinBoard already can do that. But there is no anti-aliasing during their rendering. Are there more modern routines that do render TrueType fonts with anti-aliasing? If so, that would make a great improvement to.
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: MinGW AlphaBlend

Post by kbhearn »

I had thought truetype fonts had antialiasing by default - so i went to do some reading. This article seems to give a good overview on font rendering technology.

https://www.smashingmagazine.com/2012/0 ... rendering/

Short version:

antialiased truetype has been around since windows xp at least with rendering in grayscale mode which works acceptably for large font sizes

cleartype became the default rendering method in windows vista - this only provides horizontal antialiasing and large font sizes have jaggies

directwrite is the current modern technology to replace GDI and does a good job of antialiasing in both directions and works with postscript fonts as well
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: MinGW AlphaBlend

Post by jdart »

Arasan uses TrueType fonts but the problem is not only anti-aliasing but also rendering them as Black or White colors on a (possibly) colored background - I have not found a good way to do that.

Many of the freeware GUIs now use vector graphics, in particular SVG, which seems to be a reasonable choice, although Windows has no native SVG support that I am aware of, so you need 3rd party code such as Cairo.

--Jon
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: MinGW AlphaBlend

Post by JoshPettus »

Well cairo AFIK requires gtk so now you are in compiling xboard for windows territory.
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: MinGW AlphaBlend

Post by Dann Corbit »

https://github.com/behdad/glyphy
Glyphy is really interesting. Runs smooth and fast on GPU cards.
There are videos about it. I made it work on a PC some time ago.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: MinGW AlphaBlend

Post by hgm »

jdart wrote:Arasan uses TrueType fonts but the problem is not only anti-aliasing but also rendering them as Black or White colors on a (possibly) colored background - I have not found a good way to do that.
Allesandro Scotti added the code for doing TrueType Chess fonts in WinBoard, and this could very well have predated Win XP. OTOH, his choice to use pure black and white might have been intentionally, to solve the coloring problem. What he did is render the glyphs on a background of the desired color for the inside of the pieces, and then flood-fill the outside from the corners with the desired background.

Flood-filling works poorly on anti-aliased edges. In addition, if the glyph is rendered very small, the impression of thin lines will be created by dashing/dotting them. So the outlines will no longer be 'air tight', and the flood fill of the outside will leak into the inside, effectively making the piece transparent.

So we would need a better algorithm. One approch could be to render the glyph both on a backround for the inside and for the outside, and then somehow construct an all-or-nothing mask that selects one or the other. In the hope that the ragged boundary of this mask falls completely in the black outline of the piece, which should be pure black in both images (if the outline is thick enough).

It would be nice if this mask could be made by flood-filling the glyph for the black piece from the outside; black pieces are usually solid, so nothing can leak in. Unfortunately black pieces do not always have exactly the same shape as white pieces, in Chess fonts, though.
User avatar
Kotlov
Posts: 266
Joined: Fri Jul 10, 2015 9:23 pm
Location: Russia

Re: MinGW AlphaBlend

Post by Kotlov »

hgm wrote:. Unfortunately black pieces do not always have exactly the same shape as white pieces, in Chess fonts, though.
It solved the superposition of two picturels on one another (lower mask and the main picture).
Most chess fonts present this mask.
Patrice Duhamel
Posts: 193
Joined: Sat May 25, 2013 11:17 am
Location: France
Full name: Patrice Duhamel

Re: MinGW AlphaBlend

Post by Patrice Duhamel »

hgm wrote:Are there more modern routines that do render TrueType fonts with anti-aliasing? If so, that would make a great improvement to.
Freetype library is a good choice to render texts, with anti aliasing.

https://www.freetype.org/
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: MinGW AlphaBlend

Post by Evert »

JoshPettus wrote:Well cairo AFIK requires gtk so now you are in compiling xboard for windows territory.
Does it?
It's certainly bundled with gtk, and most tutorials assume you want to combine them. However, you can also use Cairo with plain XLib and with Qt, so it seems gtk is not required.
Of course that doesn't imply you can use it directly on Windows...