https://github.com/adobe-type-tools/afdko/ Adobe Font Development Kit for OpenType
https://github.com/mpcabd/python-arabic-reshaper/ Reconstruct Arabic sentences to be used in applications that don't support Arabic
https://github.com/adobe-type-tools/afdko/ Adobe Font Development Kit for OpenType
https://github.com/mpcabd/python-arabic-reshaper/ Reconstruct Arabic sentences to be used in applications that don't support Arabic
#!/usr/bin/env python3 | |
import shlex | |
import subprocess | |
import uharfbuzz as hb | |
font_dir = 'fonts/g/mac/10.15.7/' | |
font_path = f'{font_dir}Hiragino Kaku Gothic W4.ttc' | |
font_path = f'{font_dir}Hiragino MaruGothic ProN W4.ttc' | |
font_path = f'{font_dir}Hiragino Mincho ProN.ttc' |
# First of all you need install *libraqm* on your machin. | |
# The Raqm library encapsulates the logic for complex text layouts and provides a convenient API. | |
# libraqm relies on the following libraries: FreeType, HarfBuzz, FriBiDi, | |
# make sure that you install them before installing libraqm if not available as package in your system. | |
# if you using macos you can install libraqm with homebrew | |
# $> brew install libraqm | |
# Pillow wheels since version 8.2.0 include a modified version of libraqm |
from PIL import Image, ImageDraw, ImageFont | |
import PIL.features | |
# ! brew install libraqm | |
print('libraqm:', PIL.features.check('raqm')) | |
size = (320, 16) | |
""" | |
FORMAT = "RGB" |
from PIL import Image, ImageDraw, ImageFont, ImageFilter | |
im = Image.open("./blue30.png") | |
POS = (1, 4) | |
X = POS[0] * 80 | |
Y = POS[1] * 80 | |
im1 = im.crop((X, Y, X + 30, Y + 30)) |
#!/usr/bin/python3 | |
# -*- coding:utf-8 -*- | |
r"""テキストファイルを画像に変換 | |
このファイル自体はサブコマンンド向けに作られた内部のクラスを実行する | |
ためのダミー | |
使い方 | |
# 縦長(720x1280) 20桁 白色文字 黒色背景 ./font.ttf png形式 |
!wget https://github.com/Phonbopit/sarabun-webfont/raw/master/fonts/thsarabunnew-webfont.ttf | |
# !pip install -U --pre matplotlib | |
import matplotlib as mpl | |
mpl.font_manager.fontManager.addfont('thsarabunnew-webfont.ttf') # 3.2+ | |
mpl.rc('font', family='TH Sarabun New') |
import icu | |
thkey = icu.Collator.createInstance(icu.Locale('th_TH')).getSortKey | |
words = 'ไก่ ไข่ ก ฮา'.split() | |
print(sorted(words, key=thkey)) # ['ก', 'ไก่', 'ไข่', 'ฮา'] |
// INPUT: ၁၁.၁၂.၂၀၁၇ | |
// OUTPUT: 11.12.2017 | |
function mm2en(num) { | |
var nums = { '၀': '0', '၁': 1, '၂': 2, '၃': 3, '၄': 4 , '၅': 5, '၆': 6, '၇':7, '၈':8, '၉':9 }; | |
return num.replace(/([၀-၉])/g, function(s, key) { | |
return nums[key] || s; | |
}); | |
} |
# We start by loading up PyICU. | |
import PyICU as icu | |
# Let's create a test text. Notice it contains some punctuation. | |
test = u"This is (\"a\") test!" | |
# We create a wordbreak iterator. All break iterators in ICU are really RuleBasedBreakIterators, and we need to tell it which locale to take the word break rules from. Most locales have the same rules for UAX#29 so we will use English. | |
wb = icu.BreakIterator.createWordInstance(icu.Locale.getEnglish()) | |
# An iterator is just that. It contains state and then we iterate over it. The state in this case is the text we want to break. So we set that. |