An essential problem in on-line handwriting recognition is in shape variation along with the variety of stroke number/order. To cope with such topological deformations, we have developed a clear and systematic algorithm for shape matching based on structural feature grouping. The algorithm requires a small number of prototypes and has the following properties: (a) The order, direction, and number of strokes are free; (b) Stroke connection and breaking are allowed.