JBR-1699 Use platform font rendering for bundled fonts on MacOS

Used CFont instead of TrueTypeFont for bundled fonts on mac
Use different family for specific font faces. Refactoring

(cherry picked from commit 8c86ad3e96)
(cherry picked from commit c423003bd4)
(cherry picked from commit bcae402dc8)
This commit is contained in:
Alexey Ushakov
2019-07-29 18:00:23 +02:00
committed by jbrbot
parent 2bd6edd9ff
commit 2e5e513cc9
2 changed files with 26 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ package sun.font;
import java.awt.*;
import java.io.File;
import java.io.FilenameFilter;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -35,14 +36,12 @@ import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.plaf.FontUIResource;
import sun.awt.FontConfiguration;
import sun.awt.HeadlessToolkit;
import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*;
public final class CFontManager extends SunFontManager {
@@ -144,6 +143,18 @@ public final class CFontManager extends SunFontManager {
}
}
@Override
protected void registerJREFonts() {
String[] files = AccessController.doPrivileged((PrivilegedAction<String[]>) () ->
new File(jreFontDirName).list(getTrueTypeFilter()));
if (files != null) {
for (String f : files) {
loadNativeDirFonts(jreFontDirName + File.separator + f);
}
}
}
protected void registerFontsInDir(final String dirName, boolean useJavaRasterizer,
int fontRank, boolean defer, boolean resolveSymLinks) {
@@ -166,6 +177,11 @@ public final class CFontManager extends SunFontManager {
private native void loadNativeFonts();
void registerFont(String fontName, String fontFamilyName) {
// Use different family for specific font faces
String newFontFamily = jreFamilyMap.get(fontName);
if (newFontFamily != null) {
fontFamilyName = newFontFamily;
}
final CFont font = new CFont(fontName, fontFamilyName);
registerGenericFont(font);

View File

@@ -270,6 +270,14 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
return ttFilter;
}
FilenameFilter getTrueTypeFilterIdea() {
return ttFilterIdea;
}
FilenameFilter getTrueTypeFilterJre() {
return ttFilterJre;
}
public FilenameFilter getType1Filter() {
return t1Filter;
}