mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-169924 do not scale a system font like editor
This commit is contained in:
@@ -943,7 +943,7 @@ editor.breadcrumbs.highlight.on.hover.description=Highlight corresponding ranges
|
||||
editor.breadcrumbs.above=false
|
||||
editor.breadcrumbs.above.description=Show breadcrumbs above or below an editor
|
||||
|
||||
editor.breadcrumbs.small.font=true
|
||||
editor.breadcrumbs.small.font=false
|
||||
editor.breadcrumbs.small.font.description=Use small font to show breadcrumbs
|
||||
|
||||
editor.breadcrumbs.system.font=true
|
||||
|
||||
@@ -70,6 +70,7 @@ import java.util.LinkedList;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import static com.intellij.ui.ScrollPaneFactory.createScrollPane;
|
||||
import static com.intellij.util.ui.UIUtil.getLabelFont;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
@@ -169,7 +170,7 @@ public class BreadcrumbsXmlWrapper extends JComponent implements Disposable {
|
||||
|
||||
breadcrumbs.onHover(this::itemHovered);
|
||||
breadcrumbs.onSelect(this::itemSelected);
|
||||
breadcrumbs.setFont(getEditorFont(myEditor));
|
||||
breadcrumbs.setFont(getNewFont(myEditor));
|
||||
|
||||
JScrollPane pane = createScrollPane(breadcrumbs, true);
|
||||
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
@@ -191,7 +192,7 @@ public class BreadcrumbsXmlWrapper extends JComponent implements Disposable {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent event) {
|
||||
breadcrumbs.updateBorder(gutterComponent.getWhitespaceSeparatorOffset());
|
||||
breadcrumbs.setFont(getEditorFont(myEditor));
|
||||
breadcrumbs.setFont(getNewFont(myEditor));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -216,7 +217,7 @@ public class BreadcrumbsXmlWrapper extends JComponent implements Disposable {
|
||||
|
||||
private void updateCrumbs() {
|
||||
if (breadcrumbs != null && myEditor != null && !myEditor.isDisposed()) {
|
||||
breadcrumbs.setFont(getEditorFont(myEditor));
|
||||
breadcrumbs.setFont(getNewFont(myEditor));
|
||||
updateCrumbs(myEditor.getCaretModel().getLogicalPosition());
|
||||
}
|
||||
}
|
||||
@@ -516,6 +517,11 @@ public class BreadcrumbsXmlWrapper extends JComponent implements Disposable {
|
||||
if (EditorEx.PROP_FONT_SIZE.equals(event.getPropertyName())) queueUpdate();
|
||||
}
|
||||
|
||||
private static Font getNewFont(Editor editor) {
|
||||
Font font = editor == null || Registry.is("editor.breadcrumbs.system.font") ? getLabelFont() : getEditorFont(editor);
|
||||
return font == null || !Registry.is("editor.breadcrumbs.small.font") ? font : font.deriveFont(font.getSize2D() / 1.09f);
|
||||
}
|
||||
|
||||
private static Font getEditorFont(Editor editor) {
|
||||
return ComplementaryFontsRegistry.getFontAbleToDisplay('a', Font.PLAIN, editor.getColorsScheme().getFontPreferences(),
|
||||
null).getFont();
|
||||
|
||||
@@ -22,11 +22,9 @@ import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.components.breadcrumbs.Breadcrumbs;
|
||||
import com.intellij.ui.components.breadcrumbs.Crumb;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
/**
|
||||
@@ -45,21 +43,6 @@ final class PsiBreadcrumbs extends Breadcrumbs {
|
||||
super.paintMarker(g, x, y, width, above ? height : thickness, crumb, thickness);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFont(Font font) {
|
||||
if (font != null) {
|
||||
float size = font.getSize2D();
|
||||
if (Registry.is("editor.breadcrumbs.system.font")) {
|
||||
Font system = UIUtil.getLabelFont();
|
||||
if (system != null) font = system.deriveFont(size);
|
||||
}
|
||||
if (Registry.is("editor.breadcrumbs.small.font")) {
|
||||
font = font.deriveFont(size / 1.09f);
|
||||
}
|
||||
}
|
||||
super.setFont(font);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getForeground() {
|
||||
if (!isForegroundSet()) {
|
||||
|
||||
Reference in New Issue
Block a user