This may well be a fix to the "Improper line wrapping" bug. The fix

is basically that we use our own special ViewFactory, with a new
subclass of LabelView (the view RTFEditorKit uses for the nitty
gritty) that is aware of Tibetan.

There are a couple of nasty hacks still here, and Swing's
documentation for doing what I did was quite poor.  I searched the web
for hours, read the Javadocs and the tutorials, and consulted a Swing
reference book, but I still don't have tremendous confidence in this
solution.  If it fundamentally doesn't work, though, we have to define
our own first-class Document, Element hierarchy, ViewFactory, Views,
and EditorKit.  So let's hope it *does* work fundamentally.

I can't say for sure if this even works, as I have yet to run this
code on a machine where Jskad works properly.  I had major trouble
installing the TMW fonts on Linux, and have yet to resolve it, even
after verifying via xlsfonts that the fonts were installed and then
changing TibetanMachineWeb.java to look for them.  Because I haven't
tested this yet, a lot of nasty code is tagged 'DLC' and commented
out.
This commit is contained in:
dchandler 2002-10-28 03:08:04 +00:00
parent f26dd53da3
commit 0ad135f8f1
5 changed files with 267 additions and 8 deletions

View file

@ -18,6 +18,7 @@ Contributor(s): ______________________________________.
package org.thdl.tib.input;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.datatransfer.*;
@ -25,13 +26,9 @@ import java.awt.font.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.lang.*;
import org.thdl.tib.text.*;
import java.io.*;
import javax.swing.text.rtf.*;
import org.thdl.tib.text.*;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlOptions;
import org.thdl.util.StatusBar;
@ -307,13 +304,11 @@ public RTFEditorKit rtfEd = null;
/**
* This method sets up the editor, assigns fonts and point sizes,
* sets the document, the caret, and adds key and focus listeners.
*
* @param sek the StyledEditorKit for the editing window
*/
private void setupEditor() {
rtfBoard = getToolkit().getSystemClipboard();
rtfFlavor = new DataFlavor("text/rtf", "Rich Text Format");
rtfEd = new RTFEditorKit();
rtfEd = new TibetanRTFEditorKit();
setEditorKit(rtfEd);
styleContext = new StyleContext();