Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6795562

HTMLEditorKit : Add Support for LineSpacing (line-height)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 6u10
    • client-libs

      A DESCRIPTION OF THE REQUEST :
      A Swing Styled Text Component using HTMLEditorKit as its EditorKit won't use neither the line-height CSS attribute nor the LineSpacing text attribute defined in StyleConstants to render a paragraph with line spacing

      JUSTIFICATION :
      The RTF Editor Kit and the Styled Editor Kit fully support the LineSpacing attribute in the Swing Framework, so styled text components (JEditorPane and descedants) using those Editor kits will correctly display line-spaced paragraphs. However, HTMLEditorKit doesn't at all.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Paragraphs which have been set the attribute LineSpacing to a valid float number, distinct to 1.0, OR the CSS line-height attribute, should be able to render the lines of the paragraph with the desired line spacing . The LineSpacing attirbute should be translated to the CSS line-height attribute in order to be correctly restored from the text generated by getText()
      ACTUAL -
      Neither StyleConstants.setLineSpacing nor CSS.Attribute.LINE_HEIGHT are rendered by HTMLEditorKit

      CUSTOMER SUBMITTED WORKAROUND :
      Extend javax.swing.text.html.ParagraphView in order to overload the method setPropertiesFromAttributes, in order to convert the CSS.Attribute.LINE_HEIGHT to a valid number. Use StyleConstants.setLineSpacing in order to apply the valid number as linespacing to the ParagraphView
      Extend HTMLEditorKit to return a extended View Factory which returns the extended ParagraphView for all elements whose ElementName is P or P-IMPLIED.
      As you can see, you must extend at least 3 classes from the Core Swing Text Package, yet it's completely WORTHLESS because the HTML rendered in labels and buttons across the entire Swing Framework uses BasicHTML, which in turns uses HTMLEditorKit, it will not use your extended HTMLEditorKit!

            peterz Peter Zhelezniakov
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: