Skip to content

Commit

Permalink
Always use monospaced font in expression builder and text editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Yulin Wang committed Feb 23, 2016
1 parent 23880c9 commit d66d09b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.eclipse.birt.report.designer.internal.ui.editors.ReportColorConstants;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.ui.ReportPlugin;
import org.eclipse.birt.report.designer.util.FontManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
Expand All @@ -23,8 +25,11 @@
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;

/**
* Sets JS configuration the editor needs
Expand Down Expand Up @@ -155,4 +160,18 @@ public void resetScannerColor( )
scanner.setDefaultReturnToken( new Token( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_CONTENT_COLOR_PREFERENCE ) ) );
}
}

public static void updateSourceFont( SourceViewer sourceViewer )
{
if ( Platform.getOS( ).equals( Platform.WS_WIN32 ) )
{
Font font = sourceViewer.getTextWidget( ).getFont( );
FontData data = font.getFontData( )[0];
// BIRT-1113 Always use monospaced font
Font newFont = FontManager.getFont( "Courier", //$NON-NLS-1$
data.getHeight( ),
data.getStyle( ) );
sourceViewer.getTextWidget( ).setFont( newFont );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import org.eclipse.birt.report.designer.ui.preferences.PreferenceFactory;
import org.eclipse.birt.report.designer.util.DEUtil;
import org.eclipse.birt.report.designer.util.DNDUtil;
import org.eclipse.birt.report.designer.util.FontManager;
import org.eclipse.birt.report.model.api.DataSetHandle;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.LevelAttributeHandle;
import org.eclipse.birt.report.model.api.ModuleHandle;
Expand All @@ -57,7 +55,6 @@
import org.eclipse.birt.report.model.api.util.UnicodeUtil;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
Expand Down Expand Up @@ -112,8 +109,6 @@
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
Expand Down Expand Up @@ -697,15 +692,7 @@ private void createExpressionField( Composite parent )
GridData gd = new GridData( GridData.FILL_BOTH );
gd.heightHint = 150;
sourceViewer.getControl( ).setLayoutData( gd );
if ( Platform.getOS( ).equals( Platform.WS_WIN32 ) )
{
Font font = sourceViewer.getTextWidget( ).getFont( );
FontData data = font.getFontData( )[0];
Font newFont = FontManager.getFont( data.getName( ),
data.getHeight( ) + 1,
data.getStyle( ) );
sourceViewer.getTextWidget( ).setFont( newFont );
}
JSSourceViewerConfiguration.updateSourceFont( sourceViewer );
sourceViewer.getTextWidget( ).addKeyListener( new KeyAdapter( ) {

public void keyPressed( KeyEvent e )
Expand Down

0 comments on commit d66d09b

Please sign in to comment.