From 29bf3f64e43ed153670dfeee6dd4b553d1543016 Mon Sep 17 00:00:00 2001 From: Alpi Rimppi Date: Thu, 26 Sep 2019 11:26:55 +0300 Subject: [PATCH] Change editor font in UI and update on editor reload. gitlab #390 Change-Id: Ieae1ceb208a3e401f122725eda5693e1e4aeb5b5 --- bundles/org.simantics.scl.ui/plugin.xml | 9 +++++++++ .../scl/ui/editor2/SCLPresentationReconciler.java | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/bundles/org.simantics.scl.ui/plugin.xml b/bundles/org.simantics.scl.ui/plugin.xml index 85e8aad7a..bb69f55bf 100644 --- a/bundles/org.simantics.scl.ui/plugin.xml +++ b/bundles/org.simantics.scl.ui/plugin.xml @@ -254,6 +254,15 @@ The SCL Console font is used by SCL Console and SCL Script Output console views. + + + The SCL editor font is used by SCL module and script editors. + + diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLPresentationReconciler.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLPresentationReconciler.java index b74e35fb2..7a937f8a3 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLPresentationReconciler.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLPresentationReconciler.java @@ -1,6 +1,7 @@ package org.simantics.scl.ui.editor2; import org.eclipse.jface.resource.FontDescriptor; +import org.eclipse.jface.resource.FontRegistry; import org.eclipse.jface.resource.ResourceManager; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextAttribute; @@ -17,11 +18,16 @@ import org.eclipse.jface.text.rules.WordRule; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.PlatformUI; import org.simantics.scl.ui.info.SCLInfo; public class SCLPresentationReconciler extends PresentationReconciler { - private static final FontDescriptor FONT_NORMAL = FontDescriptor.createFrom("Consolas", 10, SWT.NORMAL); //$NON-NLS-1$ - private static final FontDescriptor FONT_BOLD = FontDescriptor.createFrom("Consolas", 10, SWT.BOLD); //$NON-NLS-1$ + + + private final FontRegistry fontRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry(); + + private final FontDescriptor FONT_NORMAL = FontDescriptor.createFrom( fontRegistry.getFontData("org.simantics.scl.editorfont") ); + private final FontDescriptor FONT_BOLD = FONT_NORMAL.setStyle(SWT.BOLD); public SCLPresentationReconciler(ResourceManager resourceManager) { Font font = resourceManager.createFont(FONT_NORMAL); @@ -52,8 +58,8 @@ public class SCLPresentationReconciler extends PresentationReconciler { setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); } } - - private static ITokenScanner getSclTokenScanner(ResourceManager resourceManager) { + + private ITokenScanner getSclTokenScanner(ResourceManager resourceManager) { RuleBasedScanner scanner = new RuleBasedScanner(); Token defaultToken = new Token( -- 2.47.1