Fit a text to an outline
- Category: JS Illustrator
- Last Updated on Tuesday, 27 September 2016 19:56
- Published on Tuesday, 27 September 2016 19:09
- Written by robinfredericf
- Hits: 420
Someone provided you with a file (such as ai, pdf, eps) and you are now asked to edit a text line in it using Illustrator, but unfortunately this text has been converted to outlines
If you have ever been through this before, you know that you have to cope with some difficulties to get to it : identify the font, get it (legally !) and load it, if this font is not already in your system or font manager, and finally recreate the text with exactly the same typeface size and horizontal scale.
This simple script without any dialog box nor option will help you to accomplish the last step by enabling you to fit exactly the text to the bounds of a vector object. For example you type and format with the needed font the first letter of the text you want to recreate, you select both the text and the corresponding outline and the script fits the text to the outline.
If you actually used the same font as the original, you will be able to check by zooming in up to 6400% the perfect superposition of the character on the outline, if not — this generally means that you didn't use exactly the same font version (for example you will never succeed to fit the Adobe Futura to your outline if the font originally used was Futura BT).
If the whole line has the same character attributes (same font, same weight, same typeface size, etc.) all you have to do now is to type the other letters and modify if needed the kerning method and letter/word spacing to get a satisfying superposition of the whole recreated text line on the reference outline. The script can also fit a text including several characters to a selection of several vector objects, but the result will not be satisfying if the kerning and justification are not appropriate. If you have several fonts and styles in the same line, then you will have to recreate it in several parts that you will be able to merge using this other script http://www.wundes.com/JS4AI/#joinTextFrames.js or a similar script that i wrote myself, that should give better results and that i will also upload soon.
The script is intended for outlines converted from horizontal text, possibly extended or condensed, but not rotated nor deformed such as sheared to make false italic. In the case of simple rotation if you manage to estimate the rotation angle of the vector object you should get a correct result if you apply the same rotation to the text sample before launching the script, in the case of skewing, the angle is excessively complex to estimate if the deformation was combined with a non-uniform scale (extended or condensed).
Tested from CS5 to CC2015.