Expand description
How wide a title and description render in Google’s results, in pixels, so the explorer can show where a snippet gets cut. Google sets titles in Arial 20 px and descriptions in Arial 14 px; the widths come from Arial’s advance widths (2048 units per em), grouped by width, with a sensible default for characters outside the table.
Constants§
- DESCRIPTION_
LIMIT_ PX - Where Google cuts a description on desktop (about two lines).
- TITLE_
LIMIT_ PX - Where Google cuts a title on desktop.
Functions§
- description_
px - Width of
textset as a result description (Arial 14 px). - title_
px - Width of
textset as a result title (Arial 20 px). - truncate_
to_ px - Cuts
textso it fits inlimitpixels as measured byf, the way Google does: at a word boundary when that keeps most of the text, followed by" …". Returns the text and whether it was cut. The result, ellipsis included, never measures more thanlimit.