nerdfonts patcher support
parent
7eeb30a086
commit
2d55e92464
|
@ -1,10 +1,10 @@
|
||||||
import argparse
|
import argparse
|
||||||
|
import utility as Utility
|
||||||
|
|
||||||
def callPatcher(font):
|
def callPatcher(font):
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
NerdFontPatcher = sys.modules["NerdFontPatcher"]
|
NerdFontPatcher = sys.modules.get("NerdFontPatcher",None)
|
||||||
if not NerdFontPatcher:
|
if not NerdFontPatcher:
|
||||||
import importlib.util
|
import importlib.util
|
||||||
spec = importlib.util.spec_from_file_location("NerdFontPatcher", "assets/NerdFontPatcher_extract/fontPatcher.py")
|
spec = importlib.util.spec_from_file_location("NerdFontPatcher", "assets/NerdFontPatcher_extract/fontPatcher.py")
|
||||||
|
@ -32,7 +32,9 @@ def callPatcher(font):
|
||||||
args.windows = True
|
args.windows = True
|
||||||
args.alsowindows = False
|
args.alsowindows = False
|
||||||
args.nonmono = False
|
args.nonmono = False
|
||||||
|
# args.progressbars = False
|
||||||
args.progressbars = True
|
args.progressbars = True
|
||||||
|
# args.quiet = True
|
||||||
args.quiet = False
|
args.quiet = False
|
||||||
args.adjustLineHeight = True
|
args.adjustLineHeight = True
|
||||||
# args.careful = True
|
# args.careful = True
|
||||||
|
@ -50,9 +52,36 @@ def callPatcher(font):
|
||||||
selFlag = ("more","ranges","unicode")
|
selFlag = ("more","ranges","unicode")
|
||||||
|
|
||||||
def postScript(font,deselectOriginalGlyphs,baseSize):
|
def postScript(font,deselectOriginalGlyphs,baseSize):
|
||||||
|
# Termux, Vscode 등에서 정의된 크기에 따라
|
||||||
|
# 폰트 크기를 맞춥니다
|
||||||
|
|
||||||
|
# 일반 크기
|
||||||
font.selection.none()
|
font.selection.none()
|
||||||
font.selection.select()
|
font.selection.select(selFlag,0xE200,0xF8FE)
|
||||||
deselectOriginalGlyphs()
|
font.selection.select(selFlag,0xFADA,0xFD46)
|
||||||
|
font.selection.select(selFlag,0xF8FF,0xF8FF)
|
||||||
|
font.selection.select(selFlag,0xF0001,0xF1AF0)
|
||||||
|
deselectOriginalGlyphs(font)
|
||||||
|
Utility.setWidthWithSavingPosition(
|
||||||
|
font=font,targetWidth=baseSize*2
|
||||||
|
)
|
||||||
|
Utility.width(font=font,targetWidth=baseSize)
|
||||||
|
|
||||||
|
# 2배 크기
|
||||||
|
font.selection.none()
|
||||||
|
font.selection.select(selFlag,0xF8FF,0xFAD9)
|
||||||
|
deselectOriginalGlyphs(font)
|
||||||
|
Utility.setWidthWithSavingPosition(
|
||||||
|
font=font,targetWidth=baseSize*2
|
||||||
|
)
|
||||||
|
|
||||||
|
# 몰라 그냥 다 2배로
|
||||||
|
# font.selection.none()
|
||||||
|
# font.selection.select(selFlag,0xF8FF,0xFAD9)
|
||||||
|
# deselectOriginalGlyphs(font)
|
||||||
|
# Utility.setWidthWithSavingPosition(
|
||||||
|
# font=font,targetWidth=baseSize*2
|
||||||
|
# )
|
||||||
|
|
||||||
def build(target,deselectOriginalGlyphs,NerdFontsAdjust=True,baseSize=550,weightStr="Regular"):
|
def build(target,deselectOriginalGlyphs,NerdFontsAdjust=True,baseSize=550,weightStr="Regular"):
|
||||||
# 용량적 이유로 Regular 폰트에만 패치를 적용함
|
# 용량적 이유로 Regular 폰트에만 패치를 적용함
|
||||||
|
@ -64,5 +93,5 @@ def build(target,deselectOriginalGlyphs,NerdFontsAdjust=True,baseSize=550,weight
|
||||||
callPatcher(target)
|
callPatcher(target)
|
||||||
|
|
||||||
# 적절한 크기를 위해서 크기조절을 수행함
|
# 적절한 크기를 위해서 크기조절을 수행함
|
||||||
# if NerdFontsAdjust:
|
if NerdFontsAdjust:
|
||||||
# postScript(target,deselectOriginalGlyphs,baseSize)
|
postScript(target,deselectOriginalGlyphs,baseSize)
|
||||||
|
|
|
@ -40,15 +40,18 @@ def build(config=None):
|
||||||
print("--------------------- Patching ----------------------")
|
print("--------------------- Patching ----------------------")
|
||||||
|
|
||||||
# 유지 목록 (덮어쓰기 금지) 만들기
|
# 유지 목록 (덮어쓰기 금지) 만들기
|
||||||
kawaii.selection.all()
|
keepList = None
|
||||||
keepList = [i.unicode for i in kawaii.selection.byGlyphs]
|
|
||||||
def deselectOriginalGlyphs(target):
|
def deselectOriginalGlyphs(target):
|
||||||
|
nonlocal keepList
|
||||||
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():
|
def updateOriginalGlyphs():
|
||||||
nonlocal keepList
|
nonlocal keepList
|
||||||
|
kawaii.selection.all()
|
||||||
keepList = [i.unicode for i in kawaii.selection.byGlyphs]
|
keepList = [i.unicode for i in kawaii.selection.byGlyphs]
|
||||||
|
kawaii.selection.none()
|
||||||
|
updateOriginalGlyphs()
|
||||||
|
|
||||||
# 모든 글리프를 붇여넣을 수 있도록 인코딩을 utf full 로 변경
|
# 모든 글리프를 붇여넣을 수 있도록 인코딩을 utf full 로 변경
|
||||||
kawaii.encoding = 'UnicodeFull'
|
kawaii.encoding = 'UnicodeFull'
|
||||||
|
@ -93,6 +96,7 @@ def build(config=None):
|
||||||
baseSize=baseSize,
|
baseSize=baseSize,
|
||||||
weightStr="Regular",
|
weightStr="Regular",
|
||||||
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
deselectOriginalGlyphs = deselectOriginalGlyphs)
|
||||||
|
updateOriginalGlyphs()
|
||||||
|
|
||||||
# 생성
|
# 생성
|
||||||
if not os.path.exists("out"): os.mkdir("out")
|
if not os.path.exists("out"): os.mkdir("out")
|
||||||
|
|
|
@ -9,6 +9,9 @@ def setWidthWithSavingPosition(font,targetWidth):
|
||||||
glyph.right_side_bearing = int(glyph.right_side_bearing + math.ceil(sideAdjust))
|
glyph.right_side_bearing = int(glyph.right_side_bearing + math.ceil(sideAdjust))
|
||||||
glyph.width = targetWidth # 타겟 너비로 정확하게 설정
|
glyph.width = targetWidth # 타겟 너비로 정확하게 설정
|
||||||
|
|
||||||
|
def width(font,targetWidth):
|
||||||
|
for glyph in font.selection.byGlyphs: glyph.width = targetWidth
|
||||||
|
|
||||||
def scale(font,targetScale):
|
def scale(font,targetScale):
|
||||||
font.transform(psMat.scale(targetScale))
|
font.transform(psMat.scale(targetScale))
|
||||||
font.round()
|
font.round()
|
||||||
|
|
Loading…
Reference in New Issue