Design: 04.02.03.03/P04
This is an abstract, language-independent design. Grim
details may be found in the
corresponding source code.
You may return to the
documentation
for the module containing this program design, or to the
entire hierarchical table of
topics covered by the PVT.
PROGRAM 4: Text alignment
CHARACTERISTICS: ynnn
OPERATOR SCRIPT: passive test.
DESIGN:
Open primary workstation
Establish specwt = specific primary workstation type
<Inquire text extent> with:
font = 2 (ASCII font)
chxp = 1.3
chsp = 0.4
chh = 3.4
txp = RIGHT
txal = 1st: CENTER,CAP
2nd: CENTER,HALF
3rd: CENTER,BASE
str = "NIST"
to determine:
vloc(cap) = cap location of rectangle bottom = txexry(1)
vloc(half) = half location of rectangle bottom = txexry(1)
vloc(base) = base location of rectangle bottom = txexry(1)
For approximate equality:
abstol = absolute tolerance = .02 * chh
reltol = relative tolerance = .02
TEST: #SR 8 11
"Character height should set the distance between the CAP
and BASE lines of a capital letter."
pass/fail depending on (vloc(base)-vloc(cap) approx= chh)
TEST: #SR 11
"Text alignment for HALF should be approximately halfway
between CAP and BASE."
pass/fail depending on
(.7*vloc(base) + .3*vloc(cap) > vloc(half) and
.3*vloc(base) + .7*vloc(cap) < vloc(half))
chh = default character height = 4.4
For approximate equality:
abstol = absolute tolerance = .02 * chh
reltol = relative tolerance = .02
Set horizontal and vertical limits for reasonable fraction
of text rectangle indicated by text alignment:
low high
horlim: ---- ----
left -.01 .01
center .49 .51
right .99 1.01
verlim:
top .99 1.01
cap .60 1.01
half .20 .80
base .01 .40
bottom -.01 .01
for txp = RIGHT,LEFT,UP,DOWN
<inquire text extent> with:
wktype = specwt
font = 2 (ASCII font)
chxp = -0.33
chsp = -0.1
chh = as is
txp = as is
txal = LEFT, BOTTOM
str = "W.j "
to determine:
nomw = nominal width = abs (txexrx(2) - txexrx(1))
nomh = nominal height = abs (txexry(2) - txexry(1))
nomcpx = nominal concatenation x-offset
nomcpy = nominal concatenation y-offset
calculate NORMAL alignment, based on this txp:
if (txp = RIGHT) then
nhoral = LEFT
nveral = BASE
elseif (txp = LEFT) then
nhoral = RIGHT
nveral = BASE
elseif (txp = UP) then
nhoral = CENTER
nveral = BASE
elseif (txp = DOWN) then
nhoral = CENTER
nveral = TOP
else
Abort: illegal text path
endif
for htxal = NORMAL, LEFT, CENTER, RIGHT
calculate actual horizontal alignment:
if (htxal = NORMAL) then
ahtxal = nhoral
else
ahtxal = htxal
endif
for vtxal = NORMAL, TOP, CAP, HALF, BASE, BOTTOM
calculate actual vertical alignment:
if (vtxal = NORMAL) then
avtxal = nveral
else
avtxal = vtxal
endif
conmsg = "When text path is " + txp + " and text alignment
is (" + htxal + "," + vtxal ") "
<inquire text extent> with wktype, font, chxp, chsp,
chh, txp, str unchanged, but
txal = htxal,vtxal
to determine rectangle:
reclox = txexrx(1)
rechix = txexrx(2)
recloy = txexry(1)
rechiy = txexry(2)
and concatenation point:
cpx, cpy
TEST: #SR 2 10 11 12 13 15 16
conmsg + " the size of the text extent rectangle
should be unaffected."
pass/fail depending on ((rechix-reclox) approx= nomw and
(rechiy-recloy) approx= nomh)
TEST: #SR 2 10 11 12 13 15 16
conmsg + " the location of the text extent
rectangle should be shifted as indicated by
the text alignment."
calculate low, high fraction of rectangle:
frlox = -reclox / nomw
frhix = 1 - rechix / nomw
frloy = -recloy / nomh
frhiy = 1 - rechiy / nomh
pass/fail depending on
(horlim (ahtxal, low) <= frlox and
horlim (ahtxal, high) >= frlox and
horlim (ahtxal, low) <= frhix and
horlim (ahtxal, high) >= frhix and
verlim (avtxal, low) <= frloy and
verlim (avtxal, high) >= frloy and
verlim (avtxal, low) <= frhiy and
verlim (avtxal, high) >= frhiy )
if (txp = LEFT or RIGHT) then
expcpx = nomcpx + reclox
expcpy = 0
else (txp is vertical)
expcpx = 0
expcpy = nomcpy + recloy
endif
TEST: #SR 10 11 12 13 17 18
conmsg + " the concatenation point should be
shifted along the text path dimension by the same
amount as the text extent rectangle."
pass/fail depending on
(cpx approx= expcpx and
cpy approx= expcpy)
save vertical displacements:
vertab (vtxal) = recloy
next vtxal
vermsg = "When text path is " + txp + " and horizontal text
alignment is " + htxal + ", "
TEST: #SR 10 11 12 13 16
vermsg + " then NORMAL vertical alignment should have the
same effect as " + nveral + "."
pass/fail depending on (vertab(NORMAL) approx= vertab(nveral))
TEST: #SR 10 11 13 16
vermsg + " then vertical alignments TOP, CAP, HALF,
BASE, and BOTTOM should cause increasing vertical
displacements."
pass/fail depending on
( vertab(TOP) <= vertab(CAP) < vertab(HALF) <
vertab(BASE) < vertab(BOTTOM) )
next htxal
next txp
END PROGRAM 4