Skip to content

Instantly share code, notes, and snippets.

@jtanx
jtanx / Calculating xAvgCharwidth.md
Created November 30, 2013 05:55
Calculating xAvgCharWidth for the OS/2 font table.

For OS/2 table versions >= 3, take the sum of the advancement widths (from the hmtx table) of each glyph, iff the advancement width is greater than zero. Do integer division of this sum by the number of glyphs that had an advancement width > 0.

For versions < 3, follow a similar procedure, but weight according to: http://www.microsoft.com/typography/otspec/os2ver2.htm#acw, and only consider lowercase latin characters for the average.

@jtanx
jtanx / multibytecmap4-1.md
Created December 17, 2013 06:59
Looking up non-Unicode format 4 TrueType character maps (cmap; ShiftJIS, PRC, Big5, Wansung, Johab)

Reference material: http://www.microsoft.com/typography/otspec/cmap.htm

Convert Unicode string using the appropriate encoding (e.g ShiftJIS). For each unicode code point, store the corresponding multibyte character sequence in little endian format.

E.g: Suppose you converted the character 'コ' (U+30B3) using ShiftJIS encoding. This would give the bytes [0x83, 0x52]. Store the result in a WORD (or larger sized variable) to give 0x8352 as the value. Use this value to lookup the glyph id from the cmap.

Conversion between charsets may be achieved through a number of ways, such as by using ICU. On Windows, the Unicode and Character set functions, such as WideChartoMultiByte may be used instead. Depending on the language, there may be in-built character set conversion utilities.

@jtanx
jtanx / gist:af507cf13eb1cb705836
Created August 9, 2014 02:30
FF build PR #1616+a0126eda4d27b83da27b63fc90bb4dfcb5a9fff3
bootstrap: running: libtoolize --quiet
bootstrap: running: git clone --depth 365 'git://git.sv.gnu.org/gnulib' 'gnulib'
Cloning into 'gnulib'...
Checking out files: 1% (148/9274)
Checking out files: 2% (186/9274)
Checking out files: 3% (279/9274)
Checking out files: 3% (339/9274)
Checking out files: 4% (371/9274)
Checking out files: 5% (464/9274)
Checking out files: 5% (537/9274)
@jtanx
jtanx / gist:e98d78381eb731e71ca2
Created July 4, 2015 02:24
List of results from setlocale(LC_ALL, "")
Afrikaans_South Africa.1252
Albanian_Albania.1250
Alsatian_France.1252
Arabic_Algeria.1256
Arabic_Bahrain.1256
Arabic_Egypt.1256
Arabic_Iraq.1256
Arabic_Jordan.1256
Arabic_Kuwait.1256
Arabic_Lebanon.1256
@jtanx
jtanx / gist:d62c55137435e85f149c1538bd4924ac
Created March 30, 2016 11:06
Visual Studio 2015 fix missing libcpmt.lib/libcpmtd.lib

This fixes linking when using the v120 toolset.

You will need to download the installation files for Visual Studio 2013. This link should work: https://www.microsoft.com/en-au/download/details.aspx?id=44914 (download the ISO)

Note that you don't have to install Visual Studio 2013.

  1. Extract the contents of D:\packages\vc_libraryDesktop\x86\vc_LibraryDesktopX86.msi and D:\packages\vc_libraryDesktop\x64\vc_LibraryDesktopX64.msi. Use something like the Universal Extractor.
  2. Copy the contents into C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib and C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\amd64 respectively.
@jtanx
jtanx / highlighter.ahk
Last active January 2, 2021 18:12
Acrobat DC Highlighter tool
; Set colour Acrobat DC
; Valid x positions: 20, 35, 55, 75, 90, 111, 128, 146
; Valid y positions: 60, 80, 100, 120, 135
SetColour(x, y)
{
If WinExist("Highlighter Tool Properties ahk_class AVL_AVFloating") or WinExist("Highlight Properties ahk_class AVL_AVFloating")
{
WinActivate
WinWaitActive
if !ErrorLevel
@jtanx
jtanx / compile.sh
Created April 23, 2016 01:15
GDK transient test
#!/bin/bash
set -ev
gcc -Wall -Werror -pedantic -std=c99 -g `pkg-config --cflags gdk-3.0` gdktransient.c `pkg-config --libs gdk-3.0` -o gdk
./gdk
@jtanx
jtanx / formula_installer.rb
Last active July 21, 2016 05:29
homebrew on roids
require "cxxstdlib"
require "exceptions"
require "formula"
require "keg"
require "tab"
require "utils/bottles"
require "caveats"
require "cleaner"
require "formula_cellar_checks"
require "install_renamed"
warning: HEAP[fontforge.exe]:
warning: Heap block at 0476DFC8 modified at 047A17C8 past requested size of 337f
8
Program received signal SIGTRAP, Trace/breakpoint trap.
0x76faeeab in ntdll!RtlpNtSetValueKey () from C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) bt full
#0 0x76faeeab in ntdll!RtlpNtSetValueKey ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
@jtanx
jtanx / python_web_app_azure_deployment.md
Last active December 30, 2016 14:27
Deploying a Python Web App on Azure

NOTE: For more up-to-date instructions and more explanations, please see the readme of https://github.com/jtanx/isso-azure

Basic instructions

  1. Add a new Web App
  2. Go to https://my-web-app-name.scm.azurewebsites.net and click on Site Extensions
  3. Install the Python 2.7.12 x64 and IIS Manager extensions. Click on Restart site when both are installed.
  4. Under the installed site extensions, click on the play (▶) button for IIS Manager.
  5. Go to the applicationHost.xdt tab
  6. Enter the following contents: