Skip to content

Images with layout information #4116

@litherum

Description

@litherum

There are quite a few examples of images which are associated with additional layout information. When I say "layout information" I'm talking about situations where the images are more than just simple width × height boxes.

MathML

From the minutes of the Math on Web Pages Joint Meeting at the Lyon F2F:

arno: Moving on to another challenge
arno: Baseline alignment
...
arno: Needed for lining up equations

Consider a math equation like this:

ex51

If it's presented inline in the middle of a paragraph, proper typesetting would align the baseline of the line it's on with the baseline of the 𝑓(t)dπ(t) part. However, that isn't the lowest part of the content; with naive typesetting, the bottom of the content would lie upon the baseline and the whole formula would be too high on the line of the paragraph.

Logos

Consider the Apple Pay logo:

Screen Shot 2019-07-14 at 4 13 10 PM

Similar to above, part of this logo should descend below the baseline. If you treat this logo as a simple image, the whole thing would be moved up too high, and wouldn't appear correctly on the line.

Currently, web authors often use icon fonts to work around this, as glyphs in fonts are allowed to have descenders. However, using icon fonts is an anti-pattern on the web. Instead, there should be a way to associate this baseline information with the logo itself.

Icons & Symbols

Consider the Play icon in the Music app on iOS. It is a little triangle, but when you have your finger pressed on it, there's a little circle surrounding the triangle.

IMG_0054

If you get your ruler out and measure, it turns out that the Play button is not mathematically centered in the circle. Instead, it's optically centered, using the overshoot concept from typography. Since the right point of the triangle is much more narrow than the left edge of the triangle, the right point gets to extend farther outward from the center.

The facilities for this are present in the "Symbol Images" concept natively available on macOS and iOS. An artist can associate a symbol with hand-authored baseline information. This allows the system to place these icons properly.

Kanbun

Not all CJK characters are encoded in Unicode. These characters are usually represented with images. Even though, technically, CJK doesn’t have descent, in practice, CJK characters end up having descent in real fonts because this is the only way to have proper vertical alignment on lines with mixed scripts. When a kanbun image is used, it cannot currently have a descent, meaning it cannot be placed vertically correctly. This is particularly bad in vertical writing mode (which is common in CJK), where the baseline is in the middle of the line, meaning the kanbun image would naturally be in a completely incorrect place.

Conclusion

CSS should have facilities to allow for this kind of layout information associated with images. Layout engines should allow designers to place or tweak layout information such as baselines or vertical baselines for their image artwork.

There is currently no file format for associating layout information with images. So, there are a few ways this could possibly work today:

  1. SVG is modified to allow an extra attribute on the root-most SVG element, which can indicate to the containing layout content additional layout information
  2. System assets, such as Symbols on macOS and iOS, could be exposed to the web. These assets would have layout information built-in. E.g. background-image: system-ui(play-button); background-position: auto;
  3. An additional CSS property that could modify the baseline of an image. E.g. image-baseline: 20% 50%; (for horizontal and vertical baseline). This would do more than background-position; it would actually move the layout box of the image.

Regardless of which method is chosen, CSS layout would have to be modified to include affordances for this additional layout information.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions