Skip to content

Commit

Permalink
Fixed #371 - Switch default font name to Verdana
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Nov 7, 2023
1 parent 073250f commit 2035700
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
* Frank Buloup - Internationalization
*******************************************************************************/
package org.eclipse.swtchart.extensions.core;
Expand Down Expand Up @@ -45,7 +45,7 @@ public abstract class AbstractAxisSettings implements IAxisSettings {
/*
* The default font is only used if no font is set.
*/
private final Font defaultFont = Resources.getFont("Tahoma", Resources.MEDIUM_FONT_SIZE, SWT.BOLD); //$NON-NLS-1$
private final Font defaultFont = Resources.getFont(Resources.DEFAULT_FONT_NAME, Resources.MEDIUM_FONT_SIZE, SWT.BOLD); // $NON-NLS-1$

protected AbstractAxisSettings(String title) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
* Frank Buloup - Internationalization
*******************************************************************************/
package org.eclipse.swtchart.extensions.core;
Expand Down Expand Up @@ -118,7 +118,7 @@ public class ChartSettings implements IChartSettings {
/*
* The default font is only used if no font is set.
*/
private final Font defaultFont = Resources.getFont("Tahoma", Resources.MEDIUM_FONT_SIZE, SWT.BOLD); //$NON-NLS-1$
private final Font defaultFont = Resources.getFont(Resources.DEFAULT_FONT_NAME, Resources.MEDIUM_FONT_SIZE, SWT.BOLD); // $NON-NLS-1$

public ChartSettings() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Contributors:
* yoshitaka - initial API and implementation
* Christoph Läubrich - adjust for API changes
* Philip Wenig - default font name
*******************************************************************************/
package org.eclipse.swtchart;

Expand Down Expand Up @@ -45,7 +46,7 @@ public class AxisTickTest extends ChartTestCase {
private static final double[] ySeries = {0.0, 0.38, 0.71, 0.92, 1.0};

@Override
public void setUp() {
public void setUp() {

super.setUp();
xAxisTick = chart.getAxisSet().getXAxis(0).getTick();
Expand All @@ -56,7 +57,7 @@ public void setUp() {
* Test for foreground.
*/
@Test
public void testForeground() {
public void testForeground() {

// set null
xAxisTick.setForeground(null);
Expand Down Expand Up @@ -103,7 +104,7 @@ public void testForeground() {
* Test for axis tick font.
*/
@Test
public void testFont() {
public void testFont() {

// set null
xAxisTick.setFont(null);
Expand All @@ -118,15 +119,15 @@ public void testFont() {
assertEquals(smallFontData.getHeight(), fontData.getHeight());
assertEquals(smallFontData.getStyle(), fontData.getStyle());
// set the disposed font
Font font = new Font(Display.getCurrent(), "Tahoma", 11, SWT.BOLD);
Font font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 11, SWT.BOLD);
font.dispose();
try {
xAxisTick.setFont(font);
fail();
} catch(IllegalArgumentException e) {
// expected to reach here
}
font = new Font(Display.getCurrent(), "Tahoma", 12, SWT.BOLD);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 12, SWT.BOLD);
font.dispose();
try {
yAxisTick.setFont(font);
Expand All @@ -135,22 +136,22 @@ public void testFont() {
// expected to reach here
}
// set normal font
font = new Font(Display.getCurrent(), "Tahoma", 18, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 18, SWT.ITALIC);
xAxisTick.setFont(font);
fontData = xAxisTick.getFont().getFontData()[0];
assertEquals("Tahoma", fontData.getName());
assertEquals(Resources.DEFAULT_FONT_NAME, fontData.getName());
assertEquals(18, fontData.getHeight());
assertEquals(SWT.ITALIC, fontData.getStyle());
showChart();
yAxisTick.setFont(font);
fontData = yAxisTick.getFont().getFontData()[0];
assertEquals("Tahoma", fontData.getName());
assertEquals(Resources.DEFAULT_FONT_NAME, fontData.getName());
assertEquals(18, fontData.getHeight());
assertEquals(SWT.ITALIC, fontData.getStyle());
showChart();
font.dispose();
// set large font size
font = new Font(Display.getCurrent(), "Tahoma", 64, SWT.BOLD);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 64, SWT.BOLD);
xAxisTick.setFont(font);
fontData = xAxisTick.getFont().getFontData()[0];
assertEquals(64, fontData.getHeight());
Expand All @@ -161,7 +162,7 @@ public void testFont() {
showChart();
font.dispose();
// set tiny font size
font = new Font(Display.getCurrent(), "Tahoma", 4, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 4, SWT.ITALIC);
xAxisTick.setFont(font);
fontData = xAxisTick.getFont().getFontData()[0];
assertEquals(4, fontData.getHeight());
Expand All @@ -177,7 +178,7 @@ public void testFont() {
* Test for axis tick visibility.
*/
@Test
public void testVisibility() {
public void testVisibility() {

// show X axis tick
xAxisTick.setVisible(false);
Expand All @@ -199,7 +200,7 @@ public void testVisibility() {
* Test for tick mark step hint.
*/
@Test
public void testTickMarkStepHint() {
public void testTickMarkStepHint() {

// set small value the tick mark step hint
xAxisTick.setTickMarkStepHint(10);
Expand Down Expand Up @@ -234,7 +235,7 @@ public void testTickMarkStepHint() {
* Test for format.
*/
@Test
public void testFormat() {
public void testFormat() {

// create line series
ILineSeries<?> lineSeries = (ILineSeries<?>)chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
Expand Down Expand Up @@ -263,7 +264,7 @@ public void testFormat() {
* Test for tick label values.
*/
@Test
public void testTickLabelValues() {
public void testTickLabelValues() {

ILineSeries<?> lineSeries = (ILineSeries<?>)chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
lineSeries.setYSeries(ySeries);
Expand All @@ -281,7 +282,7 @@ public void testTickLabelValues() {
* Test for tick label angle.
*/
@Test
public void testTickLabelAngle() {
public void testTickLabelAngle() {

ILineSeries<?> lineSeries = (ILineSeries<?>)chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
lineSeries.setYSeries(ySeries);
Expand All @@ -295,7 +296,7 @@ public void testTickLabelAngle() {
*/
@Test
@Ignore("environment dependent")
public void testBounds() {
public void testBounds() {

ILineSeries<?> lineSeries = (ILineSeries<?>)chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
lineSeries.setYSeries(ySeries);
Expand Down Expand Up @@ -325,4 +326,4 @@ public void testBounds() {
assertEquals(35, yAxisBounds.width);
assertEquals(217, yAxisBounds.height);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* yoshitaka - initial API and implementation
* Philip Wenig - default font name
*******************************************************************************/
package org.eclipse.swtchart;

Expand Down Expand Up @@ -149,7 +150,7 @@ public void testFont() {
// set null
xAxisTitle.setFont(null);
FontData fontData = xAxisTitle.getFont().getFontData()[0];
Font font = new Font(Display.getCurrent(), "Tahoma", 13, SWT.BOLD);
Font font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 13, SWT.BOLD);
FontData defaultFontData = font.getFontData()[0];
assertEquals(defaultFontData.getName(), fontData.getName());
assertEquals(defaultFontData.getHeight(), fontData.getHeight());
Expand All @@ -161,16 +162,16 @@ public void testFont() {
assertEquals(defaultFontData.getStyle(), fontData.getStyle());
font.dispose();
// set font
font = new Font(Display.getCurrent(), "Tahoma", 15, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 15, SWT.ITALIC);
xAxisTitle.setFont(font);
fontData = xAxisTitle.getFont().getFontData()[0];
assertEquals("Tahoma", fontData.getName());
assertEquals(Resources.DEFAULT_FONT_NAME, fontData.getName());
assertEquals(15, fontData.getHeight());
assertEquals(SWT.ITALIC, fontData.getStyle());
showChart();
yAxisTitle.setFont(font);
fontData = yAxisTitle.getFont().getFontData()[0];
assertEquals("Tahoma", fontData.getName());
assertEquals(Resources.DEFAULT_FONT_NAME, fontData.getName());
assertEquals(15, fontData.getHeight());
assertEquals(SWT.ITALIC, fontData.getStyle());
showChart();
Expand All @@ -189,26 +190,26 @@ public void testFont() {
// expected to reach here
}
// set large font size
font = new Font(Display.getCurrent(), "Tahoma", 64, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 64, SWT.ITALIC);
xAxisTitle.setFont(font);
fontData = xAxisTitle.getFont().getFontData()[0];
assertEquals(64, fontData.getHeight());
showChart();
font.dispose();
font = new Font(Display.getCurrent(), "Tahoma", 64, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 64, SWT.ITALIC);
yAxisTitle.setFont(font);
fontData = yAxisTitle.getFont().getFontData()[0];
assertEquals(64, fontData.getHeight());
showChart();
font.dispose();
// set tiny font size
font = new Font(Display.getCurrent(), "Tahoma", 4, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 4, SWT.ITALIC);
xAxisTitle.setFont(font);
fontData = xAxisTitle.getFont().getFontData()[0];
assertEquals(4, fontData.getHeight());
showChart();
font.dispose();
font = new Font(Display.getCurrent(), "Tahoma", 4, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 4, SWT.ITALIC);
yAxisTitle.setFont(font);
font = yAxisTitle.getFont();
fontData = font.getFontData()[0];
Expand Down Expand Up @@ -237,4 +238,4 @@ public void testVisibility() {
assertTrue(yAxisTitle.isVisible());
showChart();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* yoshitaka - initial API and implementation
* Philip Wenig - default font name
*******************************************************************************/
package org.eclipse.swtchart;

Expand Down Expand Up @@ -113,17 +114,17 @@ public void testFont() {
title.setFont(null);
Font font = title.getFont();
FontData fontData = font.getFontData()[0];
FontData defaultFontData = new Font(Display.getDefault(), "Tahoma", 13, SWT.BOLD).getFontData()[0];
FontData defaultFontData = new Font(Display.getDefault(), Resources.DEFAULT_FONT_NAME, 13, SWT.BOLD).getFontData()[0];
assertEquals(defaultFontData.getName(), fontData.getName());
assertEquals(defaultFontData.getHeight(), fontData.getHeight());
assertEquals(defaultFontData.getStyle(), fontData.getStyle());
// set font
title.setText("foo");
font = new Font(Display.getCurrent(), "Tahoma", 18, SWT.ITALIC);
font = new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 18, SWT.ITALIC);
title.setFont(font);
font = title.getFont();
fontData = font.getFontData()[0];
assertEquals("Tahoma", fontData.getName());
assertEquals(Resources.DEFAULT_FONT_NAME, fontData.getName());
assertEquals(18, fontData.getHeight());
assertEquals(SWT.ITALIC, fontData.getStyle());
showChart();
Expand All @@ -136,14 +137,14 @@ public void testFont() {
// expected to reach here
}
// set large font size
title.setFont(new Font(Display.getCurrent(), "Tahoma", 64, SWT.ITALIC));
title.setFont(new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 64, SWT.ITALIC));
font = title.getFont();
fontData = font.getFontData()[0];
assertEquals(64, fontData.getHeight());
showChart();
font.dispose();
// set tiny font size
title.setFont(new Font(Display.getCurrent(), "Tahoma", 4, SWT.ITALIC));
title.setFont(new Font(Display.getCurrent(), Resources.DEFAULT_FONT_NAME, 4, SWT.ITALIC));
font = title.getFont();
fontData = font.getFontData()[0];
assertEquals(4, fontData.getHeight());
Expand Down Expand Up @@ -174,4 +175,4 @@ public void testVisibility() {
int height = ((Title)title).getBounds().height;
assertEquals(0, height);
}
}
}
Loading

0 comments on commit 2035700

Please sign in to comment.