Skip to content

Commit

Permalink
Update font change dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed Jul 29, 2021
1 parent 864fcdb commit ca59fe0
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import name.abuchen.portfolio.ui.Images;
Expand Down Expand Up @@ -97,14 +98,21 @@ public String getText(Object element)
label = new Label(area, SWT.NONE);
label.setText(Messages.LabelFontSize);

int systemFontSize = Display.getDefault().getSystemFont().getFontData()[0].getHeight();

fontSizeCombo = new ComboViewer(area, SWT.READ_ONLY);
fontSizeCombo.setLabelProvider(new LabelProvider()
{
@Override
public String getText(Object element)
{
int size = (Integer) element;
return size == -1 ? Messages.LabelDefaultFontSize : String.valueOf(size) + "px"; //$NON-NLS-1$
String label = size == -1 ? Messages.LabelDefaultFontSize : String.valueOf(size) + "px"; //$NON-NLS-1$

if (size == systemFontSize)
label += " (" + Messages.LabelDefaultFontSize + ")"; //$NON-NLS-1$ //$NON-NLS-2$

return label;
}

});
Expand Down Expand Up @@ -221,9 +229,11 @@ private void writeFrontSizeToCSS(int fontSize)

if (fontSize > 0)
{
int[] delta = new int[] { 2, 6, -1 }; // windows + linux
int[] delta = new int[] { 3, 10, -1 }; // windows
if (Platform.OS_MACOSX.equals(Platform.getOS()))
delta = new int[] { 3, 10, -1 }; // mac
else if (Platform.OS_LINUX.equals(Platform.getOS()))
delta = new int[] { 1, 10, -1 }; // linux

css = String.format("* { font-size: %dpx;}%n" //$NON-NLS-1$
+ ".heading1 { font-size: %dpx; }%n" //$NON-NLS-1$
Expand Down

0 comments on commit ca59fe0

Please sign in to comment.