How to Rotate a Glyph by Decimal Degrees in FontForge
Yes, you can rotate a glyph by an exact decimal degree in FontForge. This guide explains how to apply fractional rotation values through FontForge's graphical user interface using the Transform tool, as well as how to perform precision rotations using Python scripting. It also details the essential font configuration settings required to maintain fractional point positions without automatic integer rounding.
Rotating via the Graphical Interface
FontForge's standard transformation dialog accepts floating-point decimal numbers directly.
- Open your font and double-click the glyph you want to modify to open the Glyph Outline View (or select one or more glyphs in the Font View).
- Select the contours or points you want to rotate. If you want to
rotate the entire glyph, press
Ctrl + A(orCmd + Aon macOS) to select all points. - Go to the top menu and click Element >
Transform... (shortcut:
Ctrl + \orCmd + \). - In the dialog, set the first dropdown menu to Rotate.
- In the angle field, enter your exact decimal degree (for example,
15.75or-3.45). Positive values rotate counter-clockwise; negative values rotate clockwise. - Choose your rotation origin:
- Glyph Origin: Rotates around the
(0, 0)base coordinate. - Center of Selection: Rotates around the geometric center of the selected points.
- Glyph Origin: Rotates around the
- Click OK to apply the transformation.
Maintaining Decimal Precision (Grid Snapping)
By default, FontForge rounds all point coordinates to the nearest whole integer. A rotation by a decimal degree will still function, but the resulting Bezier control points and on-curve points will snap to whole numbers unless configured otherwise:
- Go to File > Preferences (or FontForge > Preferences).
- Navigate to Editing.
- Uncheck Snap To Int (or ensure points are allowed to remain floating-point values depending on your FontForge build).
- If you plan to export to formats that strictly require integer coordinates (such as standard PostScript/CFF or TrueType formats), keep in mind that FontForge will round coordinates upon font generation unless using specific OpenType features or SVG fonts.
Rotating via Python Scripting
If you need exact mathematical precision or want to batch-rotate glyphs, FontForge provides a Python scripting API that handles floating-point math natively:
import fontforge
import psMat
import math
# Open the font
font = fontforge.open("YourFont.sfd")
# Select the target glyph
glyph = font["A"]
# Define your exact decimal rotation in degrees
degrees = 12.375
radians = math.radians(degrees)
# Create the rotation transformation matrix and apply it
rotation_matrix = psMat.rotate(radians)
glyph.transform(rotation_matrix)
# Save changes
font.save()FontForge's internal transformation matrix processes the rotation directly in radians, ensuring high-precision calculations regardless of the angle specified.