// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.editor.colors;

import com.intellij.openapi.editor.Editor;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.NotNull;

import java.awt.Font;
import java.util.HashMap;
import java.util.Map;

public enum EditorFontType {
  PLAIN,
  BOLD,
  ITALIC,
  BOLD_ITALIC,
  CONSOLE_PLAIN,
  CONSOLE_BOLD,
  CONSOLE_ITALIC,
  CONSOLE_BOLD_ITALIC;

  private static final Map<EditorFontType, EditorFontType> ourConsoleTypes = new HashMap<>();
  static {
    ourConsoleTypes.put(PLAIN, CONSOLE_PLAIN);
    ourConsoleTypes.put(ITALIC, CONSOLE_ITALIC);
    ourConsoleTypes.put(BOLD_ITALIC, CONSOLE_BOLD_ITALIC);
    ourConsoleTypes.put(BOLD, CONSOLE_BOLD);
  }

  public static EditorFontType getConsoleType(EditorFontType fontType) {
    return ObjectUtils.chooseNotNull(ourConsoleTypes.get(fontType), fontType);
  }

  /**
   * @return a font of this type according to the global colors scheme
   */
  public @NotNull Font getGlobalFont() {
    return EditorColorsManager.getInstance().getGlobalScheme().getFont(this);
  }
}

// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.editor.colors;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.awt.Font;

public enum EditorFontType {
  PLAIN,
  BOLD,
  ITALIC,
  BOLD_ITALIC,
  CONSOLE_PLAIN,
  CONSOLE_BOLD,
  CONSOLE_ITALIC,
  CONSOLE_BOLD_ITALIC;

  /**
   * @param type a font type to convert
   * @return a console variant of the specified font type
   */
  public static @Nullable EditorFontType getConsoleType(@Nullable EditorFontType type) {
    return type == PLAIN ? CONSOLE_PLAIN :
           type == ITALIC ? CONSOLE_ITALIC :
           type == BOLD ? CONSOLE_BOLD :
           type == BOLD_ITALIC ? CONSOLE_BOLD_ITALIC : type;
  }

  /**
   * @return a font of this type according to the global colors scheme
   */
  public @NotNull Font getGlobalFont() {
    return EditorColorsManager.getInstance().getGlobalScheme().getFont(this);
  }
}

Simplify EditorFontType.getConsoleType