home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / lout2.lzh / LOUT2 / DOC / TR.IMPL / s2.5 < prev    next >
Text File  |  1994-01-25  |  4KB  |  91 lines

  1. @SubSection
  2.     @Tag { style }
  3.     @Title { Context-sensitive attributes of objects }
  4. @Begin
  5. @PP
  6. Although we are free to place any object in any context, the context
  7. must influence the appearance of the object, since otherwise
  8. @ID @Code "A short paragraph of text."
  9. could not appear in a variety of fonts, column widths, etc.  This
  10. influence cannot take the purely static form that block-structured
  11. languages use to associate values with identifiers, for then an operator
  12. could not influence the appearance of its parameters; and a state
  13. variable solution is not compatible with the overall functional design.
  14. @PP
  15. The information needed from the context seems quite limited, comprising
  16. the font family, face, and size to use, the style of paragraph breaking
  17. required, how much space to substitute between the words of paragraphs,
  18. and how much horizontal and vertical space is available to receive the
  19. object.  These four items constitute the so-called `style information'
  20. of Lout.  As graphics rendering hardware improves, the style information
  21. will probably grow to include colour and texture information.
  22. @PP
  23. The way to deal with fonts at least is very clear:
  24. @ID @Code "{ Times Slope 12p } @Font { Hello, world }"
  25. should have result
  26. @ID { { Times Slope 12p } @Font { Hello, world } }
  27. Lout also provides @Code "@Break" and @Code "@Space" symbols for
  28. controlling the paragraph breaking and space styles mentioned
  29. above.  These work in the same way, returning their right
  30. parameters in the style of their left.  The implementation is very
  31. simple:  one merely broadcasts the style information down into the parse
  32. tree of the right parameter.  A font, for example, is converted to an
  33. 8-bit internal name and stored in each leaf, while a breaking style is
  34. stored in the root node of each paragraph.
  35. @PP
  36. The same language design can be used for available width and height,
  37. only here the implementation is much more demanding:
  38. @ID @Code {
  39. "2i @Wide {"
  40. "(1)  |0.1i  An example"
  41. "containing a small"
  42. "paragraph of filled text."
  43. "}"
  44. }
  45. is guaranteed to be two inches wide:
  46. @ID {
  47. 2i @Wide {
  48. (1)  |0.1i  An example
  49. containing a small
  50. paragraph of filled text.
  51. }
  52. }
  53. One must calculate that 1.9 inches minus the width of @Code "(1)" is
  54. available
  55. to the paragraph, and break it accordingly; Basser Lout does this in two
  56. stages.  In the first, upward-moving stage, widths are calculated using the
  57. formulae of Section {@NumberOf objects}, which assume that available
  58. space is infinite.  If the upward movement reaches a @Eq { WIDE }
  59. node, corresponding to a @Code "@Wide" operator, and
  60. the calculated width exceeds that allowed, a second, downward-moving stage
  61. is initiated which attempts to reduce the width by finding and breaking
  62. paragraphs.  This second stage is quite routine except at @Code "|" nodes,
  63. whose children are the columns of a table.  It is necessary to apportion
  64. the available width (minus inter-column gaps) among the columns.  Basser
  65. Lout leaves narrow columns unbroken and breaks the remaining columns to
  66. equal width, using up all of the available space.
  67. @PP
  68. The size of an object is not clearly determined when the upward-moving
  69. size is less than the downward-moving available space, and the object
  70. contains constructs that depend on available space (e.g. right
  71. justification).  For example, in
  72. @ID @Code "2i @Wide { Heading // a |1rt b }"
  73. it seems natural to assign a width of two inches to the subobject
  74. @Code "a |1rt b" because of the right justification, but it would be
  75. equally plausible if the width of @Code Heading was assigned to the
  76. subobject instead.  The author is conscious of having failed to resolve
  77. this matter properly; an extra operator for controlling available space
  78. is probably necessary.
  79. @PP
  80. The actual paragraph breaking is just a simple transformation on the
  81. parse tree; the real issue is how to describe the various styles:  ragged
  82. right, adjusted, outdented, and so on.  Their diversity suggests that
  83. they should somehow be defined using more basic features; but then there
  84. are algorithms for high-quality paragraph breaking, which presumably
  85. must be built-in.  This dilemma was not clearly grasped by the author in
  86. 1985, and he included a built-in paragraph breaker, with the @Code
  87. "@Break" operator selecting from a fixed set of styles.  A much better
  88. solution based on galleys will be given in Section {@NumberOf horizontal},
  89. but, regrettably, it is not implemented.
  90. @End @SubSection
  91.