/*
 * 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.openapi.vcs.ui;

import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;

import java.awt.*;

public class FontUtil {
  @NotNull
  public static Font getFontAbleToDisplay(char c, int size, int style, @NotNull String family) {
    return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, family, null).getFont();
  }

  @NotNull
  public static String getHtmlWithFonts(@NotNull String input) {
    Font font = UIUtil.getLabelFont();
    return getHtmlWithFonts(input, font.getStyle(), font);
  }

  @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(input.substring(0, start));
    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, baseFont.getSize(), style, baseFont.getFamily());
        if (font != baseFont) result.append("<font face=\"").append(font.getFamily()).append("\">");
        result.append(c);
      }
    }
    if (font != null) result.append("</font>");

    return result.toString();
  }
}

@@ -777,16 +777,59 @@
 NotNull;
+%0Aimport org.jetbrains.annotations.Nullable;
 %0A%0Aimport
@@ -866,30 +866,31 @@
 tUtil %7B%0A  @N
-otN
 ull
+able
 %0A  public st
@@ -979,22 +979,27 @@
 ) %7B%0A    
-return
+Font font =
  Complem
@@ -1076,24 +1076,69 @@
 .getFont();%0A
+    return font.canDisplay(c) ? font : null;%0A
   %7D%0A%0A  @NotN
@@ -2086,24 +2086,20 @@
 font != 
-baseFont
+null
 ) result

fix font fallback in commit details