Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font size in pixels

On an iPhone how do I calculate the size of a character in pixels for a given point size?

like image 493
Ian1971 Avatar asked Jun 29 '09 16:06

Ian1971


People also ask

How many pixels is font size?

What is a Point (pt)? A point (pt) is equal to 0.352778 millimeters, 0.0138889 inches, or 1.333 pixels.

What is normal size font size?

Font size is commonly expressed in points. Font sizes range from 8 point (extremely small) to 72 point (extremely large). The standard font size for most documents is 12 point.

What is font size 12pt?

The PT Sans font set to 12 pt in InDesign; the grey rectangle behind the font is 12 pt high which equals 4.233 mm and represents the body height.


2 Answers

Point sizes are defined as 1/72 of an inch. That is, a 72-point font is approximately 1 inch from the lowest descent to the highest ascent. So the maximum height of a glyph in a 72pt font is about 1 inch.

Apple's iphone tech specs page claims that the iPhone currently has a resolution of 163 pixels per inch. So 72 points is 163 pixels, or about 2.2639 pixels per point. Just remember that every glyph varies in height and width, so this is a very rough estimate of size. Generally, the distance between baselines will be a bit larger than the font's point size so that lines of text don't crash into each other.

If you need exact measurements (and you probably do) then you'll need to actually measure the font glyphs using the font metric information. You can do this by using NSString's UIKit additions, which will let you measure the size of a particular string when rendered on screen.

like image 155
Naaff Avatar answered Sep 21 '22 21:09

Naaff


To match font sizes (in Points) on the iPhone4 with font sizes (in Points) in Photoshop you have to set your Photoshop document to 144dpi. I have run a number of tests and that's the resolution that produces 1:1 results.

Steps:

  • Take a screenshot of “Settings » General » Accessibility » Large Text” on an iPhone4
  • Open the screenshot in Photoshop
  • Change the resolution from 72dpi to 144dpi with “Resample Image” off
  • Retype the text in Photoshop (in Points) to match size in the screenshot

I have gone through a number of different resolutions, including the 163dpi that was mentioned in the answer above, and I found that 144dpi produces 1:1 results. I have also tested this against a native app where I know the point sizes and the 144dpi was match there too.

like image 34
Kai Avatar answered Sep 18 '22 21:09

Kai