Re: Layout

Paul Rohr (
Wed, 13 Oct 1999 08:25:44 -0700

Since we're on the topic, here's the relevant snippet from the Win32 SDK


The character placement and line spacing metrics enable an application to
compute device-independent line breaks that are portable across screens,
printers, typesetters, and even platforms.

Device-independent page layout requires the following seven basic steps:

1. Normalize all design metrics to a common ultra-high resolution (UHR)
value (for example, 65,536 DPI); this prevents round-off errors.

2. Compute line breaks based on UHR metrics and physical page width; this
yields a starting point and an ending point of a line within the text stream.

3. Compute the device page width in device units (for example, pixels).

4. Fit each line of text into the device page width, using the line breaks
computed in step 2.

5. Compute page breaks by using UHR metrics and the physical page length;
this yields the number of lines per page.

6. Compute the line heights in device units.

7. Fit the lines of text onto the page, using the lines per page from step 5
and the line heights from step 6.

If all applications adopt these techniques, developers can virtually
guarantee that documents moved from one application to another will retain
their original appearance and format.


For more details on the Win32 API calls provided to get the necessary
information for such an algorithm, see the rest of the page at:

However, before using some of the more complex metrics mentioned here, it's
worth making sure that the other platforms either:

- expose comparable API calls directly, or
- we can get enough information ourselves from the AFM files.

As Eric suggests, this work all gets hidden down in platform-specific
GR_Graphics implementations, but we don't want to spec an unimplementable
method. :-)


PS: I have put *zero* thought into this particular problem. I'm just
quoting what I've read, so interpret this information accordingly. I'm more
than happy to defer to the design judgement of whoever's gonna tackle this.

This archive was generated by hypermail 1.03b2.