mirror of
				https://github.com/Alexander-D-Karpov/akarpov
				synced 2025-10-31 22:37:26 +03:00 
			
		
		
		
	added otf
This commit is contained in:
		
							parent
							
								
									cc20d9aab2
								
							
						
					
					
						commit
						1f2544e357
					
				|  | @ -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 | ||||
|  |  | |||
|  | @ -0,0 +1 @@ | |||
| from . import otf  # noqa | ||||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user