1 |
|
# -*-python-*- |
2 |
# |
# |
3 |
# Copyright (c) 2003, Asko Soukka |
# Copyright (c) 2003, Asko Soukka |
4 |
# |
# |
22 |
# |
# |
23 |
|
|
24 |
|
|
25 |
"""Test text sizes, rendering etc. |
""" |
26 |
|
Test text sizes, rendering etc. |
27 |
""" |
""" |
28 |
|
|
29 |
from test.tools.gfx import * |
from test.tools.gfx import * |
30 |
from java.awt import Color |
from java.awt import Color |
31 |
|
|
32 |
sty1 = win.getGraphicsAPI().getTextStyle("SansSerif", 0, 20) |
sty1 = win.getGraphicsAPI().getTextStyle("SansSerif", 0, 20) |
|
sty2 = win.getGraphicsAPI().getTextStyle("SansSerif", 0, 50) |
|
|
sty3 = win.getGraphicsAPI().getTextStyle("SansSerif", 0, 10) |
|
|
|
|
|
def testStyleSize(): |
|
|
"""Test that the different styles give out suitable heights. |
|
|
""" |
|
|
failUnlessApprox(4, sty1.getHeight(1), 20) |
|
|
failUnlessApprox(15, sty2.getHeight(1), 50) |
|
|
failUnlessApprox(4, sty3.getHeight(1), 10) |
|
|
|
|
|
failUnlessApprox(10, sty1.getHeight(2), 40) |
|
|
failUnlessApprox(25, sty2.getHeight(2), 100) |
|
|
failUnlessApprox(8, sty3.getHeight(2), 20) |
|
|
|
|
|
failUnlessApprox(20, sty2.getWidth("xx", 1), 50) |
|
|
failUnlessApprox(4, sty3.getWidth("xx", 1), 10) |
|
|
|
|
|
def testStyleScaling(): |
|
|
"""Test scaling by height. |
|
|
""" |
|
|
for height in range (0, 100): |
|
|
scale = sty1.getScaleByHeight(height) |
|
|
failUnlessApprox(1, sty1.getHeight(scale), height, "height") |
|
|
failUnlessApprox(1, sty1.getAscent(scale) + sty1.getDescent(scale), height, "ascender + descender") |
|
|
|
|
|
def testSize(): |
|
|
"""Test, for various box sizes, that text consisting of |
|
|
lower-case letter x is on the baseline or slightly above. |
|
|
""" |
|
|
|
|
|
def testScale(): |
|
|
"""Test that hierarchical coordinate systems affect the scaling |
|
|
in the same way. |
|
|
""" |
|
33 |
|
|
34 |
def testWH(): |
def testWH(): |
35 |
"""Test that TextVob is drawn with the width and height |
"""Test that TextVob is drawn with the width and height |