mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-09 10:01:41 +01:00
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 commit8c86ad3e96) (cherry picked from commitc423003bd4) (cherry picked from commitbcae402dc8)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user