Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 28739 - Not possible to change Tree/Table fonts
Summary: Not possible to change Tree/Table fonts
Status: RESOLVED DUPLICATE of bug 56558
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 major with 6 votes (vote)
Target Milestone: 3.0   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 41221 42562
  Show dependency tree
 
Reported: 2002-12-20 09:47 EST by Andre Weinand CLA
Modified: 2004-03-29 07:53 EST (History)
3 users (show)

See Also:


Attachments
Reduces the theme font size to use kThemeSmallSystemFont (2.10 KB, patch)
2003-09-18 03:16 EDT, Anjo Krank CLA
no flags Details | Diff
Patch for SWT (5.11 KB, patch)
2003-12-25 15:19 EST, Boris Pruessmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Weinand CLA 2002-12-20 09:47:43 EST
Most heavily discussed issue with M4 on all mailing lists:

The fonts used in Tree/Tables (Navigator, Tasklist) are rather large and there seems to 
be no way to change them.
Comment 1 Veronika Irvine CLA 2002-12-20 11:34:14 EST
The current table and tree are the emulated ones and their font can already be 
changed through API.  By default we are using the system default font which is 
what we do on all platforms.

Isn't this a problem in the Eclipse UI that it does not give access to this 
capability?

Usually, there is a way for the user to configure the system default font 
(.gtkrc, .Xdefaults, Control Panel ->Display Attributes).  How do you do this 
on the Mac?  In the absence of Eclipse UI access, this is how users are advised 
to modify the fonts.

Also, the users can modify jfacefonts_macosx.properties files found in the 
jface.jar in plugins/org.eclipse.jface_2.1.0.  I believe the relevant line is:

   org.eclipse.jface.defaultfont.0=Courier-regular-12

Perhaps this setting should be made smaller by default.
Comment 2 Andre Weinand CLA 2002-12-20 12:03:11 EST
Yes, on Mac OS X it becomes a problem of the Eclipse UI because there seems to be 
now official UI for changing system fonts in Mac OS X (or am I missing something?).

I will investigate what to do....

Comment 3 Wilhelm Fitzpatricck CLA 2003-02-03 19:58:23 EST
suggestion:  OS X seems to have different "system fonts" for different purposes.
 There is the System Font (Lucidia Grande 13) that is used for menus and window
titles, and then there is the Application Font (Helvetica 12) that is used for
labels and widgets.  There is even a Fixed Font (Monacao 10).  It seems
Table/Tree should be using the Application Font.  Would SWT support such a notion?
Comment 4 Nick Edgar CLA 2003-03-05 14:55:05 EST
Consider for 2.2.
Comment 5 Anjo Krank CLA 2003-03-31 18:18:07 EST
There is a simple fix to get at least Eclipse to display fonts at reasonable
sizes (roughly the same size that all the other platforms use).

http://www.prnet.de/RegEx/eclipse.txt

It sets the default display to OS.SmallSystemFont and removes the special
handling of tree, combo and table widgets.

There is still too much space left around the items but at least you can view
more  than a few items in the UI.
Comment 6 Anjo Krank CLA 2003-05-18 17:21:16 EDT
Please change the default font discovery to go through some bottleneck. I'd propose to put it into 
org/eclipse/swt/graphics/Device.java as a new method int getDefaultFont() and this should return 
either OS.kThemeSystemFont or OS. kThemeSmallSystemFont settable via some default.

This time, I have included all changes needed to have a consitent font size thoughout all the SWT 
controlled classe and I would be very gratefuly if you could apply it. The general behaviour will stay 
the same unless a "SWTUsesSmallFonts" default is set to the value "true", so there is applying this 
fix will not impair other SWT apps in the least.

On OSX, Eclipse´s usefulness is very much impaired due a a few interface bugs - like too-large 
fonts and menu bar oddities and as this is a very small fix I'd really wish for you to integrate it.

diff -r -c3 swtsrc_2/org/eclipse/swt/graphics/Device.java swtsrc_3/org/eclipse/swt/graphics/
Device.java
*** swtsrc_2/org/eclipse/swt/graphics/Device.java       Thu Mar 27 10:51:48 2003
--- swtsrc_3/org/eclipse/swt/graphics/Device.java       Sun May 18 23:12:40 2003
***************
*** 492,511 ****
        COLOR_MAGENTA = new Color (this, 0xFF,0,0xFF);
        COLOR_CYAN = new Color (this, 0,0xFF,0xFF);
        COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
  
!       /* Initialize the system font slot */
!       short id = OS.GetAppFont();
!       short style = (short)0; 
!       short size = OS.GetDefFontSize();
!       int[] font = new int[1];
!       if (OS.FMGetFontFromFontFamilyInstance(id, style, font, null) != 0) {
!               SWT.error(SWT.ERROR_NO_HANDLES);
!       }
!       systemFont = Font.carbon_new (this, font[0], id, style, size);
  }
  
! /**    
!  * Invokes platform specific functionality to allocate a new GC handle.
   * <p>
   * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
   * API for <code>Device</code>. It is marked public only so that it
--- 492,541 ----
        COLOR_MAGENTA = new Color (this, 0xFF,0,0xFF);
        COLOR_CYAN = new Color (this, 0,0xFF,0xFF);

        COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
+ 
+         systemFont = getDefaultFont();
  
! }
! /**
!  * @return default base font used by all widgets. 
!  */
! protected Font getDefaultFont() {
!     Font defaultFont = null;
! 
!     if("true".equals(System.getProperty("SWTUsesSmallFonts"))) {
!         /* Initialize the system font slot */
!         short id = OS.GetAppFont();
!         short style = (short)0;
!         short size = OS.GetDefFontSize();
!         int[] font = new int[1];
!         if (OS.FMGetFontFromFontFamilyInstance(id, style, font, null) != 0) {
!             SWT.error(SWT.ERROR_NO_HANDLES);
!         }
!         defaultFont = Font.carbon_new (this, font[0], id, style, size);
!     } else {
!         /* Initialize the system font by using the default small font */
!         byte [] family = new byte [256];
!         short [] size = new short [1];
!         byte [] style = new byte [1];
!         OS.GetThemeFont ((short) defaultThemeFont (), (short) OS.smSystemScript, family, size, 
style);
!         short id = OS.FMGetFontFamilyFromName (family);
!         int [] font = new int [1];
!         OS.FMGetFontFromFontFamilyInstance (id, style [0], font, null);
!         defaultFont = Font.carbon_new (this, font [0], id, style [0], size [0]);
!     }
!     return defaultFont;
! }
! 
! /**
! * Bottleneck routine for all the default fonts.
! * @return default theme font used by all widgets (should be small system font because all the 
others are too large on OSX).
!  */
! public int defaultThemeFont () {
!     return OS.kThemeSmallSystemFont;
  }
  
! /**
! * Invokes platform specific functionality to allocate a new GC handle.
   * <p>
   * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
   * API for <code>Device</code>. It is marked public only so that it
diff -r -c3 swtsrc_2/org/eclipse/swt/widgets/Control.java swtsrc_3/org/eclipse/swt/widgets/
Control.java
*** swtsrc_2/org/eclipse/swt/widgets/Control.java       Thu Mar 27 10:52:36 2003
--- swtsrc_3/org/eclipse/swt/widgets/Control.java       Sun May 18 23:11:22 2003
***************
*** 490,497 ****
        return display.getSystemColor (SWT.COLOR_BLACK);
  }
  
! int defaultThemeFont () {
!       return OS.kThemeSystemFont;
  }
  
  void deregister () {
--- 490,497 ----
        return display.getSystemColor (SWT.COLOR_BLACK);
  }
  
! int defaultThemeFont () {
!     return getDisplay().defaultThemeFont();
  }
  
  void deregister () {
diff -r -c3 swtsrc_2/org/eclipse/swt/widgets/Table.java swtsrc_3/org/eclipse/swt/widgets/
Table.java
*** swtsrc_2/org/eclipse/swt/widgets/Table.java Tue Mar 11 18:38:28 2003
--- swtsrc_3/org/eclipse/swt/widgets/Table.java Sun May 18 22:14:51 2003
***************
*** 330,339 ****
        return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
  }
  
- int defaultThemeFont () {
-       return OS.kThemeViewsFont;
- }
- 
  /**
   * Deselects the item at the given zero-relative index in the receiver.
   * If the item at the index was already deselected, it remains
--- 330,335 ----
diff -r -c3 swtsrc_2/org/eclipse/swt/widgets/Tree.java swtsrc_3/org/eclipse/swt/widgets/
Tree.java
*** swtsrc_2/org/eclipse/swt/widgets/Tree.java  Thu Apr 24 12:22:24 2003
--- swtsrc_3/org/eclipse/swt/widgets/Tree.java  Sun May 18 22:14:23 2003
***************
*** 326,335 ****
        return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
  }
  
- int defaultThemeFont () {
-       return OS.kThemeViewsFont;
- }
- 
  /**
   * Deselects all selected items in the receiver.
   *
--- 326,331 ----
Comment 7 Anjo Krank CLA 2003-09-18 03:16:28 EDT
Created attachment 6136 [details]
Reduces the theme font size to use kThemeSmallSystemFont

The font size for the tree and table items in the main window is way too large.
Especially on an iBook, there is hardly any space left for the code.

This patch adds a new method defaultThemeFont() on Display, reduces the overall
font size to use the small system font and instructs tables and tree to also
use it.

So defaultThemeFont() is now a bottleneck that could easily be modified to
check a system default that restores the previous behaviour.

Please apply this patch. There are numerous bug reports about the font size
being to big and they have been outstanding a long while now.
Comment 8 Andre Weinand CLA 2003-09-18 04:04:46 EDT
Thanks for the patch.
Could you please create the patch with Eclipse's Create Patch command?
You can find it in the Navigator's context menu under "Team > Create Patch..."
It will result in a patch that doesn't use absolute path names and is easier to apply.
Comment 9 Boris Pruessmann CLA 2003-12-25 15:19:08 EST
Created attachment 7276 [details]
Patch for SWT

Re-packaged patch to be used via "Apply patch..."

Looks much better! I would even say that screen estate utilisation matches
windows with this patch.
Comment 10 Andre Weinand CLA 2003-12-25 16:40:40 EST
Cool! The first useful Christmas present... :-)
Comment 11 Andre Weinand CLA 2004-03-29 07:53:54 EST

*** This bug has been marked as a duplicate of 56558 ***