mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] use fallback fonts for renderring commit message in details IDEA-143113
This commit is contained in:
@@ -288,14 +288,29 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
|
||||
myMainText = null;
|
||||
}
|
||||
else {
|
||||
String header = commit.getId().toShortString() + " " + getAuthorText(commit) +
|
||||
(myMultiRoot ? " [" + commit.getRoot().getName() + "]" : "");
|
||||
String header = getHtmlWithFonts(commit.getId().toShortString() + " " + getAuthorText(commit) +
|
||||
(myMultiRoot ? " [" + commit.getRoot().getName() + "]" : ""));
|
||||
String body = getMessageText(commit);
|
||||
myMainText = header + "<br/>" + body;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getHtmlWithFonts(@NotNull String input) {
|
||||
return getHtmlWithFonts(input, getBaseFont().getStyle());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getHtmlWithFonts(@NotNull String input, int style) {
|
||||
return FontUtil.getHtmlWithFonts(input, style, getBaseFont());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Font getBaseFont() {
|
||||
return EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
|
||||
}
|
||||
|
||||
void setBranches(@Nullable List<String> branches) {
|
||||
if (branches == null) {
|
||||
myBranches = null;
|
||||
@@ -313,7 +328,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
|
||||
}
|
||||
else {
|
||||
setText("<html><head>" +
|
||||
UIUtil.getCssFontDeclaration(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)) +
|
||||
UIUtil.getCssFontDeclaration(getBaseFont()) +
|
||||
"</head><body>" +
|
||||
myMainText +
|
||||
"<br/>" +
|
||||
@@ -413,8 +428,8 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
|
||||
int separator = fullMessage.indexOf("\n\n");
|
||||
String subject = separator > 0 ? fullMessage.substring(0, separator) : fullMessage;
|
||||
String description = fullMessage.substring(subject.length());
|
||||
return "<b>" + escapeMultipleSpaces(IssueLinkHtmlRenderer.formatTextWithLinks(myProject, subject)) + "</b>" +
|
||||
escapeMultipleSpaces(IssueLinkHtmlRenderer.formatTextWithLinks(myProject, description));
|
||||
return "<b>" + getHtmlWithFonts(escapeMultipleSpaces(IssueLinkHtmlRenderer.formatTextWithLinks(myProject, subject)), Font.BOLD) + "</b>" +
|
||||
getHtmlWithFonts(escapeMultipleSpaces(IssueLinkHtmlRenderer.formatTextWithLinks(myProject, description)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class FontUtil {
|
||||
@NotNull
|
||||
public static Font getFontAbleToDisplay(char c, int style, @NotNull Font baseFont) {
|
||||
return ComplementaryFontsRegistry.getFontAbleToDisplay(c, baseFont.getSize(), style, baseFont.getFamily()).getFont();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getHtmlWithFonts(@NotNull String input, int style, @NotNull Font baseFont) {
|
||||
int start = baseFont.canDisplayUpTo(input);
|
||||
if (start == -1) return input;
|
||||
|
||||
Font font = null;
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = start; i < input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
if (baseFont.canDisplay(c)) {
|
||||
if (font != null) result.append("</font>");
|
||||
result.append(c);
|
||||
font = null;
|
||||
}
|
||||
else if (font != null && font.canDisplay(c)) {
|
||||
result.append(c);
|
||||
}
|
||||
else {
|
||||
if (font != null) result.append("</font>");
|
||||
font = getFontAbleToDisplay(c, style, baseFont);
|
||||
if (font != baseFont) result.append("<font face=\"").append(font.getFamily()).append("\">");
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
if (font != null) result.append("</font>");
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user