Adding nerd fonts preset
parent
d87dfa9ee2
commit
7eeb30a086
|
@ -90,3 +90,5 @@ OFL 라이선스의 폰트가 패치에 사용된 경우, 그 폰트가 웹폰
|
|||
~~일해라 쿼리~~
|
||||
|
||||
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)
|
||||
if os.path.exists(filename):
|
||||
print("Found build cache [OK]")
|
||||
print(" Found build cache [CACHE HIT]")
|
||||
return fontforge.open(filename)
|
||||
print("Creating new build cache",end="")
|
||||
print(" Creating new build cache",end="",flush=True)
|
||||
|
||||
# 새로운 캐시용 폰트 생성
|
||||
cache=fontforge.font()
|
||||
|
|
|
@ -17,6 +17,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,baseSize=550,weightStr=
|
|||
weight = weightStrToNum.get(weightStr)
|
||||
)
|
||||
|
||||
print(" Copying . . .",end="",flush=True)
|
||||
selectGlyphs.Clear(source)
|
||||
selectGlyphs.Clear(target)
|
||||
|
||||
|
@ -27,6 +28,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,baseSize=550,weightStr=
|
|||
selectGlyphs.Korean(target)
|
||||
deselectOriginalGlyphs(target)
|
||||
target.paste()
|
||||
print(" [OK]")
|
||||
|
||||
# 캐시 닫기
|
||||
source.close()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
from .download import downloadPatcher
|
||||
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("Symbols") and ".sym" or "")
|
||||
if os.path.exists(filename):
|
||||
print("Found build cache [OK]")
|
||||
print(" Found build cache [CACHE HIT]")
|
||||
return fontforge.open(filename)
|
||||
print("Creating new build cache",end="")
|
||||
print(" Creating new build cache",end="",flush=True)
|
||||
|
||||
# 새로운 캐시용 폰트 생성
|
||||
cache=fontforge.font()
|
||||
|
@ -29,18 +29,16 @@ def getCachedFont(sourcePath,EnabledItems,baseSize=550,weight=16):
|
|||
source.cidFlatten()
|
||||
source.encoding = 'UnicodeFull'
|
||||
if EnabledItems.get("JapaneseGlyphs"): selectGlyphs.JapaneseGlyphs(source)
|
||||
if EnabledItems.get("Symbols"): selectGlyphs.Symbols(source)
|
||||
source.changeWeight(weight) # 굵기 변경
|
||||
selectGlyphs.SelectByEnabledList(source,EnabledItems)
|
||||
# 한자 글립은 냥많아서 크기조절하면 끝이 안난다냥
|
||||
|
||||
# 너비 지정
|
||||
Utility.scale(font=source,targetScale=0.85)
|
||||
Utility.setWidthWithSavingPosition(
|
||||
font=source,targetWidth=baseSize*2
|
||||
)
|
||||
|
||||
Utility.scale(font=source,targetScale=0.85)
|
||||
|
||||
# 캐시에 붇여넣기
|
||||
source.copy()
|
||||
selectGlyphs.SelectByEnabledList(cache,EnabledItems)
|
||||
|
|
|
@ -8,6 +8,7 @@ weightStrToNum = {
|
|||
|
||||
def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=550,weightStr="Regular"):
|
||||
# 캐시된 소스를 읽어드림
|
||||
print("Patching: NotoMono")
|
||||
source = getCachedFont(
|
||||
sourcePath = sourcePath,
|
||||
baseSize = baseSize,
|
||||
|
@ -15,6 +16,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=5
|
|||
EnabledItems = EnabledItems
|
||||
)
|
||||
|
||||
print(" Copying . . .",end="",flush=True)
|
||||
selectGlyphs.Clear(source)
|
||||
selectGlyphs.Clear(target)
|
||||
|
||||
|
@ -25,6 +27,7 @@ def pasteGlyphs(target,sourcePath,deselectOriginalGlyphs,EnabledItems,baseSize=5
|
|||
selectGlyphs.SelectByEnabledList(target,EnabledItems)
|
||||
deselectOriginalGlyphs(target)
|
||||
target.paste()
|
||||
print(" [OK]")
|
||||
|
||||
# 캐시 닫기
|
||||
source.close()
|
||||
|
|
|
@ -52,14 +52,21 @@ def Symbols(font):
|
|||
font.selection.select(selFlag,0x3358,0x337A)
|
||||
font.selection.select(selFlag,0x3380,0x33FF)
|
||||
|
||||
# 로마 숫자
|
||||
# font.selection.select(selFlag,0x2160,0x217B)
|
||||
font.selection.select(selFlag,0x2150,0x218F) # Number Forms
|
||||
|
||||
# Latin Ligature
|
||||
font.selection.select(selFlag,0xFB00,0xFB04)
|
||||
font.selection.select(selFlag,0xFB00,0xFB4F) # Alphabetic Presentation Forms
|
||||
|
||||
# 특수기호/FULLWIDTH Latin
|
||||
font.selection.select(selFlag,0xFE10,0xFF5A)
|
||||
font.selection.select(selFlag,0xFFE0,0xFFEE)
|
||||
font.selection.select(selFlag,0x1F100,0x1F1AC)
|
||||
font.selection.select(selFlag,0x1F201,0x1F251)
|
||||
font.selection.select(selFlag,0x2600,0x26FF) # Miscellaneous Symbols
|
||||
font.selection.select(selFlag,0x2700,0x27BF) # Dingbats
|
||||
font.selection.select(selFlag,0xFE10,0xFE1F) # Vertical Forms
|
||||
# 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):
|
||||
if EnabledItems.get("JapaneseGlyphs"): JapaneseGlyphs(target)
|
||||
|
|
|
@ -46,6 +46,9 @@ def build(config=None):
|
|||
for unicode in keepList:
|
||||
if unicode == -1: continue
|
||||
target.selection.select(deselectFlags,unicode)
|
||||
def updateOriginalGlyphs():
|
||||
nonlocal keepList
|
||||
keepList = [i.unicode for i in kawaii.selection.byGlyphs]
|
||||
|
||||
# 모든 글리프를 붇여넣을 수 있도록 인코딩을 utf full 로 변경
|
||||
kawaii.encoding = 'UnicodeFull'
|
||||
|
@ -64,6 +67,7 @@ def build(config=None):
|
|||
target=kawaii,baseSize=baseSize,weightStr="Regular",
|
||||
sourcePath=nanumSquareNeo,
|
||||
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
||||
updateOriginalGlyphs()
|
||||
|
||||
# 일어 글리프 혹은 한자 글리프 추가
|
||||
if notoMono:
|
||||
|
@ -76,13 +80,19 @@ def build(config=None):
|
|||
"CJKCompatibilityIdeographs": config.get("CopyCJKCompatibilityIdeographs") or False,
|
||||
"Symbols": config.get("CopySymbols") or False,
|
||||
},
|
||||
target=kawaii,baseSize=550,
|
||||
target=kawaii,baseSize=baseSize,
|
||||
sourcePath=notoMono,
|
||||
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
||||
updateOriginalGlyphs()
|
||||
|
||||
# NerdFonts 패치 적용
|
||||
# if config.get("NerdFonts"):
|
||||
# nerdFontsPatcherPath = NerdFontsLoader.downloadPatcher()
|
||||
if config.get("NerdFonts"):
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue