Draft ShapeString

From FreeCAD Documentation
Revision as of 18:51, 8 November 2018 by Vocx (talk | contribs) (Supported fonts)
Jump to: navigation, search
Other languages:
čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎polski • ‎română • ‎русский • ‎svenska • ‎Türkçe

Draft ShapeString.svg Draft ShapeString

Menu location
Draft → Shape from text ...
Workbenches
Draft, Arch
Default shortcut
S S
Introduced in version
-
See also
Draft Text, Part Extrude


Description

The ShapeString tool inserts a compound shape that represents a text string. Text height, tracking and font can be specified. The resulting shape can be used with the Part Extrude tool to create 3D letters.

The Draft Text tool is a simpler alternative that does not produce a closed shape.

Draft ShapeString Example400.png

How to use

  1. Press the Draft ShapeString16.png Draft ShapeString button, or press S then S keys.
  2. Click a point on the 3D view, or type a coordinate and press the Draft AddPoint.svg add point button.
  3. Enter the desired text, and press Enter.
  4. Enter the desired size, and press Enter.
  5. Enter the desired tracking, and press Enter.
  6. Press Enter to accept the displayed font file, or press ... to select a font file.

The text, size, tracking, and font can be changed after creation, by modifying the shape properties.

Set the default font file in Draft Preferences, in the Texts and dimensions tab. Supported fonts include TrueType (.ttf), OpenType (.otf), and Type 1 (.pfb).

Options

  • To enter coordinates manually, simply enter the numbers, then press Enter between each X, Y and Z component.
  • Press Esc or the Close button to abort the current command.

Properties

  • DataPosition: specifies the position of the base point of the compound shape.
  • DataAngle: specifies the rotation of the baseline of the shape.
  • DataAxis: specifies the axis to use for the rotation.
  • DataString: specifies the text string to display; unlike the Draft Text tool, the Draft ShapeString can only display a single line.
  • DataSize: specifies the general height of the letters.
  • DataTracking: specifies the additional inter-character spacing in the string.
  • DataFont File: specifies the full path of the font file used to draw the string.

Scripting

The ShapeString tool can be used in macros and from the Python console by using the following function:

ShapeString = makeShapeString(String, FontFile, Size=100, Tracking=0)
  • Creates a ShapeString compound shape using the specified String
  • FontFile is mandatory and must be the full path of a supported font file
  • Size is the height of the resulting text in millimeters
  • Tracking is the additional inter-character spacing in millimeters

Example:

import FreeCAD, Draft
Draft.makeShapeString("This is a sample text",
                      "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
                      200.0, 10)

Selecting A Font

SSFontSelect.png

ShapeString uses the internal geometry of a font to make FreeCAD shapes. To do this it must read the actual font file (*.tff, etc). If the Font Selection box is empty, you must type the full path to the font file or use ... to select a font file.

Limitations

  • This tool is not available in FreeCAD versions anterior to 0.14
  • TrueType(*.ttf), OpenType(*.otf) and Type1(*.pfb) font files are supported.
  • Very small text heights may result in deformed character glyphs due to loss of detail in scaling.
  • The current version is limited to left-to-right layouts on a horizontal baseline.
  • For creating curved text you can use the macro FCCircularTextButtom.pngCircular Text

Tutorials