하나 이상의 선택된 글꼴에서 미리보기 이미지를 만들 수있는 라이브러리입니다.
전체 문서는 여기에 있습니다 : Readthedocs
설치하기 전에 패키지를 테스트하려면 테스트를 사용하십시오.
$ git clone https://github.com/MatteoGuadrini/fontpreview.git
$ cd fontpreview
$ python -m unittest test_fp.py pypi 사용 :
$ pip install --user fontpreview참고 : 명령 줄 도구를 사용하려면 시스템 전체 라이브러리를 설치해야합니다 :
pip install fontpreview
미리보기 예 :
from fontpreview import FontPreview
fp = FontPreview ( '/tmp/noto.ttf' )
fp . save ( '/tmp/fp.png' )배너 예 :
from fontpreview import FontBanner
fb = FontBanner ( '/tmp/noto.ttf' , 'landscape' , bg_color = ( 153 , 153 , 255 ), mode = 'fontname' )
fb . save ( '/tmp/fb.png' )로고 예 :
from fontpreview import FontLogo
fl = FontLogo ( '/tmp/noto.ttf' , 'Fp' )
fl . save ( '/tmp/fl.png' )글꼴 벽 예 :
from fontpreview import FontBanner , FontWall
# Define the various parts of wall
fb = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'fontname' )
fb2 = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'alpha' )
fb3 = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'letter' )
fb4 = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'paragraph' )
fw = FontWall ([ fb , fb2 , fb3 , fb4 ])
fw . save ( '/tmp/fw.png' )글꼴 페이지 예 :
from fontpreview import FontPage , FontBanner
# Define the various parts of page
header = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'fontname' )
body = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'paragraph' )
footer = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'letter' )
# Create FontPage object
fpage = FontPage ()
fpage . set_header ( header )
fpage . set_body ( body )
fpage . set_footer ( footer )
# Design all parts
fpage . draw ()
fpage . save ( '/tmp/fpage.png' )템플릿 예제가있는 글꼴 페이지 :
from fontpreview import FontPage , FontPageTemplate , FontBanner
# Define the various parts of page
header = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'fontname' )
body = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'paragraph' )
footer = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'letter' )
# Create font page template
template = FontPageTemplate ( 3508 )
template . set_body ( 170 , 1 , 'lcenter' )
template . set_footer ( 100 , 4 , 'lcenter' )
# Create FontPage object
fpage = FontPage ( template = template )
fpage . set_header ( header )
fpage . set_body ( body )
fpage . set_footer ( footer )
# Design all parts
fpage . draw ()
fpage . save ( '/tmp/fpage_template.png' )글꼴 소책자 예제 :
from fontpreview import FontPage , FontBanner , FontBooklet
# Define the various parts of page
header = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'fontname' )
body = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'paragraph' )
footer = FontBanner ( '/tmp/noto.ttf' , 'landscape' , mode = 'letter' )
# Create FontPage object
fpage1 = FontPage ( header = header , body = body , footer = footer )
fpage2 = FontPage ( header = header , body = body , footer = footer )
# Design all parts
fpage1 . draw ()
fpage2 . draw ()
# Create book
book = FontBooklet ( fpage1 , fpage2 )
book . save ( '/tmp/noto_book/' ) # save page1.png, page2.png in /tmp/noto_book/ folder 아래는 "Fira Code 일반" 글꼴의 다양한 미리보기의 예입니다. 그것은 당신에게 무엇을 생각 나게합니까? Fira Code Original
# FIRA CODE WALL
from fontpreview import FontBanner , FontWall
fira_code = '/tmp/firacode.ttf'
# RGB group = ('background', 'FIRA COD color', 'Ligature color', 'E color background')
colors_group = [
( 'black' , ( 0 , 143 , 0 ), ( 0 , 236 , 236 ), ( 255 , 0 , 255 )),
( 'black' , ( 166 , 47 , 123 ), ( 81 , 208 , 93 ), ( 11 , 179 , 248 )),
(( 13 , 21 , 43 ), ( 112 , 204 , 84 ), ( 226 , 110 , 34 ), ( 223 , 245 , 90 )),
(( 43 , 6 , 42 ), ( 136 , 126 , 135 ), ( 4 , 150 , 153 ), ( 147 , 103 , 145 )),
(( 39 , 57 , 85 ), ( 255 , 241 , 208 ), ( 208 , 84 , 0 ), ( 209 , 215 , 227 )),
(( 31 , 63 , 89 ), ( 248 , 248 , 242 ), ( 230 , 219 , 117 ), ( 166 , 226 , 51 )),
(( 1 , 47 , 80 ), ( 224 , 202 , 52 ), ( 73 , 217 , 38 ), ( 255 , 125 , 158 )),
(( 0 , 0 , 170 ), ( 75 , 224 , 245 ), ( 255 , 255 , 85 ), ( 0 , 170 , 170 )),
( 'white' , 'black' , 'black' , 'black' ),
(( 247 , 247 , 247 ), ( 167 , 29 , 93 ), ( 121 , 93 , 163 ), ( 0 , 134 , 179 )),
(( 239 , 240 , 243 ), ( 15 , 131 , 207 ), ( 208 , 84 , 0 ), ( 105 , 40 , 122 )),
(( 239 , 231 , 212 ), ( 218 , 116 , 53 ), ( 0 , 142 , 212 ), ( 186 , 136 , 0 )),
(( 39 , 40 , 34 ), ( 132 , 214 , 45 ), ( 249 , 39 , 114 ), ( 174 , 129 , 255 )),
(( 43 , 48 , 59 ), ( 180 , 142 , 173 ), ( 143 , 161 , 179 ), ( 152 , 190 , 140 )),
(( 32 , 32 , 32 ), ( 171 , 130 , 84 ), ( 160 , 171 , 127 ), ( 216 , 127 , 98 )),
(( 0 , 43 , 54 ), ( 0 , 160 , 153 ), ( 126 , 143 , 3 ), ( 218 , 66 , 130 ))
]
banners = []
# Create banners
for colors in colors_group :
# Create a FontBanner objects
fb = FontBanner ( fira_code , ( 413 , 240 ))
liga = FontBanner ( fira_code , ( 413 , 240 ))
E = FontBanner ( fira_code , ( 40 , 70 ))
# Set background colors
fb . bg_color = liga . bg_color = colors [ 0 ]
E . bg_color = colors [ 3 ]
# Set foreground colors
fb . fg_color = colors [ 1 ]
liga . fg_color = colors [ 2 ]
E . fg_color = colors [ 0 ]
# Set text
fb . font_text = 'FIRA COD'
liga . font_text = "!=->>++:="
E . font_text = 'E'
# Set text position
E . set_text_position ( 'ltop' )
fb . set_text_position (( 25 , 60 ))
liga . set_text_position ( 'top' )
# Adding image on fb
fb . add_image ( liga , ( 0 , 122 ))
fb . add_image ( E , ( 339 , 60 ))
# Add to list of banners
banners . append ( fb )
# Create a wall
fw = FontWall ( banners , max_tile = 4 )
fw . save ( '/tmp/fira_code.png' ) 패키지와 함께이 Python 패키지를 기반으로하는 명령 줄 도구가 설치됩니다. 명령 줄 미리보기에 사용되는 클래스는 fontpreview입니다. 이 도구의 모든 옵션은 문서를 참조하십시오. 그렇지 않으면 fp -h 실행하십시오.
$ fp /tmp/noto.ttf이 명령은 현재 디렉토리에 fontpreview.png를 저장합니다.
fontpreview 는 오픈 소스 프로젝트입니다. 어떤 공헌이든 환영합니다.
감사합니다 .
기부하려면 이것을 누르십시오
나를 위한
Telethon의 경우
Telethon Foundation은 대학교 및 과학 기술 연구부에서 인정하는 비영리 단체입니다. 그들은 1990 년에 드문 질병으로 고통받는 환자의 호소에 반응하기 위해 태어났습니다. 오늘 오, 우리는 연중 매일 매일 듣고 대답 할 수 있도록 조직됩니다.
미래를 채택하십시오
학습 파이썬을 작성한 Mark Lutz에게 감사하고 파이썬 재단을 구성하는 Python Books를 프로그래밍합니다 .
Kenneth Reitz와 Tanya Schlusser에게 The Hitchhiker 's Guide to Python Books에 감사드립니다.
Python Pro Books의 관행을 작성해 주신 Dane Hillard에게 감사드립니다.
이 개발의 부재 시간을 이해 한 아내에게 특별한 감사를드립니다. 내 아이들 덕분에, 그들이주는 매일의 영감을주고, 인생은 단순해야한다는 것을 깨닫게하기 위해.
감사합니다 Python!