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

15 Best New Fonts, September 2024

Welcome to our roundup of the best new fonts we’ve found on the web in the previous four weeks. In this month’s edition…

3 Essential Design Trends, October 2024

This article is brought to you by Constantino, a renowned company offering premium and affordable website design You…

A Beginner’s Guide to Using BlueSky for Business Success

In today’s fast-paced digital world, businesses are always on the lookout for new ways to connect with their audience.…

The Importance of Title Tags: Tips and Tricks to Optimize for SEO

When it comes to on-page SEO, there’s one element that plays a pivotal role in both search engine rankings and user…

20 Best New Websites, September 2024

We have a mixed bag for you with both minimalist and maximalist designs, and single pagers alongside much bigger, but…

Exciting New Tools for Designers, September 2024

This time around we are aiming to simplify life, with some light and fast analytics, an all-in-one productivity…

3 Essential Design Trends, September 2024

September's web design trends have a fun, fall feeling ... and we love it. See what's trending in website design this…

Crafting Personalized Experiences with AI

Picture this: You open Netflix, and it’s like the platform just knows what you’re in the mood for. Or maybe you’re…

15 Best New Fonts, August 2024

Welcome to August’s roundup of the best fonts we’ve found over the last few weeks. 2024’s trend for flowing curves and…

Turning Rejection into Fuel: Your Guide to Creative Resilience

Rejection sucks. And for some reason, it’s always unexpected, which makes it feel like an ambush. Being creative is…

20 Best New Websites, August 2024

The overarching theme in this selection is simplicity. Minimalism never really goes out of fashion and with good…

Free AI-Website Builder, Scene, Helps With the Worst Part of Site Design

AI website design platform, Scene As we’ve been hearing constantly for the last couple of years, AI will soon replace…