PillowImage.font.register   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A register_font() 0 9 2
1
import os
2
3
from PyBundle import bundle_dir, resource_path
4
from reportlab.pdfbase import pdfmetrics
5
from reportlab.pdfbase.ttfonts import TTFont
6
7
8
def register_font(font='Vera.ttf'):
9
    """Register fonts for report labs canvas."""
10
    directory = os.path.join(bundle_dir())
11
    ttfFile = resource_path(os.path.join(directory, font))
12
    if os.path.exists(ttfFile):
13
        pdfmetrics.registerFont(TTFont("Vera", ttfFile))
14
        return ttfFile
15
    else:
16
        print(ttfFile, 'can not be found')
17
18
19
FONT = register_font()
20