-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#2030] Add option to upload and use custom fonts #963
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/open_inwoner/configurations/migrations/0058_customfontset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Generated by Django 3.2.23 on 2024-01-29 10:45 | ||
|
||
import django.core.validators | ||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
import open_inwoner.configurations.models | ||
import open_inwoner.utils.files | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("configurations", "0057_siteconfiguration_theme_stylesheet"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="CustomFontSet", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"text_body_font", | ||
open_inwoner.configurations.models.CustomFontField( | ||
blank=True, | ||
help_text="Upload text body font. TTF font types only.", | ||
null=True, | ||
storage=open_inwoner.utils.files.OverwriteStorage(), | ||
upload_to=open_inwoner.configurations.models.CustomFontSet.update_filename_body, | ||
validators=[ | ||
django.core.validators.FileExtensionValidator(["ttf"]) | ||
], | ||
verbose_name="Text body font", | ||
), | ||
), | ||
( | ||
"heading_font", | ||
open_inwoner.configurations.models.CustomFontField( | ||
blank=True, | ||
help_text="Upload heading font. TTF font types only.", | ||
null=True, | ||
storage=open_inwoner.utils.files.OverwriteStorage(), | ||
upload_to=open_inwoner.configurations.models.CustomFontSet.update_filename_heading, | ||
validators=[ | ||
django.core.validators.FileExtensionValidator(["ttf"]) | ||
], | ||
verbose_name="Heading font", | ||
), | ||
), | ||
( | ||
"site_configuration", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="custom_fonts", | ||
to="configurations.siteconfiguration", | ||
verbose_name="Configuration", | ||
), | ||
), | ||
], | ||
), | ||
] |
13 changes: 13 additions & 0 deletions
13
src/open_inwoner/configurations/migrations/0059_merge_20240129_1645.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Generated by Django 3.2.23 on 2024-01-29 15:45 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("configurations", "0058_customfontset"), | ||
("configurations", "0058_siteconfiguration_recipients_email_digest"), | ||
] | ||
|
||
operations = [] |
72 changes: 72 additions & 0 deletions
72
src/open_inwoner/configurations/migrations/0060_auto_20240208_1426.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Generated by Django 3.2.23 on 2024-02-08 13:26 | ||
|
||
import django.core.validators | ||
from django.db import migrations | ||
import open_inwoner.configurations.models | ||
import open_inwoner.utils.files | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("configurations", "0059_merge_20240129_1645"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="customfontset", | ||
name="text_body_font", | ||
), | ||
migrations.AddField( | ||
model_name="customfontset", | ||
name="body_font_bold", | ||
field=open_inwoner.configurations.models.CustomFontField( | ||
blank=True, | ||
help_text="Upload bold text body font. TTF font types only.", | ||
null=True, | ||
storage=open_inwoner.utils.files.OverwriteStorage(), | ||
upload_to=open_inwoner.configurations.models.CustomFontSet.update_filename_body_bold, | ||
validators=[django.core.validators.FileExtensionValidator(["ttf"])], | ||
verbose_name="Body font bold", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="customfontset", | ||
name="body_font_bold_italic", | ||
field=open_inwoner.configurations.models.CustomFontField( | ||
blank=True, | ||
help_text="Upload bold italic text body font. TTF font types only.", | ||
null=True, | ||
storage=open_inwoner.utils.files.OverwriteStorage(), | ||
upload_to=open_inwoner.configurations.models.CustomFontSet.update_filename_body_bold_italic, | ||
validators=[django.core.validators.FileExtensionValidator(["ttf"])], | ||
verbose_name="Body font bold italic", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="customfontset", | ||
name="body_font_italic", | ||
field=open_inwoner.configurations.models.CustomFontField( | ||
blank=True, | ||
help_text="Upload italic text body font. TTF font types only.", | ||
null=True, | ||
storage=open_inwoner.utils.files.OverwriteStorage(), | ||
upload_to=open_inwoner.configurations.models.CustomFontSet.update_filename_body_italic, | ||
validators=[django.core.validators.FileExtensionValidator(["ttf"])], | ||
verbose_name="Body font italic", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="customfontset", | ||
name="body_font_regular", | ||
field=open_inwoner.configurations.models.CustomFontField( | ||
blank=True, | ||
help_text="Upload regular text body font. TTF font types only.", | ||
null=True, | ||
storage=open_inwoner.utils.files.OverwriteStorage(), | ||
upload_to=open_inwoner.configurations.models.CustomFontSet.update_filename_body, | ||
validators=[django.core.validators.FileExtensionValidator(["ttf"])], | ||
verbose_name="Body font regular", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why (as it was working before) but when I upload any kind of TTF file, it does correctly end up in the Media directory, but I do not see anything happening on the front-end (perhaps we need a fallback font somewhere?).
Here you can download clearly different TTF fonts for testing: https://www.fontsquirrel.com/fonts/acme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The font faces definitions were missing the custom fonts after rebasing. Also, I had to specify the font-family for our
utrecht-heading
. Should work now.