D2Coding Nerd 폰트 만들기

D2Coding 버전 1.4.0 폰트의 Nerd 폰트를 직접 만들어 보았다.

2026년 10월에 D2Coding 폰트의 버전 1.4.0이 릴리즈 되었다.
D2Coding은 내가 주력으로 사용하는 폰트이고, 특히 터미널 환경에서는 D2Coding Nerd 폰트를 사용하는데, Nerd Fonts 페이지에는 D2Coding Nerd 폰트가 올라오지 않아서 직접 만들어 보았다.

D2Coding 버전 1.4.0 폰트 준비

$ wget https://github.com/naver/d2-coding-font/releases/download/VER1.4.0/D2Coding-Ver1.4.0-20261003.zip
$ unzip D2Coding-Ver1.4.0-20261003.zip

이제 아래와 같이 사용할 D2Coding-Ver1.4.0-20261003.ttf 파일을 D2Coding-Regular.ttf 이름으로 복사한다.

$ cp D2Coding/D2Coding-Ver1.4.0-20261003.ttf D2Coding-Regular.ttf

즉, D2Coding-Regular.ttf 파일을 사용하여 Nerd 폰트를 생성할 것이다.

Nerd 폰트 생성하기

기존 폰트에 아이콘을 포함시켜서 Nerd 폰트를 만들려면 Nerd Font 페이지를 참고하여 Font Patcher 툴을 사용하면 된다.

  1. Ubuntu에서는 아래와 같이 FontForge 패키지를 설치한다.
    $ sudo apt install software-properties-common
    $ sudo add-apt-repository ppa:fontforge/fontforge
    $ sudo apt update
    $ sudo apt install fontforge
    

    또는 FontForge 최신 버전을 사용하려면, 아래 예와 같이 FontForge Release 페이지에서 FontForge AppImage를 다운받아서 사용할 수 있다.

    $ wget https://github.com/fontforge/fontforge/releases/download/20251009/FontForge-2025-10-09-Linux-x86_64.AppImage
    $ chmod +x FontForge-2025-10-09-Linux-x86_64.AppImage
    $ mv FontForge-2025-10-09-Linux-x86_64.AppImage ~/.local/bin/fontforge
    
  2. 아래와 같이 Nerd Font 소스를 clone 받은 후에, 해당 디렉토리로 이동한다.
    $ git clone https://github.com/ryanoasis/nerd-fonts.git --depth 1
    $ cd nerd-fonts/
    
  3. 위에서 얻은 D2Coding-Regular.ttf 파일을 nerd-fonts 디렉토리로 복사한다.
  4. 이제 아래와 같이 실행시키면 Nerd 폰트를 얻을 수 있다.
    $ fontforge -script font-patcher {폰트파일} [옵션]
    

    예를 들어 나는 아래와 같이 실행하여 D2Coding Nerd Font를 생성하였다.

    $ fontforge -script "$PWD/font-patcher" "$PWD/D2Coding-Regular.ttf" --complete --makegroups --xavgcharwidth --careful --outputdir "$PWD"
    

    결과로 D2KodingNerdFont-Regular.ttf 파일이 생성된다. (폰트 이름은 “D2Koding Nerd Font”)

이렇게 얻은 Nerd 폰트를 여러 프로그램에서 테스트해 보았는데, 모든 프로그램들에서 영문/한글/아이콘들이 모두 문제없이 정상적으로 표시되었지만, MobaXterm 프로그램에서만 Nerd 아이콘들이 반쪽만 표시되었다. 😫

이 문제를 해결하기 위하여 아래와 같이 --mono 옵션을 추가하여 Nerd Mono 폰트를 생성해 보았다.

$ fontforge -script "$PWD/font-patcher" "$PWD/D2Coding-Regular.ttf" --mono --complete --makegroups --xavgcharwidth --careful --outputdir "$PWD"

결과로 D2KodingNerdFontMono-Regular.ttf 파일이 생성된다. (폰트 이름은 “D2Koding Nerd Font Mono”)

그런데 Windows에서 글꼴을 설치할 때 Wrong letter space after patching Korean font 이슈와 마찬가지로 한글이 1칸을 차지하게 되어 글자가 겹쳐서 보였다.
실제로도 테스트해보니 MobaXterm에서만 정상적으로 한글과 Nerd 아이콘(1칸으로 표시) 표시되었고, 다른 프로그램들에서는 모두 한글이 1칸을 차지하게 되어 한글 글자가 겹쳐서 보였다. 😓

--mono 옵션을 주면 font-patcher가 모든 글리프의 폭을 1칸(500)으로 맞추기 때문이고, 한글도 2칸이 아닌 1칸으로 만들기 때문이다.

그냥 이 mono 폰트를 MobaXterm에서만 사용하면 되긴 하지만, 궁금하여 Claude Code에게 물어보았고, MobaXterm은 아이콘의 경우에 폰트에서 아이콘의 정보를 읽어서 렌더링하지 않고, 아이콘을 무조건 1칸으로 출력하기 때문에 아이콘이 반쪽만 보여진다는 것을 알았다.
이에 대한 대응책으로 Claude Code가 font-patcher 코드를 아래와 같이 수정할 것을 제안하였다. (즉, Mono 모드에서도 Unicode 폭 속성이 Wide나 Fullwidth이고 원래 폭이 2칸(1000)인 글리프는 1000으로 유지하도록 수정)

--- a/font-patcher
+++ b/font-patcher
@@ -122,6 +122,7 @@ class TableHEADWriter:

         for i in range(numtables):
             tab_name = self.f.read(4)
+            self.tab_name = tab_name
             self.tab_check_offset = self.f.tell()
             self.tab_check = self.getlong()
             self.tab_offset = self.getlong()
@@ -145,6 +146,7 @@ class TableHEADWriter:
                          'flags': 2+2+4+4+4,
                          'lowestRecPPEM': 2+2+4+4+4+2+2+8+8+2+2+2+2+2,
                          'avgWidth': 2,
+                         'isFixedPitch': 4+4+2+2,
                 }
             where = self.tab_offset + positions[where]
         self.f.seek(where)
@@ -160,7 +162,9 @@ class TableHEADWriter:
         return full_check

     def calc_table_checksum(self, check = False):
-        tab_check_new = self.calc_checksum(self.tab_offset, self.tab_offset + self.tab_length - 1, (-self.checksum_adj) & 0xFFFFFFFF)
+        # Only the 'head' table checksum is calculated with checksumAdjustment set to zero
+        extra = (-self.checksum_adj) & 0xFFFFFFFF if self.tab_name == b'head' else 0
+        tab_check_new = self.calc_checksum(self.tab_offset, self.tab_offset + self.tab_length - 1, extra)
         if check and tab_check_new != self.tab_check:
             sys.exit("Checksum of 'head' in font is bad")
         return tab_check_new
@@ -527,6 +531,12 @@ class font_patcher:
                             logger.debug("Changing xAvgCharWidth from %d to %d%s", d_xwidth, xwidth, xwidth_s)
                             dest_font.putshort(xwidth, 'avgWidth')
                             dest_font.reset_table_checksum()
+                    if self.args.single and dest_font.find_table([b'post'], idx):
+                        # Fontforge clears isFixedPitch if double width glyphs are kept
+                        if dest_font.getlong('isFixedPitch') == 0:
+                            logger.debug("Setting isFixedPitch")
+                            dest_font.putlong(1, 'isFixedPitch')
+                            dest_font.reset_table_checksum()
                     source_font.find_head_table(idx)
                     dest_font.find_head_table(idx)
                     if source_font.flags & 0x08 == 0 and dest_font.flags & 0x08 != 0:
@@ -1872,12 +1882,31 @@ class font_patcher:
         mono_width = self.font_dim['width']
         recentered = []

+        # Keep WIDE asian glyphs (e.g. Hangul) in their double size cell, terminals render them in two cells anyhow.
+        # Also keep the double size glyphs they reference, as composites might take their metrics from them (USE_MY_METRICS)
+        keep_wide = set()
+        if self.source_monospaced:
+            todo = [ g.glyphname for g in self.sourceFont.glyphs()
+                     if g.width == 2 * mono_width and g.unicode > 0
+                        and unicodedata.east_asian_width(chr(g.unicode)) in 'WF' ]
+            while todo:
+                gname = todo.pop()
+                if gname in keep_wide or self.sourceFont[gname].width != 2 * mono_width:
+                    continue
+                keep_wide.add(gname)
+                todo += [ ref[0] for ref in self.sourceFont[gname].references ]
+            logger.info("Keeping %d double width glyphs", len(keep_wide))
+
         for glyph in self.sourceFont.glyphs():
             if glyph.width == mono_width:
                 # Don't touch the (negative) bearings if the width is ok
                 # Ligatures will have these.
                 continue

+            if glyph.glyphname in keep_wide:
+                continue
+
             if (glyph.width == 2 * mono_width
                 and self.source_monospaced
                 and glyph.unicode > 0


위 코드를 적용한 후에 아래와 같이 --mono 옵션으로 Mono Nerd Font를 얻었다.

$ fontforge -script "$PWD/font-patcher" "$PWD/D2Coding-Regular.ttf" --mono --complete --makegroups --xavgcharwidth --careful --outputdir "$PWD"

마찬가지로 결과로 D2KodingNerdFontMono-Regular.ttf 파일이 생성된다. (폰트 이름은 “D2Koding Nerd Font Mono”)

이렇게 얻은 폰트는 Windows 글꼴 설치 및 여러 일반적인 프로그램에서도 한글과 아이콘이 모두 정상적으로 보였고, MobaXterm에서도 한글과 아이콘이 (단, 아이콘은 1글자 폭으로 표시되므로 작게 표시됨) 정상적으로 보였다. 🙂

블로그에도 적용

이 블로그에도 D2KodingNerdFont 폰트를 적용하기 위하여 아래와 같이 수정하였다.

  • assets/css/ 경로에 D2KodingNerdFont-Regular.ttf 파일을 복사하였다.
  • assets/css/main.scss 파일에서 아래와 같이 수정하였다.
    @font-face {
      font-family: 'D2Koding Nerd Font'; src:url(D2KodingNerdFont-Regular.ttf);
    }
    
  • _sass/minimal-mistakes/_variables.scss 파일에서 아래와 같이 수정하였다.
    $monospace: 'D2Koding Nerd Font', 'D2CodingLigature Nerd Font', D2Coding, "D2 coding", Monaco, Consolas, "Lucida Console", monospace !default;
    

결과로 아래 예와 같이 Nerd 아이콘들이 정상적으로 표시된다. (참고로 Nerd Font 페이지에 있는 기존 D2Coding 1.3.2 버전에서는 제대로 표시되지 않던 YAML 아이콘도 정상적으로 표시된다)

$ eza -f --icons
 _config.yml           banner.js    env.json     LICENSE   Makefile       start.sh        stylua.toml
󰗀 AndroidManifest.xml   Dockerfile   index.html   main.c    package.json   staticman.yml   Usage.md

폰트 다운로드

내가 만든 D2Coding Nerd 버전 1.4.0 폰트는 아래 링크로 다운받을 수 있다.

일반적인 프로그램에서는 “D2Koding Nerd Font”를 사용하면 되고, MobaXterm과 같이 아이콘을 1칸으로 표시하는 프로그램에서는 “D2Koding Nerd Font Mono”를 사용하면 된다. (만약에 일반적인 프로그램에서 “D2Koding Nerd Font Mono”를 사용하면 Nerd 아이콘이 1칸으로 (즉, 작게) 표시된다)

맺음말

AI 덕분에 폰트 스펙에 대해서 잘 알지도 못하는데도 원하는 결과물을 쉽게 얻을 수 있었고, 내가 직접 만든 폰트를 아주 잘 사용하고 있다.

카테고리:

업데이트: