The designer’s guide to pixel hinting

Default avatar.
March 17, 2014
The designer’s guide to pixel hinting.

thumbnailPixel-perfect icons and typography stand out among the crowd online. Obviously we all want to strive for such refined work, but sometimes even after trying we still end up with something a little... less. Pixel Hinting is one of the skills that takes an automatic feature and improves upon its results. Despite the ultra high resolution of displays today—like Apple’s retina displays—we still need to “fake” smooth curves lest we end up with a pixelated mess.

Many designers and developers are moving more towards SVG and vector based approaches now; with the support only getting better by the day. But even so, vector based solutions have a long way to go before they’re mature enough to use in production. SVG is great for displaying vector shapes, but not so hot at resizing those shapes. So like everything else out there, there is a time and place for each solution.

What are vectors?

Vectors are essentially rendered results of the mathematical representation of a shape. When you see anything on your screen, it’s because your computer rendered those objects and bound them to the pixels on your display. In doing so, your computer has also made decisions on what should, and shouldn’t, be displayed as whole pixels. For example, the uppercase letter “D” has both a perfectly straight line, and a curved one.

001

As you can see, without anti-aliasing the curved line on the “D” is quite pixelated. So to compensate, when vector shapes are rendered they are usually anti-aliased to provide a more... robust appearance. Instead of only displaying pixels that fall within the vector outline entirely, pixels are gradually shaded out. This tricks your brain into seeing a smoother line on curved shapes that don’t snap to the pixel grid perfectly.

002

Above you can see how the rendered “D” is given what is called half-pixels to help remove the jagged pixelation. However, this same feature also introduces a problem: computers are awful at figuring out what is visually appealing. So while adding these half-pixels makes the rounded corners look fantastic, it also makes the top/bottom inner line look blurred. The automatic anti-aliasing that occurs when a vector shape is rendered ends up making most parts of shapes and typography look great, but leaves others at an even worse quality than it started with.

Hello, pixel hinting.

Now that you have a short background on vector shapes and how they work, let’s jump into the real work. Pixel hinting involves moving the vector’s anchor points to rest on pixel borders in a more aesthetically pleasing way. Making those straight lines more perfect, while still leaving the half-pixels to the curves. Most commonly, pixel hinting is used on typography and shapes for raster images (logos, icons, branding, etc). Now, most importantly, in order to properly adjust your vector it must be in the size and shape you want it. Once you’ve pixel hinted your work, rotating or resizing it could—and probably would—throw all that work away by automatically anti-aliasing it again. Before we get started make sure the following settings are adjusted (I’ll be using Photoshop for this task):

  • Turn on your pixel grid (View > Show > Grid, also make sure Extras is checked above the Show menu)
  • Make sure your grid has a gridline every 10 pixels, with 10 subdivisions. Or something similar so that there is a line between each pixel.
  • Disable snapping (View > uncheck snap). We don’t want anchor points snapping at 1px increments, we want to move points within pixels.

Pixel hinting typography

The process for doing shapes vs typography is slightly different, so I’ll walk you through both. Ideally with typography, you want to kern your type before or during your hinting process. Regardless, pixel hinting should be one of the last things you do.

First, select the typography you want to pixel hint and make a copy of the layer, then transform that layer into a shape.

003

You can see that the text falls awkwardly off the grid, both on the horizontal as well as the vertical axis. To fix this, we’re going to gently nudge each letter’s anchor points until they align more closely with the pixel grid laid out. The goal, is to get the shape lines close, if not directly on, the grid lines. Zoom in to nudge anchor points more precisely. While doing this, frequently zoom out to ensure your adjustments look alright.

You don’t want to conform precisely to the grid, as that takes away the advantages of anti-aliasing in the first place. Instead, try to simply keep things consistent—only allow half-pixels on one side of each axis. For example, I always allow half-pixels to the right and top of letters, while forcing the left and bottom edges flush to the grid.

004

As you can see, the “get in” has been roughly adjusted, while the “touch” remains as is. Just like kerning, pixel hinting is much more of a craft than a science. It takes a keen eye to look and discern whether the work looks better or worse after adjustment. Don’t be discouraged if you find typographical pixel hinting rough, iterate and keep working with it. If your result still looks sub-par, you can always delete the layer and copy fresh from the original again. It takes some time to get typography in particular to look great, just keep going and sooner or later your hard work will pay off.

Pixel hinting vector shapes

Generally, pixel hinting shapes is reserved for icons or logos. Again, you want to make sure your shape is at the size and rotation you want it before starting as adjusting it later could throw away all your hard work. Adjusting shapes is a lot easier and requires less of an eye for intrinsic detail. That being said, more complex shapes take longer and are harder to adjust, so it’s best to start with something simple.

005

Above, you can see that our arrow and circle sit just slightly off where we would like them. The half-pixels created by anti-aliasing are causing the entire shape to look blurry as a result. So let’s nudge everything to fall on the grid a little better.

006

There we go! By adjusting the anchor points to line up with the grid, we end up with a much sharper icon. It’s important to mention that since this icon is a circle, any adjustments to the width had to also be mirrored to the height as well. Also, don’t forget to make sure the inside of the shape looks good and consistent as well. If you look at the previous image you’ll notice the inside sides of the circle aren’t anti-aliased the same.

007

In conclusion

With the work above, the result is an image that looks sharper and more professional. Of course, you can apply these techniques to much more important things than a button.

While the automatic anti-aliasing done by your computer looks acceptable, it could be better. So when it comes to your logo or important icons/typography in raster form, pixel hinting is more than just a niche skill; until the day we’re all using high pixel density displays, it’s essential.

Dustin Cartwright

Dustin Cartwright is a UI/Web Designer & Front-End Developer from Baltimore, Maryland. He spends the majority of his time focusing on user experience research and is passionate about building things for the web.

Read Next

20 Best New Websites, April 2024

Welcome to our sites of the month for April. With some websites, the details make all the difference, while in others,…

Exciting New Tools for Designers, April 2024

Welcome to our April tools collection. There are no practical jokes here, just practical gadgets, services, and apps to…

14 Top UX Tools for Designers in 2024

User Experience (UX) is one of the most important fields of design, so it should come as no surprise that there are a…

What Negative Effects Does a Bad Website Design Have On My Business?

Consumer expectations for a responsive, immersive, and visually appealing website experience have never been higher. In…

10+ Best Resources & Tools for Web Designers (2024 update)

Is searching for the best web design tools to suit your needs akin to having a recurring bad dream? Does each…

3 Essential Design Trends, April 2024

Ready to jump into some amazing new design ideas for Spring? Our roundup has everything from UX to color trends…

How to Plan Your First Successful Website

Planning a new website can be exciting and — if you’re anything like me — a little daunting. Whether you’re an…

15 Best New Fonts, March 2024

Welcome to March’s edition of our roundup of the best new fonts for designers. This month’s compilation includes…

LimeWire Developer APIs Herald a New Era of AI Integration

Generative AI is a fascinating technology. Far from the design killer some people feared, it is an empowering and…

20 Best New Websites, March 2024

Welcome to our pick of sites for March. This month’s collection tends towards the simple and clean, which goes to show…

Exciting New Tools for Designers, March 2024

The fast-paced world of design never stops turning, and staying ahead of the curve is essential for creatives. As…

Web Tech Trends to Watch in 2024 and Beyond

It hardly seems possible given the radical transformations we’ve seen over the last few decades, but the web design…