[IOS] font size conversion for iOS

Source: Internet
Author: User

[IOS] font size conversion for iOS

1. px AND pt Conversion

Px: the unit of relative length. Pixel (Pixel ). (PS font)
Pt: the absolute length unit. Point ). (IOS font)
The formula is as follows:
Pt = (px/96) * 72.


2. font conversion
1in = 2.54 = 25.4 = 72pt = 6 pc
The specific conversion is:
Points Pixels EMS Percent
6pt 8px 0.5em 50%
7pt 9px 0.55em 55%
7.5pt 10px 0.625em 62.5%
8pt 11px 0.7em 70%
9pt 12px 0.75em 75%
10pt 13px 0.8em 80%
10.5pt 14px 0.875em 87.5%
11pt 15px 0.95em 95%
12pt 16px 1em 100%
13pt 17px 1.05em 105%
13.5pt 18px 1.125em 112.5%
14pt 19px 1.2em 120%
14.5pt 20px 1.25em 125%
15pt 21px 1.3em 130%
16pt 22px 1.4em 140%
17pt 23px 1.45em 145%
18pt 24px 1.5em 150%
20pt 26px 1.6em 160%
22pt 29px 1.8em 180%
24pt 32px 2em 200%
26pt 35px 2.2em 220%
27pt 36px 2.25em 225%
28pt 37px 2.3em 230%
29pt 38px 2.35em 235%
30pt 40px 2.45em 245%
32pt 42px 2.55em 255%
34pt 45px 2.75em 275%
36pt 48px 3em 300%

3. pixel and millimeter Conversion
The conversion also needs to know another parameter: DPI (How many points per inch)
Elephant prime number/DPI = inches
Inches x 25.4 = millimeters
There is a common method for display devices, whether they are printers or screens.
First use GetDeviceCaps (device handle, LOGPIXELSX)
Or
GetDeviceCaps (device handle, LOGPIXELSY) obtains the number of devices per inch
Recorded as: px and py
1 inch equals 25.4
The formula for converting millimeters into pixels is
Horizontal conversion: x * px/25.4
Vertical conversion: y * py/25.4
Pixel conversion to mm x * 25.4/px
Write this in the program
MyControl. Height: = 10 {mm} * PixelsPerInch * 10 div 254;
The numerator and denominator multiply by 10 to convert the floating point operation into an integer operation, which is more efficient.

The dpi calculated by standard resolutions such as 1024x768 or 800x600 is a constant: 96. Therefore, the relationship between the calculated millimeters and pixels is approximately equal to a constant:

Basically, 1mm is about 3.78 pixels.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.