init comomit
							parent
							
								
									992fe96f32
								
							
						
					
					
						commit
						28d1ac3e9f
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
from src.build import build
 | 
			
		||||
import config
 | 
			
		||||
if __name__ == "__main__": build(config.config)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,81 @@
 | 
			
		|||
 | 
			
		||||
# TODO: 블록 글자 추가
 | 
			
		||||
# TODO: 기울임꼴(ah 같은 특수 기울임도) 추가
 | 
			
		||||
 | 
			
		||||
config = {
 | 
			
		||||
    # -------------------------------------------
 | 
			
		||||
    #               Base Settings
 | 
			
		||||
    # -------------------------------------------
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # 출력 파일의 이름을 지정합니다.
 | 
			
		||||
    # Array 형태로 여러 이름을 추가할 수 있습니다
 | 
			
		||||
    # 필요한 경우 otf 와 같은 다른 확장자를
 | 
			
		||||
    # 사용할 수도 있습니다
 | 
			
		||||
    "OutputNames": {
 | 
			
		||||
        "Bold": ["KawaiiPatched.ttf"],
 | 
			
		||||
        "Regular": [""],
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # 일반적인 글자 (예: a) 의 너비입니다.
 | 
			
		||||
    # 작은 화면에 더많은 정보를 담아내려면
 | 
			
		||||
    # 이 값을 줄이세요. 단 스캐일이 조정되지
 | 
			
		||||
    # 않습니다
 | 
			
		||||
    "FontBaseWidth": 550,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # 폰트의 X 축 스캐일 조정입니다.
 | 
			
		||||
    # 폰트의 width 를 줄이거나 늘렸을 때
 | 
			
		||||
    # 이 값을 변경하여 가로로 늘리거나
 | 
			
		||||
    # 작게 줄일 수 있습니다
 | 
			
		||||
    "FontScaleX": 1,
 | 
			
		||||
 | 
			
		||||
    # -------------------------------------------
 | 
			
		||||
    #            Glyphs and Features
 | 
			
		||||
    # -------------------------------------------
 | 
			
		||||
 | 
			
		||||
    # 한글 글리프를 나눔 스퀘어 네오 폰트에서
 | 
			
		||||
    # 복사할 지에 대한 여부입니다
 | 
			
		||||
    # 폰트 용량이 매우 커집니다!!
 | 
			
		||||
    "CopyKoreanGlyphs": True,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # 노토 산스 모노에서 가타카나/히라가나
 | 
			
		||||
    # 글리프를 복사할 지에 대한 여부입니다
 | 
			
		||||
    # 한자는 포함하지 않습니다
 | 
			
		||||
    "CopyJapaneseGlyphs": True,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # 노토 산스 모노에서 CJK 공용 한자 글리프를
 | 
			
		||||
    # 복사할 지에 대한 여부입니다.
 | 
			
		||||
    # 폰트 용량이 매우 커집니다!!
 | 
			
		||||
    # 웹용 폰트의 경우 끄는것을 추천합니다
 | 
			
		||||
    "CopyCJKUnifiedIdeographs": True,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # 라틴 글리프를 Hack 폰트에서 더 가져옵니다
 | 
			
		||||
    # (성조 표시된 라틴, ...)
 | 
			
		||||
    "CopyLatinExtra": True,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # Nerd Fonts 패치를 적용할지에 대한
 | 
			
		||||
    # 여부입니다. 폰트 용량이 매우 커집니다!!
 | 
			
		||||
    # 웹용 폰트의 경우 끄는것을 추천합니다
 | 
			
		||||
    "NerdFonts": True,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # Nerd Fonts 패치에 발견되는 크기 이슈를
 | 
			
		||||
    # 해결하기 위해 크기조절이 이루워집니다
 | 
			
		||||
    # Nerd Fonts 패치를 활성화 한 경우에만
 | 
			
		||||
    # 이 값이 사용됩니다.
 | 
			
		||||
    "NerdFontsAdjust": True,
 | 
			
		||||
 | 
			
		||||
    # TODO: 이 설정은 아직 동작하지 않습니다
 | 
			
		||||
    # Liga (합자) 를 추가할 지에 대한 여부입니다
 | 
			
		||||
    # 활성화시 <!-- 와 같은 문자를 합쳐줍니다
 | 
			
		||||
    # Vscode 의 경우 설정에
 | 
			
		||||
    # "editor.fontLigatures": true,
 | 
			
		||||
    # 가 되어있어야 표시됩니다.
 | 
			
		||||
    "Liga": True,
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
#!/usr/bin/bash
 | 
			
		||||
python3 build.py
 | 
			
		||||
cp kawaiiPatched.ttf ~/.local/share/fonts/KawaiiMonoRegular.ttf
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
wget
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
def getFontPath():
 | 
			
		||||
    return "KawaiiMonoRegular.sfd"
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
from . import wgetHandler
 | 
			
		||||
import os
 | 
			
		||||
import zipfile
 | 
			
		||||
import shutil
 | 
			
		||||
import math
 | 
			
		||||
 | 
			
		||||
link_NanumSquareNeo = "https://campaign.naver.com/nanumsquare_neo/download/NaverNanumSquareNeo.zip"
 | 
			
		||||
 | 
			
		||||
# 폰트 다운로드와 열기
 | 
			
		||||
# 배포 방식이 zip 으로 배포이기 때문에 zipfile 라이브러리로
 | 
			
		||||
# 다운로드 후 언팩함
 | 
			
		||||
def getFontPath():
 | 
			
		||||
    if not os.path.exists("assets"): os.mkdir("assets")
 | 
			
		||||
    if not os.path.exists("assets/NanumSquareNeoKr.ttf"):
 | 
			
		||||
        if not os.path.exists("assets/NanumSquareNeoKr.zip"):
 | 
			
		||||
            wgetHandler.download(link_NanumSquareNeo,"assets/NanumSquareNeoKr.zip")
 | 
			
		||||
        print("Unzipping NanumSquareNeoKr.zip",end="")
 | 
			
		||||
        with zipfile.ZipFile("assets/NanumSquareNeoKr.zip", 'r') as zip_ref:
 | 
			
		||||
            extractName = zip_ref.extract("NaverNanumSquareNeo/TTF/NanumSquareNeo-cBd.ttf","assets/NanumSquareNeoKr.extract")
 | 
			
		||||
            os.rename(extractName,"assets/NanumSquareNeoKr.ttf")
 | 
			
		||||
            shutil.rmtree('assets/NanumSquareNeoKr.extract')
 | 
			
		||||
        print(" [OK]")
 | 
			
		||||
    return "assets/NanumSquareNeoKr.ttf"
 | 
			
		||||
 | 
			
		||||
def pasteGlyphs(target,source,baseSize=550):
 | 
			
		||||
    def select(font):
 | 
			
		||||
        font.selection.none()
 | 
			
		||||
        font.selection.select(("more","ranges","unicode"),0x3131,0x32BF) # ㄱ ~ ㊿
 | 
			
		||||
        font.selection.select(("more","ranges","unicode"),0xAC00,0xD7A3) # 가 ~ 힣
 | 
			
		||||
    select(source)
 | 
			
		||||
 | 
			
		||||
    # 넓은 글자 크기 (한글에 모두 적용)
 | 
			
		||||
    wideWidth = baseSize*2
 | 
			
		||||
    for glyph in source.selection.byGlyphs:
 | 
			
		||||
        widthDiff = wideWidth-glyph.width # 타겟 너비와 얼마나 크기 차이가 나는지
 | 
			
		||||
        sideAdjust = widthDiff/2 # 좌우 사이드 조정해야하는 정도
 | 
			
		||||
        glyph.left_side_bearing = int(glyph.left_side_bearing + math.floor(sideAdjust)) # 좌우 베어링을 조정함
 | 
			
		||||
        glyph.right_side_bearing = int(glyph.right_side_bearing + math.ceil(sideAdjust))
 | 
			
		||||
        glyph.width = wideWidth # 타겟 너비로 정확하게 설정
 | 
			
		||||
 | 
			
		||||
    # 타겟으로 글리프 복사
 | 
			
		||||
    source.copy()
 | 
			
		||||
    select(target)
 | 
			
		||||
    target.paste()
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    getFontPath()
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,38 @@
 | 
			
		|||
from . import wgetHandler
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
github_NotoSansMonoCJKkr = "https://github.com/googlefonts/noto-cjk/raw/main/Sans/Mono/NotoSansMonoCJKkr-Regular.otf"
 | 
			
		||||
 | 
			
		||||
# 폰트 다운로드와 열기
 | 
			
		||||
def getFontPath():
 | 
			
		||||
    if not os.path.exists("assets"): os.mkdir("assets")
 | 
			
		||||
    if not os.path.exists("assets/NotoMonoCJKkr.otf"):
 | 
			
		||||
        wgetHandler.download(github_NotoSansMonoCJKkr,"assets/NotoMonoCJKkr.otf")
 | 
			
		||||
    return "assets/NotoMonoCJKkr.otf"
 | 
			
		||||
 | 
			
		||||
def pasteGlyphs(target,source,baseSize=550):
 | 
			
		||||
    source.cidFlatten()
 | 
			
		||||
 | 
			
		||||
    def select(font):
 | 
			
		||||
        font.selection.none()
 | 
			
		||||
        font.selection.select(("more","ranges","unicode"),0x3131,0x32BF) # ㄱ ~ ㊿
 | 
			
		||||
        font.selection.select(("more","ranges","unicode"),0xAC00,0xD7A3) # 가 ~ 힣
 | 
			
		||||
    select(source)
 | 
			
		||||
 | 
			
		||||
    # 넓은 글자 크기 (한글에 모두 적용)
 | 
			
		||||
    wideWidth = baseSize*2
 | 
			
		||||
    for glyph in source.selection.byGlyphs:
 | 
			
		||||
        widthDiff = wideWidth-glyph.width # 타겟 너비와 얼마나 크기 차이가 나는지
 | 
			
		||||
        sideAdjust = widthDiff/2 # 좌우 사이드 조정해야하는 정도
 | 
			
		||||
        glyph.left_side_bearing = int(glyph.left_side_bearing + math.floor(sideAdjust)) # 좌우 베어링을 조정함
 | 
			
		||||
        glyph.right_side_bearing = int(glyph.right_side_bearing + math.ceil(sideAdjust))
 | 
			
		||||
        glyph.width = wideWidth # 타겟 너비로 정확하게 설정
 | 
			
		||||
 | 
			
		||||
    # 타겟으로 글리프 복사
 | 
			
		||||
    source.copy()
 | 
			
		||||
    select(target)
 | 
			
		||||
    target.paste()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    getFontPath()
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
import fontforge
 | 
			
		||||
 | 
			
		||||
from . import NanumSquareNeo as NanumSquareNeoLoader
 | 
			
		||||
from . import NotoMono as NotoMonoLoader
 | 
			
		||||
from . import KawaiiMono as KawaiiMonoLoader
 | 
			
		||||
 | 
			
		||||
def build(config=None):
 | 
			
		||||
    # 메인 폰트 불러오기
 | 
			
		||||
    kawaii = fontforge.open(
 | 
			
		||||
        KawaiiMonoLoader.getFontPath())
 | 
			
		||||
 | 
			
		||||
    # 모든 글리프를 붇여넣을 수 있도록 인코딩을 utf full 로 변경
 | 
			
		||||
    kawaii.encoding = 'UnicodeFull'
 | 
			
		||||
 | 
			
		||||
    # 한글 글리프 붇여넣기
 | 
			
		||||
    if config.CopyKoreanGlyphs:
 | 
			
		||||
        # 나눔 스퀘어 네오 다운로드/불러오기
 | 
			
		||||
        nanumSquareNeo = fontforge.open(
 | 
			
		||||
            NanumSquareNeoLoader.getFontPath())
 | 
			
		||||
        # 글리프 붇여넣기
 | 
			
		||||
        NanumSquareNeoLoader.pasteGlyphs(
 | 
			
		||||
            target=kawaii,baseSize=550,
 | 
			
		||||
            source=nanumSquareNeo)
 | 
			
		||||
 | 
			
		||||
    if config.CopyJPGlyphs or config.Copy:
 | 
			
		||||
        # 노토 모노 다운로드/불러오기
 | 
			
		||||
        notoMono = fontforge.open(
 | 
			
		||||
            NotoMonoLoader.getFontPath())
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
    # 생성
 | 
			
		||||
    kawaii.generate("kawaiiPatched.ttf")
 | 
			
		||||
 | 
			
		||||
    # 파일 닫기
 | 
			
		||||
    notoMono.close()
 | 
			
		||||
    nanumSquareNeo.close()
 | 
			
		||||
    kawaii.close()
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__": build()
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
import wget
 | 
			
		||||
import math
 | 
			
		||||
 | 
			
		||||
def bar_custom(current, total, width=80):
 | 
			
		||||
    width=30
 | 
			
		||||
    avail_dots = width-2
 | 
			
		||||
    shaded_dots = int(math.floor(float(current) / total * avail_dots))
 | 
			
		||||
    percent_bar = '[' + '■'*shaded_dots + ' '*(avail_dots-shaded_dots) + ']'
 | 
			
		||||
    progress = "%d%% %s [%d / %d]" % (current / total * 100, percent_bar, current, total)
 | 
			
		||||
    return progress
 | 
			
		||||
 | 
			
		||||
def download(url, fileName):
 | 
			
		||||
    print("Downloading resource to "+fileName+" ...")
 | 
			
		||||
    wget.download(url, fileName, bar=bar_custom)
 | 
			
		||||
    print(" [OK]")
 | 
			
		||||
		Loading…
	
		Reference in New Issue