added otf

This commit is contained in:
Alexander Karpov 2023-04-15 14:44:59 +03:00
parent cc20d9aab2
commit 1f2544e357
3 changed files with 36 additions and 2 deletions

View File

@ -1,4 +1,4 @@
from . import application, audio, image, text, video
from . import application, audio, font, image, text, video
previews = {
"application": {
@ -37,6 +37,7 @@
"plain": text.plain.view,
"csv": text.csv.view,
},
"font": {"otf": font.otf.view},
}
source_code = {}
@ -62,4 +63,5 @@
"jar": application.zip.view,
"mpeg": video.mp4.view,
"oga": audio.oga.view,
"otf": font.otf.view,
} | source_code

View File

@ -0,0 +1 @@
from . import otf # noqa

View File

@ -1,5 +1,36 @@
import string
from akarpov.files.models import File
def view(file: File):
...
text = " ".join(string.printable)
name = file.file.path.split("/")[-1].split(".")[0]
static = (
"""
<style>
@font-face {
"""
+ f"""
font-family: {name};
src: url("{file.file.url}") format("opentype");
"""
+ """
}
#text-example {
"""
+ f"""
font-family: '{name}', serif;
font-size: 48px;
"""
+ """
}
</style>
"""
)
content = f"""
<div id="text-example" class="">
{text}
</div>
"""
return static, content