5
$\begingroup$

If you are trying to create a text object in blender and find it is missing some code points, what workflow would you use to mix in another TTF that supplies the missing code points?

To complicate this, assume you want to have reasonable automatic kerning and word wrap in a text box.

For an example of a text object that illustrates the problem the following python gives me a text object missing several of the characters that are part of the body:

import bpy

obj = bpy.context.active_object
obj.data.body = "bacon\u2026 \u2058 \u03a8 eggs"

If I manage to find some .TTFs that cover the missing characters, how do I join them to the text object? It seems that blender only supports 4 fonts per object, and how you actually indicate which of the four fonts is used by any particular character?

I experimented with the object font technique outlined by Duarte Farrajota Ramos and it has shortcomings in this situation. atrocious kerning As you can see from the previous screenshot the kerning is a disaster and the glyphs seem to appear out of order. The python source that generated this scene can be found at http://web.purplefrog.com/~thoth/blender/python-cookbook/object-font-from-regular-font.html .

Despite the scripting tag that was added by a well-meaning editor, this question is NOT about scripting. Scripting is merely a convenient way to clearly illustrate the issue.

$\endgroup$
1
$\begingroup$

Not sure if it works for you, probably not a very solid or flexible long term solution, but have you looked into Object Font?

Basically you specify a "family name" or a base naming convention for a bunch of objects, you then manually name any 3d object using that naming convention like fontobject_a fontobject_b fontobject_c fontobject_n etc.

You then enter this family name in the Properties Window > Object Data > Font > Object font as fontobject_

You can now specify any regular blender objects as a character replacement. You manually create objects for every character, can be a 3D mesh, a bezier curve or even another text object using the desired font file, and name it properly.

Turn on vertex duplication on the original font object under Properties Window > Object > Duplication > Verts and you can have as many different fonts as you like.

Have in mind that it is an admittedly cumbersome solution and will probably require post processing like making the duplicates real and hiding the underlying text object.

$\endgroup$
  • 1
    $\begingroup$ I created web.purplefrog.com/~thoth/blender/python-cookbook/… based on this technique and used the StandardGreekItalic font from fonts101.com. Unfortunately, the kerning is a disaster. It seems to use the spacing from the base font (which is wrong for the missing code points, and even the placement of the glyphs ends up a mess). I'll add a screenshot to my question. $\endgroup$ – Mutant Bob May 20 '16 at 16:07
  • $\begingroup$ Yes it seems to be a lot of inconvenience. Only other thing I can think about is use an external editor with proper text editing capabilities that suit your particular needs (Inkscape comes to mind), converter your text into "static" vector paths, export as SVG and import into Blender. It will not be a "live" text object, but will probably work acceptably for rendering or any other "visual only" purposes. $\endgroup$ – Duarte Farrajota Ramos May 20 '16 at 17:40
1
$\begingroup$

try using a Pro font as opposed to Std. Pro fonts support a much wider range of glyphs than standard (for details, see https://www.fonts.com/support/faq/opentype-varieties) and this may mean you can avoid the problem by using a single font.

In order to manipulate the text formatting via Python you must use .body_format, which is a collection of TextCharacterFormat. Check the current version of the API docs for full details.

Example:

Sets the first character of the 'Text' object to use bold font.

bpy.data.objects['Text'].data.body_format[0].use_bold = True

At the end of the day, you may be better off using a 2d graphics package to prepare your text and export it as SVG, which Blender can import as curves.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.