Docs — Text Layer Reference - Investigamer/Proxyshop GitHub Wiki
Text layers are filled and formatted by creating an instance of one of the following classes. All classes require a layer
parameter (the text layer in the Photoshop document to insert the text into) and contents
parameter (the text to insert). In addition, there are optional parameters you can pass to affect the formatting and automated behavior of these text items.
# Imported at the top
import proxyshop.text_layers as text_classes
# Inside your Proxyshop template code, this example is from the StarterTemplate
self.text.extend([
text_classes.FormattedTextField(
layer = self.text_layer_mana, # A layer object
contents = self.layout.mana_cost # Contents string
),
text_classes.ScaledTextField(
# Scales the text to avoid colliding with layer on the right side
layer = self.text_layer_name,
contents = self.layout.name,
reference = self.text_layer_mana # Reference to scale down to avoid
),
text_classes.ScaledTextField(
layer = self.text_layer_type,
contents = self.layout.type_line,
reference = self.expansion_symbol
)
])
# Here's an example adding just one text layer to the list
self.text.append(
text_classes.TextField(
layer = some_layer_object,
contents = some_string
)
)
At the end of the Proxyshop render process, all initialized text item objects are executed using an execute()
method. This runs any code specific to that text item such as scaling to fit a reference, formatting for mana symbols, etc. Proxyshop iterates through the self.text list and calls execute on each one. Below you will find a reference for what each text item class is capable of, and what optional parameters they can accept to change their behavior.
TextField
Top level class that all others extend to. All this class does is fill the contents of the layer, force the layer to be visible, and set the color of the text if optional color
parameter is passed. If color isn't passed, color defaults to the layer's color when initialized. The required parameters of this class are also required for every other text item class.
Parameters
layer
(Required) — Text layer object to receive text.contents
(Required) — String to insert into layer.color
(Optional) — SolidColor object, you can generate a SolidColor object using RGB or CMYK values by using the appropriate helper function (imported from proxyshop.helpers),get_rgb(r, g, b)
for RGB values,get_cmyk(c, m, y, k)
for CMYK values.
ScaledTextField > TextField
Extends to top level TextField, the only additional functionality this class executes is scaling the text down so it doesn't collide with a reference layer (for example scaling down the card name so it doesn't collide with mana symbols).
Parameters
- Every parameter shared by
TextField
reference
(Required) — Layer object, the text will scale to avoid colliding with this layer. If the layer already doesn't collide with the text this step is ignored.
FormattedTextField > TextField
Extends to top level TextField. The added functionality of this class is a step that formats the text for any detected mana symbols, italics (such as reminder text), etc. This is the most bare bones formatted text class, primarily used for mana cost layers, one line ability layers, but not sophisticated enough for an entire rules text area.
Parameters
- Every parameter shared by
TextField
centered
(Optional) — True/False, centers the text.font_size
(Optional) — Number, sets the size of the font.bold_rules_text
(Optional) — True/False, forces the text to be bold.line_break_lead
(Optional) — Number, sets the spacing between line breaks.
FormattedTextArea > FormattedTextField
Extends to FormattedTextField, used exclusively for the rules text box. Adds additional functionality for scaling the text to fit the rules text box, vertically centering that text within the box, and optionally inserting a divider between the rules text and the flavor text.
Parameters
- Every parameter shared by
FormattedTextField
reference
(Required) — A (hidden) layer containing a rectangle (or other shape) to fit the text area within, also used as a reference for vertically positioning the text within that box.flavor
(Optional) — A flavor text string. Passed separately from the contents.divider
(Optional) — A layer containing the dividing line that is positioned between the rules text and the flavor text. If not provided, the text will be formatted like old MTG cards that had no flavor divider.flavor_centered
(Optional) — True/False, centers the flavor text.flavor_text_lead
(Optional) — Number, manually sets the line break spacing between rules and flavor text.flavor_color
(Optional) — SolidColor object, forces the flavor text to be this color.right_align_quote
(Optional) — Aligns the quote credit found in some flavor text to the right of the rules box, this is a very niche feature to accommodate a few very old MTG cards which had this feature.
CreatureFormattedTextArea > FormattedTextArea
Extends to FormattedTextArea, used exclusively for rules text on creatures. This adds additional functionality for positioning the text to avoid colliding with the power/toughness box. The process uses two reference areas, it makes a selection on the pt_reference
, and if the selection isn't empty it checks how far it is from the pt_top_reference
and shifts the entire text area upward accordingly.
Parameters
- Every parameter shared by
FormattedTextArea
pt_reference
(Required) — A layer containing a box that extends from the type bar down across the PT box.pt_top_reference
(Required) — A layer containing a box that extends from the type bar down to just above the PT box.