Design: 04.02.04.01/P06

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 6: Annotation text path, character height, expansion
           factor, spacing, and up vector

CHARACTERISTICS: ynny

OPERATOR SCRIPT:

ANNOTATION TEXT PATH AND CHARACTER UP: A short text string should
be visible.  First, indicate whether the entire string is laid
out horizontally or vertically.  Next, indicate the up direction
of the individual characters.  Finally, type in the leftmost (for
a horizontal string) or topmost (for a vertical string)
character.

ANNOTATION TEXT CHARACTER HEIGHT, EXPANSION, AND SPACING FOR
HORIZONTAL PATHS: Several horizontal lines containing an
annotation text string are drawn with various values for the
character attributes.  The expected character body positions are
outlined with a dotted line and a dashed baseline, usually of a
different color than the annotation text itself.  Identify the
single line in which the characters do NOT fall within the dotted
boxes.  In the case of overlapping characters due to negative
character spacing, half-boxes are drawn, so that the boxes
themselves don't overlap.

ANNOTATION TEXT CHARACTER HEIGHT, EXPANSION, AND SPACING FOR
VERTICAL PATHS: Same as above, except that the annotation text
choices are vertical columns, not horizontal lines.  Note that
expected position is aligned on vertical centerline (not left- or
right-justified); the actual characters, therefore, must not
appear to the left or right of the expected box.  In the case of
overlapping characters due to negative character spacing,
half-boxes are drawn, so that the boxes themselves don't overlap.

DESIGN:

TEST: #SR 5 7 23 55 56 57 58 70 71 72
      "Annotation text path should specify the direction in which
       successive characters are generated and annotation text
       character up vector should rotate the resulting
       primitive."

set text font = 2
set text precision = STROKE
chstr = mostly non-symmetrical characters = "SPQR"
for txp = RIGHT,LEFT,UP,DOWN
   set annotation text path = txp
   rot = rotation amount = random 0,90,180,270 degrees
   set annotation text character up vector = rot
   draw chstr as an annotation text primitive

   OPQA/ANNOTATION TEXT PATH AND CHARACTER UP: Is text string as
      a whole oriented horizontally (1) or vertically (2)?
   opans = operator response
   if ((txp = LEFT or RIGHT) and (rot =  0 or 180)) or
      ((txp = UP   or DOWN)  and (rot = 90 or 270)) then
      truans = 1
   else
      truans = 2
   endif
   if (truans not= opans) then
      fail
      goto end_text_path
   endif

   OPQA/ANNOTATION TEXT PATH AND CHARACTER UP: Is the character
      up direction to the left (1), top (2), right (3), or bottom (4)?
   opans = operator response
   if (opans does not match rot) then
      fail
      goto end_text_path
   endif

   OPQA/ANNOTATION TEXT PATH AND CHARACTER UP: Identify the
      character to the left/top of the screen.
   if (operator response incorrect) then
      fail
      goto end_text_path
   endif

next txp
pass

end_text_path:

use <inquire text extent> with
  text font                  = 1
  character height           = 1 (WC)
  character spacing          = 0
  character expansion factor = 1
  text string                = "WWiig!"
to determine
  ncbht = nominal character body height
  ncbwd = nominal character body width

set annotation text path = RIGHT
set text font = 1
set text precision = STROKE
numlin = number of lines = 6
ngline = random number from 1 to numlin
for ix = 1 to numlin
   randomly select an annotation text character height, expansion
     factor, and spacing, to fit on one line

   calculate expected character boxes
   if (ix = ngline) then
      distort character boxes
   endif
   draw in character boxes, using dotted line style, color #2

   set non-unit scaling modelling transform to show that
     size of annotation-text is unaffected, even though
     location is affected.
   display annotation text "WWiig!" on line ix
   restore identity modelling transform
next ix

TEST: #SR 1 2 5 11 23 26 27 28 32 33 34 48 49 50 51 52 57 58 60
      "The size and shape of an annotation text string displayed
       with STROKE precision in a monospaced font on a horizontal
       annotation text path should conform exactly to the
       annotation text character height, expansion factor, and
       spacing in effect."

OPQA/ANNOTATION TEXT CHARACTER HEIGHT, EXPANSION, AND SPACING FOR
  HORIZONTAL PATHS: In which line are the characters of the
  annotation text string NOT aligned within dotted character
  boxes and on the dashed baseline?
pass/fail depending on (operator picks location ngline)

set annotation text path = DOWN
set text font = 1
set text precision = STROKE
numcol = number of columns = 6
ngcol  = random number from 1 to numcol
for ix = 1 to numcol
   randomly select an annotation text character height, expansion
     factor, and spacing, to fit on one column

   calculate expected character boxes
   if (ix = ngcol) then
      distort character boxes
   endif
   draw in character boxes, using dotted line style, color #2

   set non-unit scaling modelling transform to show that
     size of annotation-text is unaffected, even though
     location is affected.
   display annotation text "WWiig!" on line ix
   restore identity modelling transform
next ix

TEST: #SR 1 2 5 11 23 26 27 28 32 33 34 48 49 50 51 52 57 58 59
      "The size and shape of an annotation text string displayed
       with STROKE precision in a monospaced font on a vertical
       annotation text path should conform exactly to the
       annotation text character height, expansion factor, and
       spacing in effect."

OPQA/ANNOTATION TEXT CHARACTER HEIGHT, EXPANSION, AND SPACING FOR
  VERTICAL PATHS: In which column are the characters of the
  annotation text string NOT aligned within dotted character
  boxes and on the dashed centerline?
pass/fail depending on (operator picks location ngcol)

bestfn = a stroke text font other than 1, preferably not #2 and
         not monospaced

bestsc = best score so far for font properties = -1
bestfn = best font so far = -1
for ix = each available non-#1 stroke font
   thisfn = ixth font from <inquire text facilities>
   use <inquire text extent> with
     text font                  = thisfn
     character height           = 1
     character spacing          = 0
     character expansion factor = 1
     text string                = "WWW"
   to determine
     tcbhtw = nominal character body height for W
     tcbwdw = nominal character body width for W

   use <inquire text extent> with
     text font                  = thisfn
     character height           = 1
     character spacing          = 0
     character expansion factor = 1
     text string                = "iii"
   to determine
     tcbhti = nominal character body height for i
     tcbwdi = nominal character body width for i

   if (thisfn = 2) then
      fnscor = score for this font = 0
   else
      fnscor = score for this font = 1
   endif

   if (ncbwdi approx= ncbwdw) then
      do nothing
   else
      add 2 to fnscor
   endif

   if (fnscor > bestsc) then
      best font so far:
      bestsc = fnscor
      bestfn = thisfn
      ncbhtw = tcbhtw
      ncbwdw = tcbwdw
      ncbhti = tcbhti
      ncbwdi = tcbwdi
      if (fnscor >= 3) then
         got a non-2, non-monospaced font: goto got_font
      endif
   endif
next stroke font

if (bestsc <= -1) then
   message: skipping tests for proportionately spaced fonts; none
            available.
   goto endit
endif

got_font:

set annotation text path = LEFT
set text font = bestfn
set text precision = STROKE
numlin = number of lines = 6
ngline = random number from 1 to numlin
for ix = 1 to numlin
   randomly select an annotation text character height, expansion
      factor, and spacing, to fit on one line
   calculate expected character boxes
   if (ix = ngline) then
      distort character boxes
   endif
   draw in character boxes, using dotted line style, color #2
   display annotation text "WWiiiW" on line ix
next ix

TEST: #SR 1 2 5 11 23 26 27 28 32 33 34 48 49 50 51 52 57 58 60
      "The size and shape of an annotation text string displayed
       with STROKE precision in any font on a horizontal
       annotation text path should conform exactly to the
       annotation text character height, expansion factor, and
       spacing in effect."

OPQA/ANNOTATION TEXT CHARACTER HEIGHT, EXPANSION, AND SPACING FOR
  HORIZONTAL PATHS: In which line are the characters of the
  annotation text string NOT aligned within dotted character
  boxes and on the dashed baseline?
pass/fail depending on (operator picks location ngline)

set annotation text path = UP
set text precision = STROKE
numcol = number of columns = 6
ngcol  = random number from 1 to numcol
for ix = 1 to numcol
   randomly select an annotation text character height, expansion
     factor, and spacing, to fit in one column
   calculate expected character boxes
   if (ix = ngcol) then
      distort character boxes
   endif
   draw in character boxes, using dotted line style, color #2
   display annotation text "WWiiiW" in column ix
next ix

TEST: #SR 1 2 5 11 19 23 26 27 29 32 33 34 48 49 50 52 57 58 59
      "The size and shape of an annotation text string displayed
       with STROKE precision in any font on a vertical annotation
       text path should conform exactly to the annotation text
       character height, expansion factor, and spacing in
       effect."

OPQA/ANNOTATION TEXT CHARACTER HEIGHT, EXPANSION, AND SPACING FOR
  VERTICAL PATHS: In which column are the characters of the
  annotation text string NOT aligned within dotted character
  boxes and on the dashed centerline?
pass/fail depending on (operator picks location ngcol)

endit:

END PROGRAM 6