Skip to content

Demonstrate that SVG rasterization on mac is low-resolution #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions durian-swt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ p2deps {
into 'testImplementation', {
p2repo "https://download.eclipse.org/eclipse/updates/$SWT_VERSION/"
install 'org.eclipse.swt'
install 'org.eclipse.swt.svg'
}
}
dependencies {
Expand Down
10 changes: 5 additions & 5 deletions durian-swt/src/main/java/com/diffplug/common/swt/Shells.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
private var title: String? = null
private var image: Image? = null
private var alpha = SWT.DEFAULT
private val size = Point(SWT.DEFAULT, SWT.DEFAULT)
private val size = SwtKt.Point(SWT.DEFAULT, SWT.DEFAULT)
private var positionIncludesTrim = true
private var location: Map.Entry<Corner, Point>? = null
private var dontOpen = false
Expand Down Expand Up @@ -86,7 +86,7 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
* Calls [.setLocation] and [.setSize] in one line.
*/
fun setRectangle(rect: Rectangle): Shells {
return setLocation(Point(rect.x, rect.y)).setSize(Point(rect.width, rect.height))
return setLocation(SwtKt.Point(rect.x, rect.y)).setSize(SwtKt.Point(rect.width, rect.height))
}

/**
Expand Down Expand Up @@ -290,12 +290,12 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
}
}
val topLeft =
location!!.key.topLeftRequiredFor(Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
bounds = Rectangle(topLeft.x, topLeft.y, computedSize.x, computedSize.y)
location!!.key.topLeftRequiredFor(SwtKt.Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
bounds = SwtKt.Rectangle(topLeft.x, topLeft.y, computedSize.x, computedSize.y)
} else {
val computedSize = shell.computeSize(size.x, size.y, true)
val topLeft =
location!!.key.topLeftRequiredFor(Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
location!!.key.topLeftRequiredFor(SwtKt.Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
bounds = shell.computeTrim(topLeft.x, topLeft.y, computedSize.x, computedSize.y)
}
}
Expand Down
29 changes: 29 additions & 0 deletions durian-swt/src/main/java/com/diffplug/common/swt/SwtKt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.diffplug.common.swt;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;

public class SwtKt {
public static Point Point(int x, int y) {
return new Point(x, y);
}

public static Rectangle Rectangle(int x, int y, int width, int height) {
return new Rectangle(x, y, width, height);
}
}
55 changes: 55 additions & 0 deletions durian-swt/src/test/java/com/diffplug/common/swt/Issue_2228.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.diffplug.common.swt;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.junit.Test;
import org.junit.experimental.categories.Category;

@Category(InteractiveTest.class)
public class Issue_2228 {
@Test
public void recreate() {
// testCoat probably takes a title and a lambda that receives the parent Composite
InteractiveTest.testCoat(
"Show the difference between `.svg` and `@x2.png` rendering",
(Composite parent) -> {
// two-column grid
Layouts.setGrid(parent).numColumns(2);

// “.svg” label + image
Label svgLabel = new Label(parent, SWT.NONE);
svgLabel.setText(".svg");

Label svgImage = new Label(parent, SWT.NONE);
ImageDescriptor svgDesc = ImageDescriptor.createFromFile(
Issue_2228.class, "/issue_2228/strikethrough.svg");
svgImage.setImage(svgDesc.createImage());

// “.png” label + image
Label pngLabel = new Label(parent, SWT.NONE);
pngLabel.setText(".png");

Label pngImage = new Label(parent, SWT.NONE);
ImageDescriptor pngDesc = ImageDescriptor.createFromFile(
Issue_2228.class, "/issue_2228/strikethrough.png");
pngImage.setImage(pngDesc.createImage());
});
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions durian-swt/src/test/resources/issue_2228/strikethrough.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ VER_DURIAN=1.2.0
VER_DURIAN_RX=5.0.1
VER_DURIAN_DEBUG=1.1.0
# SWT Dependencies from P2
SWT_VERSION=4.21
SWT_VERSION=4.36
SWT_VERSION_X86=4.7

# Testing
Expand Down