# wx.lib.floatcanvas.FCObjects.ScaledText¶

##fixme: this can be depricated and jsut use ScaledTextBox with different defaults.

This class creates a text object that is scaled when zoomed. It is placed at the coordinates, x,y. the “Position” argument is a two charactor string, indicating where in relation to the coordinates the string should be oriented.

The first letter is: t, c, or b, for top, center and bottom The second letter is: l, c, or r, for left, center and right The position refers to the position relative to the text itself. It defaults to “tl” (top left).

Size is the size of the font in world coordinates.

• Family: Font family, a generic way of referring to fonts without specifying actual facename. One of:

• wx.FONTFAMILY_DEFAULT: Chooses a default font.

• wx.FONTFAMILY_DECORATIVE: A decorative font.

• wx.FONTFAMILY_ROMAN: A formal, serif font.

• wx.FONTFAMILY_SCRIPT: A handwriting font.

• wx.FONTFAMILY_SWISS: A sans-serif font.

• wx.FONTFAMILY_MODERN: A fixed pitch font.

Note

these are only as good as the wxWindows defaults, which aren’t so good.

• Style: One of wx.FONTSTYLE_NORMAL, wx.FONTSTYLE_SLANT and wx.FONTSTYLE_ITALIC.

• Weight: One of wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_LIGHT and wx.FONTWEIGHT_BOLD.

• Underlined: The value can be True or False. At present this may have an an effect on Windows only.

Alternatively, you can set the kw arg: Font, to a wx.Font, and the above will be ignored. The size of the font you specify will be ignored, but the rest of its attributes will be preserved.

The size will scale as the drawing is zoomed.

Bugs/Limitations:

As fonts are scaled, the do end up a little different, so you don’t get exactly the same picture as you scale up and doen, but it’s pretty darn close.

On wxGTK1 on my Linux system, at least, using a font of over about 3000 pts. brings the system to a halt. It’s the Font Server using huge amounts of memory. My work around is to max the font size to 3000 points, so it won’t scale past there. GTK2 uses smarter font drawing, so that may not be an issue in future versions, so feel free to test. Another smarter way to do it would be to set a global zoom limit at that point.

The hit-test is done on the entire text extent. This could be made optional, but I haven’t gotten around to it.

## Class Hierarchy¶

Inheritance diagram for class ScaledText:

## Methods Summary¶

 __init__ Initialize self. See help(type(self)) for accurate signature. CalcBoundingBox Calculate the bounding box. LayoutText A dummy method to re-do the layout of the text.

## Class API¶

class ScaledText(TextObjectMixin, DrawObject)

##fixme: this can be depricated and jsut use ScaledTextBox with different defaults.

This class creates a text object that is scaled when zoomed. It is placed at the coordinates, x,y. the “Position” argument is a two charactor string, indicating where in relation to the coordinates the string should be oriented.

The first letter is: t, c, or b, for top, center and bottom The second letter is: l, c, or r, for left, center and right The position refers to the position relative to the text itself. It defaults to “tl” (top left).

Size is the size of the font in world coordinates.

• Family: Font family, a generic way of referring to fonts without specifying actual facename. One of:

• wx.FONTFAMILY_DEFAULT: Chooses a default font.

• wx.FONTFAMILY_DECORATIVE: A decorative font.

• wx.FONTFAMILY_ROMAN: A formal, serif font.

• wx.FONTFAMILY_SCRIPT: A handwriting font.

• wx.FONTFAMILY_SWISS: A sans-serif font.

• wx.FONTFAMILY_MODERN: A fixed pitch font.

Note

these are only as good as the wxWindows defaults, which aren’t so good.

• Style: One of wx.FONTSTYLE_NORMAL, wx.FONTSTYLE_SLANT and wx.FONTSTYLE_ITALIC.

• Weight: One of wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_LIGHT and wx.FONTWEIGHT_BOLD.

• Underlined: The value can be True or False. At present this may have an an effect on Windows only.

Alternatively, you can set the kw arg: Font, to a wx.Font, and the above will be ignored. The size of the font you specify will be ignored, but the rest of its attributes will be preserved.

The size will scale as the drawing is zoomed.

Bugs/Limitations:

As fonts are scaled, the do end up a little different, so you don’t get exactly the same picture as you scale up and doen, but it’s pretty darn close.

On wxGTK1 on my Linux system, at least, using a font of over about 3000 pts. brings the system to a halt. It’s the Font Server using huge amounts of memory. My work around is to max the font size to 3000 points, so it won’t scale past there. GTK2 uses smarter font drawing, so that may not be an issue in future versions, so feel free to test. Another smarter way to do it would be to set a global zoom limit at that point.

The hit-test is done on the entire text extent. This could be made optional, but I haven’t gotten around to it.

### Methods¶

__init__(self, String, XY, Size, Color = "Black", BackgroundColor = None, Family = wx.FONTFAMILY_MODERN, Style = wx.FONTSTYLE_NORMAL, Weight = wx.FONTWEIGHT_NORMAL, Underlined = False, Position = 'tl', Font = None, InForeground = False)

Initialize self. See help(type(self)) for accurate signature.

CalcBoundingBox(self)

Calculate the bounding box.

LayoutText(self)

A dummy method to re-do the layout of the text.

A derived object needs to override this if required.