Hi,

Roman Kennke wrote:

Some more stuff that I had trouble with Espial/Espresso. This should fix
the font handling in AWT.

[...]

   /**
    * Called to ensure that the layout for this component is valid. This is
    * usually called on containers.
    *
    * @see #invalidate()
    * @see #doLayout()
    * @see LayoutManager
    * @see Container#validate()
    */
   public void validate()
   {
-    valid = true;
+    if (! valid)
+      {
+        // Synchronize on the tree here as this might change the layout
+        // of the hierarchy.
+        synchronized (getTreeLock())
+          {
+            // Create local variables for thread safety.
+            ComponentPeer p = peer;
+            if (p != null)
+              {
+                // Possibly update the peer's font.
+                Font newFont = getFont();
+                Font oldFont = peerFont;
+                // Only update when the font really changed.
+                if (newFont != oldFont
+                    && (oldFont == null || ! oldFont.equals(newFont)))
+                  {
+                    p.setFont(newFont);
+                    peerFont = newFont;
+                  }
+                // Let the peer perform any layout.
+                p.layout();
+              }
+          }
+        valid = true;
+      }
   }

Does the reference implementation do this font field manipulation in validate? Why is this needed in addition to the setFont part of your patch?

Tom

Reply via email to