How can i add bengali font in a django web application
I want to create a quiz web application using django where the quiz question will be in Bengali. How can i generate the bengali font in my desired site. Please if anyo开发者_StackOverflow中文版ne tell me .. i will be grateful to him
Django is not involved in font rendering on the browser. Embedding a particular font via CSS is still problematical until today. You may find answers at How to embed fonts in HTML?.
In Django, you specify only the character codes. You may have to use unicode escape sequences in strings, unless you can enter Bengali characters directly. Bengali characters reside in the unicode range U+0981 to U+09FA. I assume that your target audience will have glyphs installed for those characters, so there may be no need to provide an embedded font at all.
You can use the following script to display a list of the defined Bengali unicode characters.
import sys
import unicodedata as ucd
try:
chr = unichr
except NameError:
# Python 3
unicode = str
def filter_bengali():
for i in range(256, sys.maxunicode + 1):
try:
name = ucd.name(chr(i))
if 'BENGALI' in name:
print(unicode('U+{0:04X} {1:<60} {2}').format(i, name, chr(i)))
except ValueError:
pass
if __name__ == '__main__':
filter_bengali()
精彩评论