Adding nerd fonts preset
parent
d87dfa9ee2
commit
7eeb30a086
|
@ -90,3 +90,5 @@ OFL 라이선스의 폰트가 패치에 사용된 경우, 그 폰트가 웹폰
|
||||||
~~일해라 쿼리~~
|
~~일해라 쿼리~~
|
||||||
|
|
||||||
ps1 스크립트로 윈도우 설치 자동화와, 윈도우 호환성을 만듭니다(가능한가 의문)
|
ps1 스크립트로 윈도우 설치 자동화와, 윈도우 호환성을 만듭니다(가능한가 의문)
|
||||||
|
|
||||||
|
^ And how
|
||||||
|
|
|
@ -10,9 +10,9 @@ def getCachedFont(sourcePath,baseSize=550,weight=16):
|
||||||
# 캐시된 파일을 확인하고 있으면 반환
|
# 캐시된 파일을 확인하고 있으면 반환
|
||||||
filename = "assets/cache/NanumSquareNeoKr.cache_{}.base_{}.weight_{}.sfd".format(patchVersion,baseSize,weight)
|
filename = "assets/cache/NanumSquareNeoKr.cache_{}.base_{}.weight_{}.sfd".format(patchVersion,baseSize,weight)
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
print("Found build cache [OK]")
|
print(" Found build cache [CACHE HIT]")
|
||||||
return fontforge.open(filename)
|
return fontforge.open(filename)
|
||||||
print("Creating new build cache",end="")
|
print(" Creating new build cache",end="",flush=True)
|
||||||
|
|
||||||
# 새로운 캐시용 폰트 생성
|
# 새로운 캐시용 폰트 생성
|
||||||
cache=fontforge.font()
|
cache=fontforge.font()
|
||||||
|
|
|
@ -17,6 +17,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,baseSize=550,weightStr=
|
||||||
weight = weightStrToNum.get(weightStr)
|
weight = weightStrToNum.get(weightStr)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(" Copying . . .",end="",flush=True)
|
||||||
selectGlyphs.Clear(source)
|
selectGlyphs.Clear(source)
|
||||||
selectGlyphs.Clear(target)
|
selectGlyphs.Clear(target)
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,baseSize=550,weightStr=
|
||||||
selectGlyphs.Korean(target)
|
selectGlyphs.Korean(target)
|
||||||
deselectOriginalGlyphs(target)
|
deselectOriginalGlyphs(target)
|
||||||
target.paste()
|
target.paste()
|
||||||
|
print(" [OK]")
|
||||||
|
|
||||||
# 캐시 닫기
|
# 캐시 닫기
|
||||||
source.close()
|
source.close()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
from .download import downloadPatcher
|
from .download import downloadPatcher
|
||||||
from .download import isCached
|
from .download import isCached
|
||||||
from .download import nerdFonts_Download_Test
|
from .download import nerdFonts_Download_Test
|
||||||
|
from .nerdfonts import build
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
def callPatcher(font):
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
NerdFontPatcher = sys.modules["NerdFontPatcher"]
|
||||||
|
if not NerdFontPatcher:
|
||||||
|
import importlib.util
|
||||||
|
spec = importlib.util.spec_from_file_location("NerdFontPatcher", "assets/NerdFontPatcher_extract/fontPatcher.py")
|
||||||
|
NerdFontPatcher = importlib.util.module_from_spec(spec)
|
||||||
|
sys.modules["NerdFontPatcher"] = NerdFontPatcher
|
||||||
|
spec.loader.exec_module(NerdFontPatcher)
|
||||||
|
|
||||||
|
# NerdFontPatcher.patch(font)
|
||||||
|
args = argparse.Namespace()
|
||||||
|
|
||||||
|
# complete all options
|
||||||
|
args.complete = True
|
||||||
|
args.fontawesome = True
|
||||||
|
args.fontawesomeextension = True
|
||||||
|
args.fontlogos = True
|
||||||
|
args.octicons = True
|
||||||
|
args.codicons = True
|
||||||
|
args.powersymbols = True
|
||||||
|
args.pomicons = True
|
||||||
|
args.powerline = True
|
||||||
|
args.powerlineextra = True
|
||||||
|
args.material = True
|
||||||
|
args.weather = True
|
||||||
|
|
||||||
|
args.windows = True
|
||||||
|
args.alsowindows = False
|
||||||
|
args.nonmono = False
|
||||||
|
args.progressbars = True
|
||||||
|
args.quiet = False
|
||||||
|
args.adjustLineHeight = True
|
||||||
|
# args.careful = True
|
||||||
|
args.careful = False
|
||||||
|
args.single = False
|
||||||
|
args.removeligatures = False
|
||||||
|
args.postprocess = False
|
||||||
|
args.configfile = False
|
||||||
|
args.custom = False
|
||||||
|
args.glyphdir = "assets/NerdFontPatcher_extract/src/glyphs/"
|
||||||
|
|
||||||
|
patcher = NerdFontPatcher.font_patcher(args)
|
||||||
|
patcher.patch(font)
|
||||||
|
|
||||||
|
selFlag = ("more","ranges","unicode")
|
||||||
|
|
||||||
|
def postScript(font,deselectOriginalGlyphs,baseSize):
|
||||||
|
font.selection.none()
|
||||||
|
font.selection.select()
|
||||||
|
deselectOriginalGlyphs()
|
||||||
|
|
||||||
|
def build(target,deselectOriginalGlyphs,NerdFontsAdjust=True,baseSize=550,weightStr="Regular"):
|
||||||
|
# 용량적 이유로 Regular 폰트에만 패치를 적용함
|
||||||
|
if weightStr != "Regular": return
|
||||||
|
|
||||||
|
print("Patching: NerdFonts")
|
||||||
|
|
||||||
|
# NerdFonts 공식 패처를 수행함
|
||||||
|
callPatcher(target)
|
||||||
|
|
||||||
|
# 적절한 크기를 위해서 크기조절을 수행함
|
||||||
|
# if NerdFontsAdjust:
|
||||||
|
# postScript(target,deselectOriginalGlyphs,baseSize)
|
|
@ -16,9 +16,9 @@ def getCachedFont(sourcePath,EnabledItems,baseSize=550,weight=16):
|
||||||
EnabledItems.get("CopyCJKCompatibilityIdeographs") and ".cid" or "",
|
EnabledItems.get("CopyCJKCompatibilityIdeographs") and ".cid" or "",
|
||||||
EnabledItems.get("Symbols") and ".sym" or "")
|
EnabledItems.get("Symbols") and ".sym" or "")
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
print("Found build cache [OK]")
|
print(" Found build cache [CACHE HIT]")
|
||||||
return fontforge.open(filename)
|
return fontforge.open(filename)
|
||||||
print("Creating new build cache",end="")
|
print(" Creating new build cache",end="",flush=True)
|
||||||
|
|
||||||
# 새로운 캐시용 폰트 생성
|
# 새로운 캐시용 폰트 생성
|
||||||
cache=fontforge.font()
|
cache=fontforge.font()
|
||||||
|
@ -29,18 +29,16 @@ def getCachedFont(sourcePath,EnabledItems,baseSize=550,weight=16):
|
||||||
source.cidFlatten()
|
source.cidFlatten()
|
||||||
source.encoding = 'UnicodeFull'
|
source.encoding = 'UnicodeFull'
|
||||||
if EnabledItems.get("JapaneseGlyphs"): selectGlyphs.JapaneseGlyphs(source)
|
if EnabledItems.get("JapaneseGlyphs"): selectGlyphs.JapaneseGlyphs(source)
|
||||||
if EnabledItems.get("Symbols"): selectGlyphs.Symbols(source)
|
|
||||||
source.changeWeight(weight) # 굵기 변경
|
source.changeWeight(weight) # 굵기 변경
|
||||||
selectGlyphs.SelectByEnabledList(source,EnabledItems)
|
selectGlyphs.SelectByEnabledList(source,EnabledItems)
|
||||||
# 한자 글립은 냥많아서 크기조절하면 끝이 안난다냥
|
# 한자 글립은 냥많아서 크기조절하면 끝이 안난다냥
|
||||||
|
|
||||||
# 너비 지정
|
# 너비 지정
|
||||||
|
Utility.scale(font=source,targetScale=0.85)
|
||||||
Utility.setWidthWithSavingPosition(
|
Utility.setWidthWithSavingPosition(
|
||||||
font=source,targetWidth=baseSize*2
|
font=source,targetWidth=baseSize*2
|
||||||
)
|
)
|
||||||
|
|
||||||
Utility.scale(font=source,targetScale=0.85)
|
|
||||||
|
|
||||||
# 캐시에 붇여넣기
|
# 캐시에 붇여넣기
|
||||||
source.copy()
|
source.copy()
|
||||||
selectGlyphs.SelectByEnabledList(cache,EnabledItems)
|
selectGlyphs.SelectByEnabledList(cache,EnabledItems)
|
||||||
|
|
|
@ -8,6 +8,7 @@ weightStrToNum = {
|
||||||
|
|
||||||
def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=550,weightStr="Regular"):
|
def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=550,weightStr="Regular"):
|
||||||
# 캐시된 소스를 읽어드림
|
# 캐시된 소스를 읽어드림
|
||||||
|
print("Patching: NotoMono")
|
||||||
source = getCachedFont(
|
source = getCachedFont(
|
||||||
sourcePath = sourcePath,
|
sourcePath = sourcePath,
|
||||||
baseSize = baseSize,
|
baseSize = baseSize,
|
||||||
|
@ -15,6 +16,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=5
|
||||||
EnabledItems = EnabledItems
|
EnabledItems = EnabledItems
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(" Copying . . .",end="",flush=True)
|
||||||
selectGlyphs.Clear(source)
|
selectGlyphs.Clear(source)
|
||||||
selectGlyphs.Clear(target)
|
selectGlyphs.Clear(target)
|
||||||
|
|
||||||
|
@ -25,6 +27,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=5
|
||||||
selectGlyphs.SelectByEnabledList(target,EnabledItems)
|
selectGlyphs.SelectByEnabledList(target,EnabledItems)
|
||||||
deselectOriginalGlyphs(target)
|
deselectOriginalGlyphs(target)
|
||||||
target.paste()
|
target.paste()
|
||||||
|
print(" [OK]")
|
||||||
|
|
||||||
# 캐시 닫기
|
# 캐시 닫기
|
||||||
source.close()
|
source.close()
|
||||||
|
|
|
@ -52,14 +52,21 @@ def Symbols(font):
|
||||||
font.selection.select(selFlag,0x3358,0x337A)
|
font.selection.select(selFlag,0x3358,0x337A)
|
||||||
font.selection.select(selFlag,0x3380,0x33FF)
|
font.selection.select(selFlag,0x3380,0x33FF)
|
||||||
|
|
||||||
|
# 로마 숫자
|
||||||
|
# font.selection.select(selFlag,0x2160,0x217B)
|
||||||
|
font.selection.select(selFlag,0x2150,0x218F) # Number Forms
|
||||||
|
|
||||||
# Latin Ligature
|
# Latin Ligature
|
||||||
font.selection.select(selFlag,0xFB00,0xFB04)
|
font.selection.select(selFlag,0xFB00,0xFB4F) # Alphabetic Presentation Forms
|
||||||
|
|
||||||
# 특수기호/FULLWIDTH Latin
|
# 특수기호/FULLWIDTH Latin
|
||||||
font.selection.select(selFlag,0xFE10,0xFF5A)
|
font.selection.select(selFlag,0x2600,0x26FF) # Miscellaneous Symbols
|
||||||
font.selection.select(selFlag,0xFFE0,0xFFEE)
|
font.selection.select(selFlag,0x2700,0x27BF) # Dingbats
|
||||||
font.selection.select(selFlag,0x1F100,0x1F1AC)
|
font.selection.select(selFlag,0xFE10,0xFE1F) # Vertical Forms
|
||||||
font.selection.select(selFlag,0x1F201,0x1F251)
|
# font.selection.select(selFlag,0xFFE0,0xFFEE) # (Without kr) Halfwidth and Fullwidth Forms
|
||||||
|
font.selection.select(selFlag,0xFF00,0xFFEF) # Halfwidth and Fullwidth Forms
|
||||||
|
font.selection.select(selFlag,0x1F100,0x1F1FF) # Enclosed Alphanumeric Supplement
|
||||||
|
font.selection.select(selFlag,0x1F200,0x1F2FF) # Enclosed Ideographic Supplement
|
||||||
|
|
||||||
def SelectByEnabledList(target,EnabledItems):
|
def SelectByEnabledList(target,EnabledItems):
|
||||||
if EnabledItems.get("JapaneseGlyphs"): JapaneseGlyphs(target)
|
if EnabledItems.get("JapaneseGlyphs"): JapaneseGlyphs(target)
|
||||||
|
|
|
@ -46,6 +46,9 @@ def build(config=None):
|
||||||
for unicode in keepList:
|
for unicode in keepList:
|
||||||
if unicode == -1: continue
|
if unicode == -1: continue
|
||||||
target.selection.select(deselectFlags,unicode)
|
target.selection.select(deselectFlags,unicode)
|
||||||
|
def updateOriginalGlyphs():
|
||||||
|
nonlocal keepList
|
||||||
|
keepList = [i.unicode for i in kawaii.selection.byGlyphs]
|
||||||
|
|
||||||
# 모든 글리프를 붇여넣을 수 있도록 인코딩을 utf full 로 변경
|
# 모든 글리프를 붇여넣을 수 있도록 인코딩을 utf full 로 변경
|
||||||
kawaii.encoding = 'UnicodeFull'
|
kawaii.encoding = 'UnicodeFull'
|
||||||
|
@ -64,6 +67,7 @@ def build(config=None):
|
||||||
target=kawaii,baseSize=baseSize,weightStr="Regular",
|
target=kawaii,baseSize=baseSize,weightStr="Regular",
|
||||||
sourcePath=nanumSquareNeo,
|
sourcePath=nanumSquareNeo,
|
||||||
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
||||||
|
updateOriginalGlyphs()
|
||||||
|
|
||||||
# 일어 글리프 혹은 한자 글리프 추가
|
# 일어 글리프 혹은 한자 글리프 추가
|
||||||
if notoMono:
|
if notoMono:
|
||||||
|
@ -76,13 +80,19 @@ def build(config=None):
|
||||||
"CJKCompatibilityIdeographs": config.get("CopyCJKCompatibilityIdeographs") or False,
|
"CJKCompatibilityIdeographs": config.get("CopyCJKCompatibilityIdeographs") or False,
|
||||||
"Symbols": config.get("CopySymbols") or False,
|
"Symbols": config.get("CopySymbols") or False,
|
||||||
},
|
},
|
||||||
target=kawaii,baseSize=550,
|
target=kawaii,baseSize=baseSize,
|
||||||
sourcePath=notoMono,
|
sourcePath=notoMono,
|
||||||
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
||||||
|
updateOriginalGlyphs()
|
||||||
|
|
||||||
# NerdFonts 패치 적용
|
# NerdFonts 패치 적용
|
||||||
# if config.get("NerdFonts"):
|
if config.get("NerdFonts"):
|
||||||
# nerdFontsPatcherPath = NerdFontsLoader.downloadPatcher()
|
NerdFontsLoader.build(
|
||||||
|
target=kawaii,
|
||||||
|
NerdFontsAdjust=config.get("NerdFontsAdjust") or False,
|
||||||
|
baseSize=baseSize,
|
||||||
|
weightStr="Regular",
|
||||||
|
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
||||||
|
|
||||||
# 생성
|
# 생성
|
||||||
if not os.path.exists("out"): os.mkdir("out")
|
if not os.path.exists("out"): os.mkdir("out")
|
||||||
|
|
Loading…
Reference in New Issue