|
@property |
|
def path(self): |
|
# HACK: download font file when needed only |
|
if not self._local_path: |
|
self._get_offical_font() |
|
return self._local_path |
|
|
|
def _get_offical_font(self): |
|
""" |
|
Download the official font file. |
|
""" |
|
font_path = (Path(CACHE_DIR) / "fonts" / self._font_name).resolve().as_posix() |
|
if not Path(font_path).is_file(): |
|
download( |
|
url=f"https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/fonts/{self._font_name}", |
|
save_path=font_path, |
|
) |
|
self._local_path = font_path |
|
|
|
|
|
if Path(str(LOCAL_FONT_FILE_PATH)).is_file(): |
|
logging.warning( |
|
f"Using the local font file(`{LOCAL_FONT_FILE_PATH}`) specified by `LOCAL_FONT_FILE_PATH`!" |
|
) |
|
|
|
PINGFANG_FONT = Font(font_name="PingFang-SC-Regular.ttf") |
|
SIMFANG_FONT = Font(font_name="simfang.ttf") |
Ideally, one could specify a local fonts location directory. Otherwise, if one sets PADDLE_PDX_LOCAL_FONT_FILE_PATH, then that makes all the fonts use the same exact file.
If one wants to make it work now, one has to set CACHE_DIR instead via PADDLE_PDX_CACHE_HOME, which has larger efffects.
PaddleX/paddlex/utils/fonts.py
Lines 83 to 109 in a8ec0bd
Ideally, one could specify a local fonts location directory. Otherwise, if one sets
PADDLE_PDX_LOCAL_FONT_FILE_PATH, then that makes all the fonts use the same exact file.If one wants to make it work now, one has to set
CACHE_DIRinstead viaPADDLE_PDX_CACHE_HOME, which has larger efffects.