Skip to content

Instantly share code, notes, and snippets.

View dohyunkim's full-sized avatar

Dohyun Kim dohyunkim

View GitHub Profile
\documentclass{article}
\usepackage{fontspec,xcolor,luamplib}
\setmainfont{tex gyre pagella}
\directlua{
local function ol(f,_,v)
v = tonumber(v) or 3
v = v * f.size / 6578.176 % 3 means 0.3pt when using 10pt font
f.width = v
f.mode = 1
end
@dohyunkim
dohyunkim / glyphshape.tex
Last active April 3, 2024 08:49
path of a glyph
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
%\setmainfont{Noto Sans CJK KR}
%\setmainfont{Zapfino}
\usepackage{luamplib}
\directlua{ mplibglyph = require'mplibglyph' }
\begin{document}
\begin{mplibcode}
@dohyunkim
dohyunkim / noembed.tex
Last active May 8, 2023 06:47
Don't Embed Fonts
\documentclass{article}
\usepackage{kotex}
\newfontfeature{NoEmbedding}{noembedding}
\directlua{
local function noembed (tfmdata)
local properties = tfmdata.properties
if not properties.filename then
properties.filename = tfmdata.filename
end
@dohyunkim
dohyunkim / uldot.tex
Last active June 15, 2021 08:24
dotemph inside uline (xetexko)
\input xetexko.sty
\input ulem.sty
\catcode`@=11
\UL@hook\expandafter{\the\UL@hook
\protected\def\dotemph#1{%
\ifx\ \LA@space\else \UL@stop\fi
\leavevmode
\setbox\XeKo@dotemph@box\hbox{\raise\dotemphraise\hbox{\dotemphchar}}%
\begingroup
\let\XeKo@maybe@dotemph\XeKo@do@dotemph
@dohyunkim
dohyunkim / xetexprotrusion.tex
Last active April 3, 2021 12:49
xetex protrusion
\font\ntss="Noto Sans CJK KR:mapping=tex-text;script=hang;language=KOR" at 10pt
\ntss
% xetex -no-pdf xxx.tex 한 후 dviasm 을 실행해 gid 를 알아낸다.
\setbox0\hbox{\XeTeXglyph 63116}
\rpcode\font 63116=\dimexpr100\wd0/(\fontdimen6\font/10)\relax
\XeTeXprotrudechars=2
가.
@dohyunkim
dohyunkim / xetexclasses.tex
Created March 4, 2021 08:19
XeTeX character classes
\documentclass{minimal}
\chardef\XeTeXcharclassIgnore=4096
\chardef\XeTeXcharclassBoundary=4095
\newXeTeXintercharclass\XeTeXcharclassID
\newXeTeXintercharclass\XeTeXcharclassCJ
\newXeTeXintercharclass\XeTeXcharclassOP
\newXeTeXintercharclass\XeTeXcharclassCL
\newXeTeXintercharclass\XeTeXcharclassEX
\newXeTeXintercharclass\XeTeXcharclassIS
\newXeTeXintercharclass\XeTeXcharclassNS
\documentclass[a4paper]{article}
\usepackage{kotex,iftex}
\defaultfontfeatures+{Renderer=OpenType}
\setmainhangulfont{Noto Sans CJK KR}[Script=Hangul, BoldFont=* Bold]
\newfontfamily\manjufont{Noto Sans Mongolian}[Script=Mongolian]
\ifluatex
\hangulpunctuations=0
\directlua{
function reverselines(box)
local t, head, curr, prevdp = {}
@dohyunkim
dohyunkim / xindex-ko.lua
Last active April 9, 2022 13:17
xindex Korean config. v2
--[[
-- xindex-ko.lua
-- written by Dohyun Kim
-- license: LPPL
-- reference: KS X 1026-1:2007
--
-- usage: xindex -c ko -l ko file.idx
--
--]]
--[[
-- xindex-ko.lua
-- written by Dohyun Kim
-- license: LPPL
-- reference: KS X 1026-1:2007
--
-- usage: xindex -c ko -l ko file.idx
--
-- todo: hanja (?)
--]]
@dohyunkim
dohyunkim / tys.tex
Last active May 3, 2017 02:27
산가지 算木
\newif\ifsetminus
\def\tys#1{%
\begingroup
\dimen0=0pt \dimen2=0pt \hsize=0pt
\setbox4=\vbox\bgroup\splitbyspace#1 ~ %
\edef\x{\egroup\hbox{\kern\the\dimen0 \box4\kern\the\dimen2}}\x
\endgroup
}
\def\splitbyspace#1 {%
\ifx#1~\else