Commit 7b085136 authored by hpi1's avatar hpi1

Fix java.awt.Component.getFontMetric() with some J2SE versions

parent 78c37425
......@@ -30,7 +30,7 @@ import java.util.Map;
import org.videolan.Logger;
public class BDFontMetrics extends FontMetrics {
public class BDFontMetrics extends sun.font.FontDesignMetrics {
static final long serialVersionUID = -4956160226949100590L;
private static long ftLib = 0;
......@@ -175,6 +175,15 @@ public class BDFontMetrics extends FontMetrics {
return fm;
}
static {
sun.font.FontDesignMetrics.setGetFontMetricsAccess(
new sun.font.FontDesignMetrics.GetFontMetricsAccess() {
public sun.font.FontDesignMetrics getFontMetrics(Font font) {
return BDFontMetrics.getFontMetrics(font);
}
});
}
static String stripAttributes(String fontname) {
int dotidx;
if ((dotidx = fontname.indexOf('.')) == -1)
......
/*
* This file is part of libbluray
* Copyright (C) 2015 libbluray
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
package sun.font;
import java.awt.FontMetrics;
import java.awt.Font;
/*
* This class is used to "fix" Java 7 java.awt.Component.getFontMetrics()
*
* one disc calls directly (new java.awt.Component() { ... } ).getFontMetrics(font)
*
*/
public class FontDesignMetrics extends FontMetrics {
protected interface GetFontMetricsAccess {
public abstract FontDesignMetrics getFontMetrics(Font font);
}
private static GetFontMetricsAccess access;
protected static void setGetFontMetricsAccess(GetFontMetricsAccess a) {
access = a;
}
/*
*
*/
public static FontDesignMetrics getMetrics(Font font) {
return access.getFontMetrics(font);
}
protected FontDesignMetrics(Font font) {
super(font);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment