Add more test cases; fix code so they pass.

This commit is contained in:
Tom Rothamel
2011-06-12 22:16:33 -04:00
parent af300d118a
commit 7feff9e690
4 changed files with 66 additions and 38 deletions
+4 -4
View File
@@ -13,7 +13,7 @@ font_cache = { }
font_face_cache = { }
def get_font(font, size, bold, italic, outline, antialias):
key = (size, bold, italic, outline, antialias)
key = (font, size, bold, italic, outline, antialias)
rv = font_cache.get(key, None)
if rv is not None:
@@ -434,7 +434,7 @@ class Layout(object):
# Break the paragraph up into lines.
# TODO: subtitle linebreak.
textsupport.linebreak_greedy(line_glyphs, width, width)
textsupport.linebreak_greedy(line_glyphs, width - style.first_indent, width - style.rest_indent)
# Figure out the time each glyph will be drawn.
for ts, glyphs in seg_glyphs:
@@ -580,7 +580,7 @@ class Layout(object):
tag, _, value = text.partition("=")
if tag[0] == "/":
if tag and tag[0] == "/":
tss.pop()
if not tss:
@@ -1094,7 +1094,7 @@ class NewText(renpy.display.core.Displayable):
if kind == TAG:
tag, _, value = text.partition("=")
if tag == "img":
if tag == "image":
d = renpy.easy.displayable(value)
displayables.add(d)
new_tokens.append((DISPLAYABLE, d))
Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.
+62 -34
View File
@@ -1,56 +1,84 @@
screen text_test:
add renpy.display.newtext.NewText(s, xmaximum=749, **kwargs)
# window:
# has vbox
window:
has vbox
# add renpy.display.newtext.NewText(s, **kwargs)
add renpy.display.newtext.NewText(s, slow=True, **kwargs)
# if old:
# add Text(s, **kwargs)
if old:
add Text(s, **kwargs)
init python:
_preferences.text_cps = 20
_preferences.text_cps = 100
init python:
TEST = ": We are not now that strength which in old days moved earth and heaven; that which we are, we are; One equal temper of heroic hearts, made weak by time and fate, but strong in will to strive, to seek, to find, and not to yield."
TEST = ": We are not now that strength which in old days moved earth and heaven; that which we are, we are; One equal temper of heroic hearts, made weak by time and fate, but strong in will. To strive, to seek, to find, and not to yield."
def text_test(s, test=TEST, old=True, **kwargs):
ui.saybehavior()
kwargs.update(text_extra)
renpy.call_screen("text_test", s=s + test, old=old, kwargs=kwargs)
style.red = Style(style.default)
style.red.color = "#f00"
label main_menu:
return
label start:
python:
text_test("Justify", justify=True)
text_test("Justify w/ Outline", justify=True, outlines=[(2, "#00f", 0, 0)])
text_test("Normal")
text_test("Aliased", antialias=False)
text_test("Bold", bold=True)
text_test("Color", color="#ff0")
text_test("First Indent", first_indent=50)
text_test("Font", font="mikachan.ttf")
text_test("Size", size=30)
text_test("Italic", italic=True)
text_test("Justify", justify=True)
text_test("Min_width, should be right-aligned.", test="", min_width=780, text_align=1.0)
text_test("Outlines", outlines=[ (1, "#f00"), (1, "#00f", 2, 2) ])
text_test("Rest Indent", rest_indent=50)
text_test("Slow CPS", slow_cps=10)
text_test("Slow CPS Mul", slow_cps_multiplier=2.0)
text_test("Right-align", text_align=1.0)
text_test("Center-align", text_align=0.5)
text_test("Underline", underline=True)
text_test("Strikethrough", strikethrough=True)
# TODO: Test language.
# TODO: Test layout.
# TODO: test black_color
$ text_extra = dict()
$ text_test("Tags", test=": {b}Bold {plain}Plain{/plain} Bold{/b} {i}Italics{/i} {color=#f00}color{/color} {font=mikachan.ttf}Font{/font} {image=arrow.png} {s}strikeout{/s} {u}underline{/u} {=red}red style{/=red}")
$ text_test("Size Tag", test=": {size=30}absolute{/size} {size=+10}relative bigger{/size} {size=-10}relative smaller{/size}")
$ text_test("Spacing", test=":{space=100}horizontal{vspace=30}vertical", old=False)
$ text_test("Font", font="mikachan.ttf")
$ text_test("Justify", justify=True)
$ text_test("Normal")
$ text_test("Aliased", antialias=False)
$ text_test("Bold", bold=True)
$ text_test("Color", color="#ff0")
$ text_test("First Indent", first_indent=250)
$ text_test("Size", size=30)
$ text_test("Italic", italic=True)
$ text_test("Justify", justify=True)
$ text_test("Min_width, should be right-aligned.", test="", min_width=780, text_align=1.0)
$ text_test("Rest Indent", rest_indent=250)
$ text_test("Slow CPS", slow_cps=10)
$ text_test("Slow CPS Mul", slow_cps_multiplier=2.0)
$ text_test("Right-align", text_align=1.0)
$ text_test("Center-align", text_align=0.5)
$ text_test("Underline", underline=True)
$ text_test("Strikethrough", strikethrough=True)
$ text_extra = dict(outlines=[ (1, "#00f", 1, 1), (1, "#f00") ])
$ text_test("Font", font="mikachan.ttf")
$ text_test("Justify", justify=True)
$ text_test("Normal")
$ text_test("Aliased", antialias=False)
$ text_test("Bold", bold=True)
$ text_test("Color", color="#ff0")
$ text_test("First Indent", first_indent=250)
$ text_test("Size", size=30)
$ text_test("Italic", italic=True)
$ text_test("Justify", justify=True)
$ text_test("Min_width, should be right-aligned.", test="", min_width=780, text_align=1.0)
$ text_test("Rest Indent", rest_indent=250)
$ text_test("Slow CPS", slow_cps=10)
$ text_test("Slow CPS Mul", slow_cps_multiplier=2.0)
$ text_test("Right-align", text_align=1.0)
$ text_test("Center-align", text_align=0.5)
$ text_test("Underline", underline=True)
$ text_test("Strikethrough", strikethrough=True)
# TODO: Test language.
# TODO: Test layout.
# TODO: test black_color