Skip to content

Commit

Permalink
Merge pull request #950 from googlefonts/packager-article
Browse files Browse the repository at this point in the history
packager: use articles for new families
  • Loading branch information
m4rc1e authored May 16, 2024
2 parents 2ed86f5 + d80c684 commit 973e8dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
16 changes: 12 additions & 4 deletions Lib/gftools/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,18 @@ def package_family(
save_metadata(family_path / "METADATA.pb", metadata)
# Format HTML
desc_file = family_path / "DESCRIPTION.en_us.html"
with open(desc_file, encoding="utf-8") as fin:
description = format_html(fin.read())
with open(desc_file, "w", encoding="utf-8") as fout:
fout.write(description)
article_file = family_path / "article" / "ARTICLE.en_us.html"
if article_file.exists():
# Remove description file if an article already exists
if desc_file.exists():
os.remove(desc_file)
about_file = article_file
else:
about_file = desc_file
with open(about_file, encoding="utf-8") as fin:
about = format_html(fin.read())
with open(about_file, "w", encoding="utf-8") as fout:
fout.write(about)
return True


Expand Down
7 changes: 6 additions & 1 deletion Lib/gftools/scripts/add_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,19 @@ def main(args=None):
fonts.WriteProto(metadata, os.path.join(fontdir, 'METADATA.pb'), comments=language_comments)

desc = os.path.join(fontdir, 'DESCRIPTION.en_us.html')
articledir = os.path.join(fontdir, "article")
article = os.path.join(articledir, "ARTICLE.en_us.html")
if os.path.isfile(desc):
print('DESCRIPTION.en_us.html exists')
elif os.path.isfile(article):
print("ARTICLE.en_us.html exists")
else:
os.makedirs(os.path.join(fontdir, "article"))
desc_text = "N/A"
if args.github_url:
human_url = remove_url_prefix(args.github_url)
desc_text += f'\n<p>To contribute, please see <a href="{args.github_url}">{human_url}</a>.</p>'
_WriteTextFile(desc, desc_text)
_WriteTextFile(article, desc_text)


if __name__ == '__main__':
Expand Down

0 comments on commit 973e8dc

Please sign in to comment.