Prawn PDF support both English and Japenese/Chinese/Thai/Korean in same PDF
Date : March 29 2020, 07:55 AM
help you fix your problem Here's the solution, pieced together from this post ( this post) and some trial and error. The key is that Prawn supports fallback fonts. You have to download them into your project, then update Prawn's font families to include them, then include a method called "fallback_fonts" for Prawn to use when it realizes it has a unicode character that it doesn't know how to render. class ResultsPdf < Prawn::Document
def initialize(device)
super()
@device = device
set_fallback_fonts
page_title #typically English
persons_name #typically Japanese
end
def set_fallback_fonts
ipamp_path = "lib/assets/ipamp.ttf"
ipamp_spec = { file: ipamp_path, font: 'IPAPMincho'}
#don't use a symbol to define the name of the font!
font_families.update("ipamp" => {normal: ipamp_spec,
bold: ipamp_spec,
italic: ipamp_spec,
bold_italic: ipamp_spec})
end
def fallback_fonts
["ipamp"]
end
def page_title
# device name is typically in English
text "#{@device.name}", :size => 15, :style => :bold, :align => :center
end
def persons_name
# owner name can be in any language, including Japanese
# you don't have to specify :fallback_font here. Prawn will use your method.
text "Name: #{@device.owner_last_name}"
end
end
|
Regular Expression to accept all Thai characters and English letters in python
Tag : python , By : Andrew Bailey
Date : March 29 2020, 07:55 AM
I wish this helpful for you I'll be using some lists to do what I need. First, let's create the pattern : pattern = re.compile(r"[^\u0E00-\u0E7Fa-zA-Z' ]|^'|'$|''")
test_string="ทรูวิชั่นส์ ประกาศถ่ายทอดสดศึกฟุตบอล พรีเมียร์ ลีก อังกฤษ ครบทุกนัดเป็นเวลา 3 ปี ตั้งแต่ฤดูกาล 2016/2017 - 2018/2019 พร้อมด้วยอีก 5 ลีกดัง อาทิ ลา ลีกา สเปน, กัลโช เซเรีย เอ อิตาลี และลีกเอิง ฝรั่งเศส ภายใต้แพ็กเกจสุดคุ้ม ทั้งผ่านมือถือ และโทรทัศน์ some, English words here! abc123"
char_to_remove = re.findall(pattern, test_string)
list_with_char_removed = [char for char in test_string if not char in char_to_remove]
result_string = ''.join(list_with_char_removed)
|
What's the best way to convert a date in the form yyyy-mm-dd to a date using English month names?
Tag : python , By : lifchicker
Date : March 29 2020, 07:55 AM
I wish this help you You have to parse it in the existing format, and output the new. There is an output %B that represents the full month. Example: import datetime
s = '2018-05-20'
dt = datetime.datetime.strptime(s, '%Y-%m-%d')
print dt.strftime('%B %d, %Y')
$ python test.py
May 20, 2018
|
Convert French date string to English date for comparison
Date : March 29 2020, 07:55 AM
This might help you The best solution I could come up with when the overall site architecture can't be changed was to create an associate array to map French strings back into English for strtotime() to understand: var monthMap = {
'janvier' => 'january',
...
}
|
How to convert Thai date format to English using javascript?
Date : March 29 2020, 07:55 AM
|