src/java.desktop/share/classes/sun/awt/FontDescriptor.java

Print this page

        

*** 22,35 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.awt; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.StandardCharsets; - import sun.nio.cs.HistoricallyNamedCharset; public class FontDescriptor implements Cloneable { static { NativeLibLoader.loadLibraries(); --- 22,37 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.awt; + import java.io.ByteArrayInputStream; + import java.io.InputStreamReader; + import java.io.IOException;; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.StandardCharsets; public class FontDescriptor implements Cloneable { static { NativeLibLoader.loadLibraries();
*** 47,61 **** this.nativeName = nativeName; this.encoder = encoder; this.exclusionRanges = exclusionRanges; this.useUnicode = false; Charset cs = encoder.charset(); ! if (cs instanceof HistoricallyNamedCharset) ! this.charsetName = ((HistoricallyNamedCharset)cs).historicalName(); ! else ! this.charsetName = cs.name(); ! } public String getNativeName() { return nativeName; } --- 49,67 ---- this.nativeName = nativeName; this.encoder = encoder; this.exclusionRanges = exclusionRanges; this.useUnicode = false; Charset cs = encoder.charset(); ! // The following looks odd but its the only public way to get the ! // historical name if one exists and the canonical name otherwise. ! try { ! ByteArrayInputStream bais = new ByteArrayInputStream(new byte[8]); ! InputStreamReader isr = new InputStreamReader(bais, cs); ! this.charsetName = isr.getEncoding(); ! isr.close(); ! } catch (IOException ioe) { ! } } public String getNativeName() { return nativeName; }