tkinter.font — Tkinter 글꼴 래퍼

소스 코드: Lib/tkinter/font.py


The tkinter.font module provides the Font class for creating and using named fonts.

구별되는 글꼴 무게와 기울기는 다음과 같습니다:

tkinter.font.NORMAL
tkinter.font.BOLD
tkinter.font.ITALIC
tkinter.font.ROMAN
class tkinter.font.Font(root=None, font=None, name=None, exists=False, **options)

Font 클래스는 명명된 글꼴을 나타냅니다. Font 인스턴스에는 고유한 이름이 지정되며 패밀리, 크기 및 스타일 구성으로 지정할 수 있습니다. 명명된 글꼴은 나타날 때마다 어트리뷰트로 글꼴을 지정하지 않고, 글꼴을 단일 객체로 만들고 식별하는 Tk의 방법입니다.

버전 3.10에서 변경: Two fonts now compare equal (==) only when both are Font instances with the same name belonging to the same Tcl interpreter.

인자:

font - 글꼴 지정자 튜플 (패밀리, 크기, 옵션)
name - 고유한 글꼴 이름
exists - 참이면 self가 기존의 명명된 글꼴을 가리킵니다

추가 키워드 옵션 (font가 지정되면 무시됩니다):

family - font family, for example, Courier, Times
size - 글꼴 크기
size가 양수이면 포인트 단위의 크기로 해석됩니다.
size가 음수이면 절댓값을
픽셀 단위의 크기로 처리합니다.
weight - 글꼴 강조 (NORMAL, BOLD)
slant - ROMAN, ITALIC
underline - 글꼴 밑줄 (0 - 없음, 1 - 밑줄)
overstrike - 글꼴 취소선 (0 - 없음, 1 - 취소선)
actual(option=None, displayof=None)

Return the actual attributes of the font, which may differ from the requested ones because of platform limitations. With no option, return a dictionary of all the attributes; if option is given, return the value of that single attribute.

cget(option)

글꼴의 어트리뷰트를 가져옵니다.

configure(**options)

Modify one or more attributes of the font. With no arguments, return a dictionary of the current attributes.

config() is an alias of configure().

copy()

현재 글꼴의 새 인스턴스를 반환합니다.

measure(text, displayof=None)

Return amount of space the text would occupy on the specified display when formatted in the current font, as an integer number of pixels. If no display is specified then the main application window is assumed.

metrics(*options, **kw)

Return font-specific data. With no options, return a dictionary mapping each metric name to its integer value; if one option name is given, return that metric’s value as an integer. Options include:

ascent - 기준선(baseline)과 글꼴의 문자가 차지할 수 있는 가장 높은 점 사이의 거리

.

descent - 기준선과 글꼴의 문자가 차지할 수 있는 가장 낮은 점 사이의 거리

.

linespace - 줄 사이에 수직 겹침이 없음을 보장하는, 글꼴의 임의의 두 문자 간에 필요한 최소 수직 분리

.

fixed - 글꼴이 고정 너비이면 1, 그렇지 않으면 0

tkinter.font.families(root=None, displayof=None)

Return a tuple of the names of the available font families.

tkinter.font.names(root=None)

Return a tuple of the names of all the defined fonts.

tkinter.font.nametofont(name, root=None)

Return a Font representation of the existing named font name. root is the widget whose Tcl interpreter owns the font; if omitted, the default root window is used.

버전 3.10에서 변경: The root parameter was added.