1. A method for aligning a character to a sampling grid of an image, wherein an original path tracing an outline of the character is specified by input pen commands having original coordinates, comprising a processor for performing the method, the method comprising the steps of: determining points and contours of the input pen commands; determining an orientation of each contour; constructing a first directed acyclic graph (DAG) indicating a hierarchical relationship of related contours; determining radicals of a group of related contours using the first DAG; determining simple segments of the contours; merging the simple segments independently for each radical; determining segment pairs for the merged segments; determining hinted coordinates for the segment pairs; sorting the segment pairs and constructing a second DAG for the sorted segment pairs; resolving collisions between the segment pairs using the second DAG; determining x-free points and y-free points for each radical; and fitting the segments pairs, the x-free points, and the y-free points to the sampling grid independently for each radical and storing a result of the fitting in output pen commands having the hinted coordinates to align the outline of the character to the sampling grid of the image.