font size : Java Glossary


fonts  font size
Introduction Fixes For CSS
CSS Units of Measure Fixes For Java
The Wandering Font Size Problem Learning More
Proposed Fixes Links


Font size is slippery as a trout. I don’t think it is even formally defined. You pretty well have to experiment to find out what any given requested size results in, on any given browser, on any given font face, on any give platform. The results are different in CSS (Cascading Style Sheets) and Java. All you can truly count on is that requesting bigger font sizes will not result in smaller fonts.

CSS Units of Measure

CSS units of measure have to taken with a large grain of salt. Browsers have zoom features which can magnify or shrink. Printers have variable resolution. Tiny screens can now have as many dots as desktop screens. It is wise experiment with the various browsers, printers, devices, OSes to see the final effects. As a rule of thumb, avoid absolute units like px, pt, cm and inch as much as possible and use % or em.

CSS Units of Measure
Unit Meaning Notes
px pixels I found that a 20px font in CSS is not the same size as one in Java, even with the same font face.
pt points Nominally one PostScript point. Postscript points are 1/72 inch. Printer points are 1/72.2 inch. Java points are 1 pixel. You really have to experiment to see the effect.
em m widths Usually used to defined font sizes. 2em means twice the size of the current font. Think of it as a size multiplier having nothing to do with printer ems.
% percentage 100% does nothing. 110% makes an element/font 10% bigger than it would normally be.
cm cm Even though this is nominally an absolute unit, it will rarely result is exactly 1 centimeter on screen or on the printed page.
mm mm Even though this is nominally an absolute unit, it will rarely result is exactly 1 millimeter on screen or on the printed page.
in inch Even though this is nominally an absolute unit, it will rarely result is exactly 1 inch on screen or on the printed page.
ex x-height height of the letter x in a font. Usually about half the font height. I don’t know how this is intended to be used. Perhaps it is for scaling margins.
pc picas 12 points. 1/6 inch. There are five different definitions for pica in typesetting.

The Wandering Font Size Problem

Font size is poorly defined. What determines the final size of type on your screen is controlled by four factors.
  1. The font designer

    A nominally 10-point type can be tiny or huge. It depends on the whim of the artist who designed the font. The nominal font size has little to do with the height in pixels of some letter of the alphabet. For example TiresiasPCFont-Z is huge whereas KodchiangUPC is tiny.
  2. Windows

    There is a setting in the control panel ⇒ Personalisation ⇒ Adjust Font Size DPI (Dots Per Inch) to globally adjust font sizes to accommodate visual acuity. This does not work very well since most Windows apps use bigger fonts but don’t correspondingly adjust the dialog boxes bigger to hold them.
  3. Browser and CSS

    For example, in the Opera and Chrome browsers there is a Zoom command to zoom in and out making the type bigger or smaller. CSS has the further complication of default fonts which could be implemented by different physical fonts with different font metrics on different platforms: cursive, fantasy, monospace, sans-serif and serif.
  4. Java

    When Applets select a font size, the JRE (Java Runtime Environment) scales the font to a corresponding number of pixels tall. In Windows, this overrides the browser and the operating system, but not the font designer. Java has the further complication of logical fonts which could be implemented by different physical fonts with different font metrics on different platforms: Dialog, DialogInput, Monospaced, SansSerif and Serif.

The problem is when CSS or Java substitutes a font for the one used to design and suddenly the layout is unusable because the replacement font, nominally the same size, is actually much larger or smaller.

The same problem bedevils word processors, but there the operator usually notices the problem and manually adjusts.

Proposed Fixes

Fixes For CSS

What sort of syntax could you introduce into CSS so that you could use either the old size system or the new and still be upwardly compatible?

Fixes For Java

What sort of solution might you provide for Java?

Learning More

Oracle’s Javadoc on Font class : available:
Oracle’s Javadoc on FontMetrics class : available:

BestFont: part of the common18 package

This page is posted
on the web at:

Optional Replicator mirror
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number