Skip to content

PADDLE_PDX_LOCAL_FONT_FILE_PATH controls only a single font's explicit location #4405

Description

@pechersky

@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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions