Wednesday, March 25, 2009

How to enable font anti-aliasing in Wine

What is Aliasing?
All computer displays show images in bitmap mode. What this means is that every image is really a bunch of tiny little squares that make up the image. What this essentially means is that computers can't display really smooth curves.

These two letters are printed with the same font face, size, and style. The only difference between them is that the top letter is aliased and the bottom is not.

As you can see, the top letter has a jagged, "stair-step" effect that is the hallmark of aliasing. It is the way that computers display curves on the screen. The bottom letter, on the other hand, has a smoother, fuzzier look to it. It is anti-aliased to simulate the look of a smooth curve on the screen.

How does anti-aliasing work?
Anti-aliasing works with the way that our eyes see things. Human eyes do not see in as precise detail as we would like to think. In reality, the mind converts the images into what it "thinks" they are supposed to look like.

With anti-aliasing, the curve is created with squares of color that are shaded darker or lighter depending on how much of the curve would take up that square. For instance, if a portion of a curve takes up 10% of a pixel, that pixel would be shaded with 10% of the color saturation of the curve.

What this amounts to is that anti-aliasing adds shading along the curve to "fool the eye" into thinking it's seeing a smooth curve rather than a jagged bitmap.

Anti-aliasing Pros and Cons
Pros

  • Makes fonts look smoother
  • Rounded edges look round
  • Type is easier to read (for some) because it looks more like what printed type looks like
  • It's just plain prettier (some would argue)

Cons

  • Small fonts become too fuzzy to read
  • Sharp edges may be fuzzy and not precise
  • You can't print anti-aliased text as it comes out blurred
  • Images are generally larger
  • Type is easier to read (for some) because the blurring is reduced and the fonts are clear

Understanding Antialiasing and Transparency

Introduction

When designing web pages, you will often wish to incorporate graphic elements. The easiest way to include graphics is through the use of images.

Images, though, have two fundamental limitations for supporting graphic elements. First, rather than being vector-based (as are text and graphics created in programs such as Illustrator), images are a collection of pixels. Second, images are always rectangular.

In order to make your graphics look as smooth and accurate as possible, and in order to seamlessly integrate them into your design, you will need to understand antialiasing, and how it relates to transparency. This tutorial will explain the basics of antialiasing, and how to use succesfully use it in tandem with transparency.

Aliasing

The term aliasing pertains to the process of sampling something smooth and continuous using a series of discrete measurements. If the measurements do not accurately represent the function, unwanted artifacts which are not present in the original will appear. The appearance of these artifacts is referred to as aliasing.

In our case, the smooth and continuous feature we are interested in is vector data, such as text or an illustration. The sampling that occurs is due to rasterization: the process of converting vector data into pixel data. The limitation of this representation is that while vector data can represent limitless shapes and has infinite resolution, pixels are square and are relatively large.

This limitation isn't visible when dealing with rectangular objects, as in the images below:

Rectangular features, even when magnified (right) suffer from no visual artifacts.

As soon as we deviate from rectangular shapes, however, we begin to see some unwanted artifacts.

Diagonal lines are rendered less accurately. A magnified view demonstrates jaggies.

These unwanted artifacts, often called stairsteps or jaggies, are a form of aliasing. They'll appear whenever we attempt to represent a shape that deviates from a rectangle.

Antialiasing

As you have probably surmised, antialiasing (or sometimes, anti-aliasing) refers to methods of eliminating (or most often, reducing) these unwanted artifacts. In the context of rasterizing images, antialiasing refers to the reduction of the jagged borders between colors.

The example below demonstrates the most effective technique of antialiasing graphics: taking advantage of the many levels of color that our monitors can represent.

Here is a simple image that is still complex enough to show jaggies when rendered. This is even more noticeable in the detail image.

A large atmark rendered without antialiasing.

Here is the same image rendered using antialiasing. Note how much smoother this image appears, and how much better integrates into the background.

Antialiasing smoothes out the jaggies.

The detail image should demonstrate the basics of how antialiasing works with images. Rather than only using black and white pixels, intermediate levels of gray are used to blend the pixels together. The amount of black or white used represents how much the original graphic covers a pixel. A fully covered pixel will be black. One that is not covered at all will be white. One that is halfway-covered will be gray.

In this case the border pixels are shades of gray because the foreground is black and the background is white. If the foreground were red, however, the border pixels would be shades of pink.

With a red foreground and a white background, intermediate pixels are pink.
When anti-aliasing is working Winecfg should look like this. (on Wine 1.1.0)


To enable smoothed fonts in Wine you will need to run regedit and change these settings.

REGEDIT4

[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
"FontSmoothingType"=dword:00000002
"FontSmoothingGamma"=dword:00000578
"FontSmoothingOrientation"=dword:00000001

You may also want to install the free windows core fonts and even the
Tahoma font. Most Linux/Unix operating systems come with nice fonts also such as the Liberation font set.

OK, this sounds like chinease to you...Don't worry their is a handy little script that will do everything for you as
Wine has supported font smoothing, including subpixel since wine 1.1.12.

Here is a screenshot of the script running.


Wine font smoothing english version can downloaded from here.
And a Russian version can be downloaded from here.

To run the script:

wget http://files.polosatus.ru/winefontssmoothing_en.sh
bash winefontssmoothing_en.sh


6 comments:

DAVID said...

you blog is very interesting to read ..

Anonymous said...

It was very interesting for me to read this blog. Thank you for it. I like such topics and anything that is connected to them. I definitely want to read a bit more soon.

Anonymous said...

It is very interesting for me to read that blog. Thank you for it. I like such topics and everything connected to this matter. I definitely want to read a bit more soon.

Anonymous said...

Don't stop posting such themes. I like to read stories like this. BTW add some pics :)

Juiz de Meia-Tigela said...

I was looking for this information, thank you, the script worked very well :)

Anonymous said...

To enlarge and enable windows fonts of wine follow this tip

http://tips-linux.net/en/content/install-windows-fonts-wine