> For the complete documentation index, see [llms.txt](https://mkfont.gitbook.io/mkfont-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mkfont.gitbook.io/mkfont-docs/how-mkfont-works/fitting-a-shape.md). Agents can also search and read this documentation through its [MCP server](https://mkfont.gitbook.io/mkfont-docs/~gitbook/mcp).

# Fitting a Shape

How a shape drawn at any size becomes a glyph that sits on the baseline at the right height, with the right space around it.

An SVG knows nothing about fonts. It has no baseline, and its size is whatever the artboard was. A glyph needs both, so every glyph in MkFont carries **transforms**: settings that take the shape as it was imported and decide how big it is, where it sits, and how much room it takes in a line of text.

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-308dc31d5c6138d10eea6d9a40dbc0f883c812f0%2Fplaceholder-wide.jpg?alt=media" alt="DIAGRAM | id: fitting-a-shape-four-decisions | SHOWS: The four decisions transforms make, in the order they are applied | ELEMENTS: Four panels left to right, the same letter shape in each, on the same set of horizontal metric lines. Panel 1, labelled Bounds: the shape with two rectangles around it, a larger one for the imported box and a tight one for the outline box, one of them emphasized. Panel 2, labelled Scale: that box stretched so its height spans from the baseline to the ascender line, the shape scaled with it. Panel 3, labelled Position: one corner of the box marked with a dot, and the dot sitting on the baseline at the left edge. Panel 4, labelled Spacing: a gap on each side of the box, and a bracket under the whole labelled advance | MUST BE CLEAR: Each decision acts on the result of the one before it, and the shape itself is only ever scaled as a whole, never redrawn"><figcaption><p>Pick a box, scale it, place it, space it.</p></figcaption></figure>

## The shape stays as drawn

*Transforms are settings, applied again every time something changes. The imported shape is kept as it came.*

MkFont stores the shape from the SVG untouched, next to the settings that fit it. The glyph in the grid, in the text preview and in the exported font file is the result of applying one to the other.

Three things follow:

* **A metric line can move later.** Raise the font's ascender and every glyph scaled to it grows with it.
* **A redrawn SVG lands in the same place.** Import a new version of a shape into a glyph and its size, position and spacing are already decided.
* **One set of settings fits many shapes.** Shapes prepared the same way need the same transforms, so they can be set once for a whole import, or for a whole selection.

## Which box is measured

*A shape has two boxes: the one it came in, and the one it fills.*

The **imported box** is the frame the SVG was saved with: its viewBox, which is the artboard when a vector editor exports one. The **outline box** is the tight rectangle around the shape itself.

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-308dc31d5c6138d10eea6d9a40dbc0f883c812f0%2Fplaceholder-wide.jpg?alt=media" alt="DIAGRAM | id: fitting-a-shape-two-boxes | SHOWS: The imported box and the outline box of one shape | ELEMENTS: A lowercase letter drawn inside a tall rectangle that leaves empty space above it and a little on each side, the rectangle labelled imported box with a note that it is the artboard. A second, tight rectangle around the letter itself, labelled outline box. The two drawn in different line styles | MUST BE CLEAR: The imported box includes empty space the designer left on purpose, and the outline box does not"><figcaption><p>The empty space inside the imported box is information: it says how big this shape is next to the others.</p></figcaption></figure>

**Bounds** decides which of the two is fitted, and it can choose differently for height and for width.

The imported box carries the relation between shapes. A capital and a comma drawn on artboards of the same height, each at its real size and position, keep that size and position when both are fitted by their imported box. Fitted by their outline boxes, the comma would be stretched to the height of the capital.

The outline box ignores how the file was set up. Icons saved on artboards of different sizes all come out the same height when fitted by their outline boxes.

A new font starts on **Mixed bounds vertical**: the imported box decides the height, so shapes keep their size and position relative to each other, and the outline box decides the width, so the spacing on each side is measured from the shape and not from the edges of the artboard.

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-308dc31d5c6138d10eea6d9a40dbc0f883c812f0%2Fplaceholder-wide.jpg?alt=media" alt="DIAGRAM | id: fitting-a-shape-same-artboard | SHOWS: Two shapes drawn on artboards of the same height, fitted by their imported box and by their outline box | ELEMENTS: Top row: a capital letter and a comma, each on its own artboard of identical height, the capital filling the height and the comma small at the bottom. Middle row, labelled imported box: both placed on shared baseline and ascender lines, at the sizes and positions they were drawn. Bottom row, labelled outline box: the capital unchanged, the comma scaled up until it is as tall as the capital | MUST BE CLEAR: Fitting by the imported box preserves the size relation the designer drew, and fitting by the outline box throws it away"><figcaption><p>Same two files, same scale setting. Only the box changed.</p></figcaption></figure>

{% hint style="info" %}

## A box drawn into the file

When a file has no viewBox, or its viewBox is not the frame the shape should be measured in, a path painted in the **Mark color** set in **Preferences** stands in for it: MkFont reads that path's box as the imported box and leaves the path out of the shape. See [Preparing SVGs](https://mkfont.gitbook.io/mkfont-docs/import-and-export/preparing-svgs.md).
{% endhint %}

## What it is scaled to

*The height of the box is stretched to the distance between two metric lines.*

{% columns %}
{% column %}

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-61bcbb9ad8adbcf183ffbeb5e6e8c4c9abef07ff%2Ffitting-a-shape-box-between-lines.png?alt=media" alt="STILL | id: fitting-a-shape-box-between-lines | SHOWS: A fitted glyph in the glyph view, its box spanning from the baseline to the ascender line while the outline stops short of the top | FRAME: One glyph selected. Glyph view at its default size with the metric lines labelled. Bounds on Mixed bounds vertical and Scale on Baseline to Ascender in the Transforms section under it | CROP: region: the glyph view and the Fit fields of the Transforms section | NEEDS: a lowercase letter without an ascender, imported from an SVG whose artboard is taller than the letter | SOURCE: Sample font, browser build"><figcaption><p>The box reaches the ascender. The letter inside it keeps the height it was drawn at.</p></figcaption></figure>
{% endcolumn %}

{% column valign="middle" %}
**Scale** names the two lines. On **Baseline to Ascender**, the box becomes as tall as the distance from the baseline up to the ascender. The width follows in proportion: a shape is never stretched on one axis.

That is the whole contract between the drawing and the font. Draw every letter on an artboard whose bottom edge is the baseline and whose top edge is the ascender, fit by the imported box, and the font reproduces the drawing.

The other targets work the same way with other lines: the x-height, the cap height, the full span from descender to ascender, the em. Three options step outside that model:

{% endcolumn %}
{% endcolumns %}

| Scale                       | Does                                                                                                                                                                 |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Manual**                  | Multiplies the size by a **Factor**.                                                                                                                                 |
| **None**                    | Leaves the shape at the size it was drawn: one unit of the SVG is one font unit.                                                                                     |
| **Normalize (fit metrics)** | Fits the box inside the glyph's **Width** and **Height**, whichever is reached first. For shapes with very different proportions that should all fill the same cell. |

## Where it is placed

*One point of the box goes on one line.*

**Vertical** names the line, and **Anchor** names the point. With **Baseline** and the bottom-left anchor, the defaults, the bottom edge of the box sits on the baseline. Pick a middle anchor and the center of the box sits on the baseline instead; pick a top one and the box hangs under it.

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-308dc31d5c6138d10eea6d9a40dbc0f883c812f0%2Fplaceholder-wide.jpg?alt=media" alt="DIAGRAM | id: fitting-a-shape-anchor-on-line | SHOWS: The same box placed on the same line by three different anchors | ELEMENTS: One horizontal line labelled baseline running across three panels. In each panel the same box with its nine anchor points drawn as small dots, one of them emphasized. Panel 1: a bottom anchor emphasized, the box standing on the line. Panel 2: a middle anchor emphasized, the box centered on the line. Panel 3: a top anchor emphasized, the box hanging under the line | MUST BE CLEAR: The line does not move. The anchor decides which part of the box touches it"><figcaption><p>The line is where. The anchor is which part.</p></figcaption></figure>

**Horizontal** works the same way across the glyph's advance: the anchor's column, left, center or right, is placed at the start of the advance, at its middle, or at its end. **Shift** holds it off the start and **Push** off the end.

Two combinations as examples. A letter: bottom-left anchor, **Baseline**, **Min x**, so the shape stands on the baseline at the start of its advance. A shape centered in a cell of fixed width: center anchor, **Center**, and **Auto width** off.

## How much room it takes

*The advance is the room a glyph takes in a line of text. It is a setting of its own, separate from the shape.*

{% columns %}
{% column %}

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-8ff581772648c9800d436b983158c548acfbae34%2Ffitting-a-shape-advance-in-glyph-view.png?alt=media" alt="STILL | id: fitting-a-shape-advance-in-glyph-view | SHOWS: A glyph whose advance is wider than its outline, with visible space on both sides | FRAME: One glyph selected. Glyph view showing the outline inside the advance box. In the Transforms section, Auto width on, Shift and Push set to two different positive values | CROP: region: the glyph view and the Spacing fields of the Transforms section | NEEDS: a letter with an imported outline, Shift and Push both greater than zero and different from each other | SOURCE: Sample font, browser build"><figcaption><p>The gap on the left is Shift, the gap on the right is Push, and the box around all three is the advance.</p></figcaption></figure>
{% endcolumn %}

{% column valign="middle" %}
The **advance** is the distance from where a glyph starts to where the next one starts. A shape narrower than its advance has space around it; a shape wider than its advance overlaps its neighbors.

With **Auto width** on, the advance follows the shape: it is the width of the fitted box, plus **Shift**, plus **Push**. **Shift** is the space before the shape and **Push** the space after it.

With **Auto width** off, the advance is the glyph's **Width**, whatever the shape measures, and **Shift** and **Push** only move the shape inside it.
{% endcolumn %}
{% endcolumns %}

## One setting, many glyphs

*Every glyph has its own transforms, and starts with the font's.*

{% columns %}
{% column %}

<figure><img src="https://1675470811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwkWJ9v357hW91tto340i%2Fuploads%2Fgit-blob-aa9bc166d3a3a5eb25e66d51045b77c177ccbb96%2Ffitting-a-shape-default-transforms.png?alt=media" alt="STILL | id: fitting-a-shape-default-transforms | SHOWS: Default transforms in the Font panel, the same fields a glyph has | FRAME: Sidebar on the Font panel, scrolled so the Default transforms group is fully visible with its help line, Fit, Position and Spacing fields | CROP: sidebar | NEEDS: any font | SOURCE: Sample font, browser build"><figcaption><p>The font's own copy of the Transforms section. New glyphs start here.</p></figcaption></figure>
{% endcolumn %}

{% column valign="middle" %}
The **Font** panel holds **Default transforms**: the settings a new glyph is created with.

A few fields can also be linked to the font default after the fact: **Shift**, **Push**, **Y offset**, and the rotation and skew values. A linked field has no value of its own. It follows the default, so the side spacing of every linked glyph can be tuned from a single field in the **Font** panel.

Every field and every option is described on [Transforms](https://mkfont.gitbook.io/mkfont-docs/building-a-font/glyph-inspector/transforms.md).

{% endcolumn %}
{% endcolumns %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://mkfont.gitbook.io/mkfont-docs/how-mkfont-works/fitting-a-shape.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
