Skip to content
Merged
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
19 changes: 15 additions & 4 deletions bundles/org.eclipse.swt.svg/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ Bundle-Vendor: %providerName
Bundle-Localization: fragment
Bundle-RequiredExecutionEnvironment: JavaSE-21
Fragment-Host: org.eclipse.swt
Import-Package: com.github.weisj.jsvg;version="[2.0.0,3.0.0)",
com.github.weisj.jsvg.parser;version="[2.0.0,3.0.0)",
com.github.weisj.jsvg.view;version="[2.0.0,3.0.0)"
Import-Package: com.github.weisj.jsvg;version="[2.1.0,3.0.0)",
com.github.weisj.jsvg.logging;version="[2.1.0,3.0.0)",
com.github.weisj.jsvg.parser;version="[2.1.0,3.0.0)",
com.github.weisj.jsvg.view;version="[2.1.0,3.0.0)"
Export-Package: org.eclipse.swt.svg;x-internal:=true
Provide-Capability: eclipse.swt;image.format="svg";version:Version="1.0"
Provide-Capability:
eclipse.swt;
image.format="svg";
version:Version="1.0",
osgi.service;
objectClass:List<String>="com.github.weisj.jsvg.logging.LogManager";
effective:=active,
osgi.serviceloader;
osgi.serviceloader="com.github.weisj.jsvg.logging.LogManager";
register:="org.eclipse.swt.svg.logging.JVSGLoggerLogManager"

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.swt.svg.logging.JVSGLoggerLogManager
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@
*/
public class JSVGRasterizer implements SVGRasterizer {

private static final SVGLoader SVG_LOADER = new SVGLoader();
private static final SVGLoader SVG_LOADER;

static {
Thread thread = Thread.currentThread();
ClassLoader contextClassLoader = thread.getContextClassLoader();
try {
thread.setContextClassLoader(JSVGRasterizer.class.getClassLoader());
SVG_LOADER = new SVGLoader();
} finally {
thread.setContextClassLoader(contextClassLoader);
}
}

private final static Map<Key, Object> RENDERING_HINTS = Map.of( //
KEY_ANTIALIASING, VALUE_ANTIALIAS_ON, //
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2026 Eclipse contributors and others.
*
* This program and the accompanying materials are made available under the terms of the Eclipse
* Public License 2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*******************************************************************************/
package org.eclipse.swt.svg.logging;

import java.util.function.Supplier;

import com.github.weisj.jsvg.logging.LogManager;
import com.github.weisj.jsvg.logging.Logger;

public class JVSGLoggerLogManager implements LogManager {

private static final Logger.Level LEVEL = Logger.Level.valueOf(System.getProperty("org.eclipse.swt.svg.logging", "ERROR"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not very robust. Using a string does not exactly (including capitalization) match one of the existing logger levels results in no SVG being rendered. You will nothing very quickly 😆 but maybe we could be more resilient and in case the Logger.Level.valueOf(...) log some error stating that the set log level is unsupported and then make the log level default to error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's true. As we discussed, I'll push this through now so I can clean up the target platform before the nightly build and then you can improve this aspect at your leisure. You're right that in invalid value is kind of swallowed without good feedback.


@Override
public Logger createLogger(String name) {
return new Logger() {
@Override
public void log(Logger.Level level, String message, Throwable e) {
if (level.compareTo(LEVEL) <= 0) {
return;
}
doLog(level, message);
e.printStackTrace();
}

@Override
public void log(Logger.Level level, Supplier<String> messageSupplier) {
if (level.compareTo(LEVEL) < 0) {
return;
}
doLog(level, messageSupplier.get());
}

@Override
public void log(Logger.Level level, String message) {
if (level.compareTo(LEVEL) < 0) {
return;
}
doLog(level, message);
}

private void doLog(Logger.Level level, String message) {
System.err.format("JSVGRasterizer: %s: %s: %s", level, name, message).println();
}
};
}
}
Loading