diff --git a/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui b/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui
index 482a85a147..d551a06aa1 100644
--- a/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui
+++ b/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui
@@ -143,7 +143,7 @@ such as "Arial:Bold"
- dimstyle
+ DefaultAnnoDisplayMode
Mod/Draft
diff --git a/src/Mod/Draft/draftguitools/gui_texts.py b/src/Mod/Draft/draftguitools/gui_texts.py
index 370517a782..4ba938d295 100644
--- a/src/Mod/Draft/draftguitools/gui_texts.py
+++ b/src/Mod/Draft/draftguitools/gui_texts.py
@@ -113,7 +113,8 @@ class Text(gui_base_original.Creator):
_cmd = 'Draft.make_text'
_cmd += '('
_cmd += string + ', '
- _cmd += 'placement=pl'
+ _cmd += 'placement=pl, '
+ _cmd += 'screen=None, height=None, line_spacing=None'
_cmd += ')'
_cmd_list = ['pl = FreeCAD.Placement()',
'pl.Rotation.Q = ' + rot,
diff --git a/src/Mod/Draft/draftmake/make_text.py b/src/Mod/Draft/draftmake/make_text.py
index 4d1f6e4ba8..fa0fdb55b8 100644
--- a/src/Mod/Draft/draftmake/make_text.py
+++ b/src/Mod/Draft/draftmake/make_text.py
@@ -41,7 +41,7 @@ if App.GuiUp:
from draftviewproviders.view_text import ViewProviderText
-def make_text(string, placement=None, screen=False, height=None):
+def make_text(string, placement=None, screen=False, height=None, line_spacing=1):
"""Create a Text object containing the given list of strings.
The current color and text height and font specified in preferences
@@ -54,20 +54,26 @@ def make_text(string, placement=None, screen=False, height=None):
If it is a list, each element in the list represents a new text line.
placement: Base::Placement, Base::Vector3, or Base::Rotation, optional
- It defaults to `None`.
+ Defaults to `None`.
If it is provided, it is the placement of the new text.
The input could be a full placement, just a vector indicating
the translation, or just a rotation.
- screen: bool, optional
- It defaults to `False`, in which case the text is placed in 3D space
- oriented like any other object, on top of a given plane,
- by the default the XY plane.
- If it is `True`, the text will always face perpendicularly
- to the camera direction, that is, it will be flat on the screen.
+ screen: bool or None, optional
+ Defaults to `False`.
+ If it is `True`, the DisplayMode is set to "Screen".
+ If it is `False`, it is set to "World".
+ If it is `None`, the DisplayMode depends on the current preferences.
- height: float, optional
- A height value for the text, in mm
+ height: float or None, optional
+ Defaults to `None`.
+ A height value for the text, in mm.
+ If it is `None` or zero, the FontSize depends on the current preferences.
+
+ line_spacing: float or None, optional
+ Defaults to 1.
+ The line spacing factor.
+ If it is `None` or zero, the LineSpacing depends on the current preferences.
Returns
-------
@@ -116,8 +122,7 @@ def make_text(string, placement=None, screen=False, height=None):
elif isinstance(placement, App.Rotation):
placement = App.Placement(App.Vector(), placement)
- new_obj = doc.addObject("App::FeaturePython",
- "Text")
+ new_obj = doc.addObject("App::FeaturePython", "Text")
Text(new_obj)
new_obj.Text = string
new_obj.Placement = placement
@@ -125,18 +130,19 @@ def make_text(string, placement=None, screen=False, height=None):
if App.GuiUp:
ViewProviderText(new_obj.ViewObject)
- if not height: # zero or None
- height = utils.get_param("textheight", 2)
-
- new_obj.ViewObject.DisplayMode = "World"
- if screen:
- _msg("screen: {}".format(screen))
+ if screen is None:
+ # Keep value as set by viewprovider
+ pass
+ elif screen:
new_obj.ViewObject.DisplayMode = "Screen"
- height *= 10
+ else:
+ new_obj.ViewObject.DisplayMode = "World"
- new_obj.ViewObject.FontSize = height
- new_obj.ViewObject.FontName = utils.get_param("textfont", "")
- new_obj.ViewObject.LineSpacing = 1
+ if height: # Keep value as set by viewprovider if zero or None
+ new_obj.ViewObject.FontSize = height
+
+ if line_spacing: # Keep value as set by viewprovider if zero or None
+ new_obj.ViewObject.LineSpacing = line_spacing
gui_utils.format_object(new_obj)
gui_utils.select(new_obj)
diff --git a/src/Mod/Draft/draftutils/gui_utils.py b/src/Mod/Draft/draftutils/gui_utils.py
index d75cd244e3..36c02b8d02 100644
--- a/src/Mod/Draft/draftutils/gui_utils.py
+++ b/src/Mod/Draft/draftutils/gui_utils.py
@@ -492,10 +492,7 @@ def format_object(target, origin=None):
tcol = (float(tcol[0]), float(tcol[1]), float(tcol[2]), 0.0)
fcol = (float(fcol[0]), float(fcol[1]), float(fcol[2]), 0.0)
lw = utils.getParam("linewidth",2)
- fs = utils.getParam("textheight",0.20)
if not origin or not hasattr(origin, 'ViewObject'):
- if "FontSize" in obrep.PropertiesList:
- obrep.FontSize = fs
if "TextColor" in obrep.PropertiesList:
obrep.TextColor = tcol
if "LineWidth" in obrep.PropertiesList:
diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py
index 4dd6681524..285f0faa15 100644
--- a/src/Mod/Draft/draftutils/utils.py
+++ b/src/Mod/Draft/draftutils/utils.py
@@ -173,7 +173,7 @@ def get_param_type(param):
"precision", "defaultWP", "snapRange", "gridEvery",
"linewidth", "modconstrain", "modsnap",
"maxSnapEdges", "modalt", "HatchPatternResolution",
- "snapStyle", "dimstyle", "gridSize", "gridTransparency"):
+ "snapStyle", "DefaultAnnoDisplayMode", "gridSize", "gridTransparency"):
return "int"
elif param in ("constructiongroupname", "textfont",
"patternFile", "snapModes",
@@ -181,7 +181,8 @@ def get_param_type(param):
"labeltype", "gridSpacing") or "inCommandShortcut" in param:
return "string"
elif param in ("textheight", "arrowsize", "extlines", "dimspacing",
- "dimovershoot", "extovershoot", "HatchPatternSize"):
+ "dimovershoot", "extovershoot", "HatchPatternSize",
+ "LineSpacing"):
return "float"
elif param in ("selectBaseObjects", "alwaysSnap", "grid",
"fillmode", "maxSnap", "DimShowLine",
diff --git a/src/Mod/Draft/draftviewproviders/view_dimension.py b/src/Mod/Draft/draftviewproviders/view_dimension.py
index 124e6b1752..83b9a7a271 100644
--- a/src/Mod/Draft/draftviewproviders/view_dimension.py
+++ b/src/Mod/Draft/draftviewproviders/view_dimension.py
@@ -262,10 +262,6 @@ class ViewProviderDimensionBase(ViewProviderDraftAnnotation):
_tip)
vobj.ShowLine = utils.get_param("DimShowLine", True)
- def getDefaultDisplayMode(self):
- """Return the default display mode."""
- return ["World", "Screen"][utils.get_param("dimstyle", 0)]
-
def getIcon(self):
"""Return the path to the icon used by the viewprovider."""
return ":/icons/Draft_Dimension_Tree.svg"
@@ -550,7 +546,7 @@ class ViewProviderLinearDimension(ViewProviderDimensionBase):
try:
m = vobj.DisplayMode
except AssertionError:
- m = ["World", "Screen"][utils.get_param("dimstyle", 0)]
+ m = ["World", "Screen"][utils.get_param("DefaultAnnoDisplayMode", 0)]
if m == "Screen":
offset = offset.negative()
@@ -975,7 +971,7 @@ class ViewProviderAngularDimension(ViewProviderDimensionBase):
try:
m = vobj.DisplayMode
except AssertionError:
- m = ["World", "Screen"][utils.get_param("dimstyle", 0)]
+ m = ["World", "Screen"][utils.get_param("DefaultAnnoDisplayMode", 0)]
# Set the arc
first = self.circle.FirstParameter
diff --git a/src/Mod/Draft/draftviewproviders/view_draft_annotation.py b/src/Mod/Draft/draftviewproviders/view_draft_annotation.py
index 3cbdc970eb..6b985ae3e6 100644
--- a/src/Mod/Draft/draftviewproviders/view_draft_annotation.py
+++ b/src/Mod/Draft/draftviewproviders/view_draft_annotation.py
@@ -183,7 +183,7 @@ class ViewProviderDraftAnnotation(object):
def getDefaultDisplayMode(self):
"""Return the default display mode."""
- return "World"
+ return ["World", "Screen"][utils.get_param("DefaultAnnoDisplayMode", 0)]
def setDisplayMode(self, mode):
"""Return the saved display mode."""
diff --git a/src/Mod/Draft/draftviewproviders/view_label.py b/src/Mod/Draft/draftviewproviders/view_label.py
index 6d1279e8be..8b97a0f8f7 100644
--- a/src/Mod/Draft/draftviewproviders/view_label.py
+++ b/src/Mod/Draft/draftviewproviders/view_label.py
@@ -90,7 +90,7 @@ class ViewProviderLabel(ViewProviderDraftAnnotation):
"LineSpacing",
"Text",
_tip)
- vobj.LineSpacing = 1.0
+ vobj.LineSpacing = utils.get_param("LineSpacing", 1)
def set_graphics_properties(self, vobj, properties):
"""Set graphics properties only if they don't already exist."""
diff --git a/src/Mod/Draft/draftviewproviders/view_text.py b/src/Mod/Draft/draftviewproviders/view_text.py
index f0f15a4a1a..cbd9235297 100644
--- a/src/Mod/Draft/draftviewproviders/view_text.py
+++ b/src/Mod/Draft/draftviewproviders/view_text.py
@@ -66,7 +66,7 @@ class ViewProviderText(ViewProviderDraftAnnotation):
"LineSpacing",
"Text",
_tip)
- vobj.LineSpacing = 1.0
+ vobj.LineSpacing = utils.get_param("LineSpacing", 1)
def getIcon(self):
"""Return the path to the icon used by the view provider."""