Esempio n. 1
0
def BodyText(image, text, color, flavor_text_size=0, font=None):
    # Replacement of keywords with symbols
    for keyword in RulesDict:
        if keyword in text:
            text = text.replace(keyword, RulesDict[keyword])
    text = FixUnicode(text)
    if font is None:
        font = fonts["Body"]
    anchor = Anchors["Body"]
    leading = -1
    # Get the size of the body text as (w,h)
    body_text_size = PIL_Helper.GetTextBlockSize(text, fonts["Body"],
                                                 textmaxwidth)
    # If the height of the body text plus the height of the flavor text
    # doesn't fit in on the card in the normal position, move the body text up
    if body_text_size[1] + flavor_text_size[1] > TextHeightThresholds[0]:
        anchor = Anchors["BodyShiftedUp"]
    # If they still don't fit, makes the body text smaller
    if body_text_size[1] + flavor_text_size[1] > TextHeightThresholds[1]:
        font = fonts["BodySmall"]
        body_text_size = PIL_Helper.GetTextBlockSize(text, font, textmaxwidth)
        # If they still don't fit, make it smaller again. They're probably
        # the changeling cards
        if body_text_size[1] + flavor_text_size[1] > TextHeightThresholds[1]:
            font = fonts["BodyChangeling"]
            leading = -3
    Anchors["BodyShiftedUp"]
    PIL_Helper.AddText(image=image,
                       text=text,
                       font=font,
                       fill=color,
                       anchor=anchor,
                       halign="center",
                       max_width=textmaxwidth,
                       leading_offset=leading)
Esempio n. 2
0
def MakeBlankCard():
    image = PIL_Helper.BlankImage(bleed_w, bleed_h)
    print("Blank Card")
    PIL_Helper.AddText(image=image,
                       text="This Card Intentionally Left Blank",
                       font=TitleFont,
                       fill=(200, 200, 200),
                       anchor=TypeAnchor,
                       max_width=textmaxwidth)
    return image
Esempio n. 3
0
def FlavorText(image, text):
    PIL_Helper.AddText(image=image,
                       text=text,
                       font=FlavorFont,
                       anchor=FlavorAnchor,
                       max_width=textmaxwidth,
                       valign="bottom")
Esempio n. 4
0
def RulesText(image, text):
    PIL_Helper.AddText(image=image,
                       text=text,
                       font=RulesFont,
                       anchor=RulesAnchor,
                       max_width=textmaxwidth,
                       leading_offset=0)
Esempio n. 5
0
def SymbolText(image, text):
    font = BigSymbolFont if text == "-" else SymbolFont
    PIL_Helper.AddText(image=image,
                       text=text,
                       font=font,
                       anchor=SymbolAnchor,
                       valign="center")
Esempio n. 6
0
def TitleText(image, text, color=(0, 0, 0)):
    print text
    PIL_Helper.AddText(image=image,
                       text=text,
                       font=TitleFont,
                       fill=color,
                       anchor=TitleAnchor,
                       max_width=bleed_h - 150,
                       leading_offset=0,
                       rotate=90)
Esempio n. 7
0
def GenreText(image, text, color):
    PIL_Helper.AddText(
        image=image,
        text=text,
        font=GenreFont,
        fill=color,
        anchor=OneLineAnchor,
        valign="top",
        halign="center",
    )
Esempio n. 8
0
def MakeGenreChangeCard(tags):
    image = PIL_Helper.BlankImage(bleed_w, bleed_h)
    DrawLines(image, tags[COLOR])
    TypeText(image, "Genre Change")
    GenreText(image, GenreDict[tags[COLOR][0]], ColDictDark[tags[COLOR][0]])
    TitleText(image, tags[TITLE], color=ColDictDark[tags[COLOR][0]])
    SymbolText(image, "<")
    RulesText(image, RulesDict["GENRE CHANGE"])
    if len(tags) > FLAVOR:
        FlavorText(image, tags[FLAVOR])
    return image
Esempio n. 9
0
def MakeSwitchCard(tags):
    image = PIL_Helper.BlankImage(bleed_w, bleed_h)
    DrawSidebar(image, ColDict[tags[COLOR][0]])
    DrawLines(image, tags[COLOR])
    TypeText(image, "Switch")
    TitleText(image, tags[TITLE])
    SymbolText(image, tags[COLOR][0])
    RulesText(image, RulesDict["SWITCH"].format(tags[COLOR][0]))
    if len(tags) > FLAVOR:
        FlavorText(image, tags[FLAVOR])
    return image
Esempio n. 10
0
def MakeFormModifierCard(tags):
    image = PIL_Helper.BlankImage(bleed_w, bleed_h)
    DrawSidebar(image, ColDict[tags[COLOR][0]])
    DrawLines(image, tags[COLOR])
    TypeText(image, "Form Modifier")
    GenreText(image, GenreDict[tags[COLOR][0]], ColDictDark[tags[COLOR][0]])
    TitleText(image, tags[TITLE])
    ValueText(image, tags[VALUE])
    RulesText(image, RulesDict["FORM MODIFIER"])
    if len(tags) > FLAVOR:
        FlavorText(image, tags[FLAVOR])
    return image
Esempio n. 11
0
def MakeFormCard(tags):
    image = PIL_Helper.BlankImage(bleed_w,
                                  bleed_h,
                                  color=ColDict[tags[COLOR][0]])
    TypeText(image, "Form")
    GenreText(image, GenreDict[tags[COLOR][0]], ColDictDark[tags[COLOR][0]])
    # Form sidebar type
    TitleText(image, "Form")

    # Form Title
    PIL_Helper.AddText(image=image,
                       text=tags[TITLE],
                       font=TitleFont,
                       fill=(0, 0, 0),
                       anchor=FormTitleAnchor,
                       max_width=bleed_h,
                       valign="bottom",
                       rotate=90)

    RulesText(image, RulesDict["FORM"])
    if len(tags) > FLAVOR:
        FlavorText(image, tags[FLAVOR])
    #DrawLines(image,tags[COLOR])
    return image