Skip to content

Instantly share code, notes, and snippets.

View andjc's full-sized avatar

Andj andjc

  • Melbourne, Australia
View GitHub Profile
@greenlikeorange
greenlikeorange / fonttaggle.js
Last active August 29, 2015 14:09
ကိန္ဒရီ ဖောင့်တွဲခွဲ စနစ်
/**
* Knayi-myscript Detection and font tagging script
*
* Nov 10, 2014
* greenlikeorange<beginofalove@hotmail.com>
*
* original:
* https://github.com/greenlikeorange/knayi-myscript
*
*/
@saturngod
saturngod / myanmartext.js
Created February 13, 2013 16:10
check myanmar text or not
var regexMM = new RegExp("[\u1000-\u109f\uaa60-\uaa7f]+");
var text = "မြန်မာ";
if (!regexMM.test(text)) {
console.log("not myanmar text");
}
else {
console.log("myanmar text");
}
@slevithan
slevithan / xregexp-unicode-codepoints.js
Created May 7, 2012 20:54
Full 21-bit Unicode code point matching in XRegExp with \u{10FFFF}
// Allow syntax extensions
XRegExp.install("extensibility");
/* Adds Unicode code point syntax to XRegExp: \u{n..}
* `n..` is any 1-6 digit hexadecimal number from 0-10FFFF. Comes from ES6 proposals. Code points
* above U+FFFF are converted to surrogate pairs, so e.g. `\u{20B20}` is simply an alternate syntax
* for `\uD842\uDF20`. This can lead to broken behavior if you follow a `\u{n..}` token that
* references a code point above U+FFFF with a quantifier, or if you use the same in a character
* class. Using `\u{n..}` with code points above U+FFFF is therefore not recommended, unless you
* know exactly what you're doing. XRegExp's handling follows ES6 proposals for `\u{n..}`, since
@manuelmorales
manuelmorales / ghostxps.sh
Created April 17, 2012 11:01
Installing GhostPDL (with GhostXPS) on Ubuntu Oneiric
sudo apt-get install libxext-dev libxt-dev
wget http://downloads.ghostscript.com/public/ghostpdl-9.05.tar.bz2
tar xjf ./ghostpdl-9.05.tar.gz
cd ghostpdl-9.05/
./configure
echo '#define HAVE_SYS_TIME_H' >> xps/obj/gconfig_.h
make xps
./xps/obj/gxps -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -r150 -o /tmp/a.pdf ~/POWERPOINT.xps
@eimg
eimg / mmstrlen.php
Created May 31, 2012 12:03
Count no. of syllabes in a Myanmar Unicode string.
<?php
function mmstrlen($str) {
$standalones = array("ဤ", "၍", "ဪ", "၏", "၊", "။", "၌");
$consonants = array("က", "ခ", "ဂ", "ဃ", "င", "စ", "ဆ", "ဇ", "ဈ", "ည", "ဍ", "ဌ", "ဋ", "ဎ", "ဏ", "တ", "ထ", "ဒ", "ဓ", "န", "ပ", "ဖ", "ဗ", "ဘ", "မ", "ယ", "ရ", "လ", "ဝ", "သ", "ဟ", "ဠ", "အ");
$numbers = array("၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉");
$len = mb_strlen($str, "UTF-8");
$count = 0;
for($i = 0; $i < $len; $i++) {
@eimg
eimg / mm2en.js
Last active May 5, 2022 08:31
Convert Myanmar numbers to English numbers
// 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;
});
}
@korakot
korakot / thai_font.py
Last active June 30, 2022 05:18
Add thai font on Google Colaboratory notebook
!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')
#!/usr/bin/python3
# -*- coding:utf-8 -*-
r"""テキストファイルを画像に変換
このファイル自体はサブコマンンド向けに作られた内部のクラスを実行する
ためのダミー
使い方
# 縦長(720x1280) 20桁 白色文字 黒色背景 ./font.ttf png形式
@arastu
arastu / image_manipulation.py
Created May 4, 2021 13:51
Write rtl (Persian, Arabic, Hebrew) text on images using python and pillow
# 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
#!/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'