From 9e39dfea71197e6b97d2223b0941d2c375ee0663 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 8 Feb 2020 22:16:07 +0000 Subject: jlreq (8feb20) git-svn-id: svn://tug.org/texlive/trunk@53717 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/jlreq/Makefile | 193 ++++++++++++ .../source/latex/jlreq/README-template.html | 94 ++++++ .../source/latex/jlreq/README-template.tex | 68 ++++ Master/texmf-dist/source/latex/jlreq/luajfm2pl.lua | 342 +++++++++++++++++++++ .../source/latex/jlreq/make_variant_jfm.lua | 177 +++++++++++ 5 files changed, 874 insertions(+) create mode 100644 Master/texmf-dist/source/latex/jlreq/Makefile create mode 100644 Master/texmf-dist/source/latex/jlreq/README-template.html create mode 100644 Master/texmf-dist/source/latex/jlreq/README-template.tex create mode 100644 Master/texmf-dist/source/latex/jlreq/luajfm2pl.lua create mode 100644 Master/texmf-dist/source/latex/jlreq/make_variant_jfm.lua (limited to 'Master/texmf-dist/source/latex') diff --git a/Master/texmf-dist/source/latex/jlreq/Makefile b/Master/texmf-dist/source/latex/jlreq/Makefile new file mode 100644 index 00000000000..139d68925ff --- /dev/null +++ b/Master/texmf-dist/source/latex/jlreq/Makefile @@ -0,0 +1,193 @@ +TEXMF:=$(shell kpsewhich -var-value=TEXMFHOME) +MAKEJVFCNF:=$(shell ls -R $(shell kpsewhich --var-value=TEXMFDIST)/fonts/source | awk '/:$$/{sub(/:$$/,"");f=$$0} tolower($$0) ~ /makejvf-upjpn\.cnf$$/{print f"/"$$0}' | head -n 1) + +all: jfm + +jfm: \ + jfm-jlreqv.lua \ + jlreq.tfm bjlreq.tfm zjlreq.tfm bzjlreq.tfm \ + jlreq.vf bjlreq.vf zjlreq.vf bzjlreq.vf \ + ujlreq.tfm ubjlreq.tfm uzjlreq.tfm ubzjlreq.tfm \ + ujlreq.vf ubjlreq.vf uzjlreq.vf ubzjlreq.vf \ + ujlreq-q.tfm ubjlreq-q.tfm uzjlreq-q.tfm ubzjlreq-q.tfm \ + ujlreq-q.vf ubjlreq-q.vf uzjlreq-q.vf ubzjlreq-q.vf \ + jlreqg.tfm bjlreqg.tfm zjlreqg.tfm bzjlreqg.tfm \ + jlreqg.vf bjlreqg.vf zjlreqg.vf bzjlreqg.vf \ + ujlreqg.tfm ubjlreqg.tfm uzjlreqg.tfm ubzjlreqg.tfm \ + ujlreqg.vf ubjlreqg.vf uzjlreqg.vf ubzjlreqg.vf \ + ujlreqg-q.tfm ubjlreqg-q.tfm uzjlreqg-q.tfm ubzjlreqg-q.tfm \ + ujlreqg-q.vf ubjlreqg-q.vf uzjlreqg-q.vf ubzjlreqg-q.vf \ + jlreq-v.tfm bjlreq-v.tfm zjlreq-v.tfm bzjlreq-v.tfm \ + jlreq-v.vf bjlreq-v.vf zjlreq-v.vf bzjlreq-v.vf \ + ujlreq-v.tfm ubjlreq-v.tfm uzjlreq-v.tfm ubzjlreq-v.tfm \ + ujlreq-v.vf ubjlreq-v.vf uzjlreq-v.vf ubzjlreq-v.vf \ + jlreqg-v.tfm bjlreqg-v.tfm zjlreqg-v.tfm bzjlreqg-v.tfm \ + jlreqg-v.vf bjlreqg-v.vf zjlreqg-v.vf bzjlreqg-v.vf \ + ujlreqg-v.tfm ubjlreqg-v.tfm uzjlreqg-v.tfm ubzjlreqg-v.tfm \ + ujlreqg-v.vf ubjlreqg-v.vf uzjlreqg-v.vf ubzjlreqg-v.vf \ + + rm -f rml.tfm rmlv.tfm gbm.tfm gbmv.tfm uprml-h.tfm uprml-hq.tfm upgbm-h.tfm upgbm-hq.tfm uprml-v.tfm uprml-vq.tfm upgbm-v.tfm upgbm-vq.tfm + +# .pl +u%-v.pl: jfm-%v-pl.lua luajfm2pl.lua + texlua luajfm2pl.lua $*v-pl $@ + +%-v.pl: jfm-%v-pl.lua luajfm2pl.lua + texlua luajfm2pl.lua --noutf $*v-pl $@ + +u%.pl: jfm-%-pl.lua luajfm2pl.lua + texlua luajfm2pl.lua $*-pl $@ + +%.pl: jfm-%-pl.lua luajfm2pl.lua + texlua luajfm2pl.lua --noutf $*-pl $@ + +# .vf +u%g-q.vf: u%g-q.tfm + makejvf -i -u jisq $< upgbm-hq.tfm + +u%-q.vf: u%-q.tfm + makejvf -i -u jisq $< uprml-hq.tfm + +u%g-v.vf: u%g-v.tfm + makejvf -i -u custom -t ${MAKEJVFCNF} $< upgbm-v.tfm + +u%g.vf: u%g.tfm u%g-q.tfm + makejvf -i -u custom -t ${MAKEJVFCNF} -H -U u$*g-q $< upgbm-h.tfm + +%g-v.vf: %g-v.tfm + makejvf -i $< gbmv.tfm + +%g.vf: %g.tfm + makejvf -i $< gbm.tfm + +u%-v.vf: u%-v.tfm + makejvf -i -u custom -t ${MAKEJVFCNF} $< uprml-v.tfm + +%-v.vf: %-v.tfm + makejvf -i $< rmlv.tfm + +u%.vf: u%.tfm u%-q.tfm + makejvf -i -u custom -t ${MAKEJVFCNF} -H -U u$*-q $< uprml-h.tfm + +%.vf: %.tfm + makejvf -i $< rml.tfm + +# .tfm +u%-q.tfm: u%.pl + uppltotf -kanji=uptex $< $@ + +u%g-q.tfm: u%-q.tfm + cp $< $@ + +%g-v.tfm: %-v.tfm + cp $< $@ + +%g.tfm: %.tfm + cp $< $@ + +u%.tfm: u%.pl + uppltotf -kanji=uptex $< $@ + +%.tfm: %.pl + ppltotf -kanji=utf8 $< $@ + +jfm-jlreqv.lua jfm-jlreq-pl.lua jfm-bjlreq-pl.lua jfm-zjlreq-pl.lua jfm-bzjlreq-pl.lua jfm-jlreqv-pl.lua jfm-bjlreqv-pl.lua jfm-zjlreqv-pl.lua jfm-bzjlreqv-pl.lua: make_variant_jfm.lua jfm-jlreq.lua + texlua make_variant_jfm.lua + +doc: pdfdoc htmldoc + +latexdoc: jlreq.tex jlreq-ja.tex + +jlreq%tex: README%md README-template.tex + pandoc --verbose -f gfm -t latex --pdf-engine=lualatex --template README-template.tex $< -o $@ + +pdfdoc: jlreq.pdf jlreq-ja.pdf + +jlreq.pdf: README.md README-template.tex + sed -e "s/\\[README-ja.md\\](README-ja.md)/[jlreq-ja.pdf](jlreq-ja.pdf)/" README.md | pandoc --verbose -f gfm -t latex --pdf-engine=lualatex --template README-template.tex -o $@ + +jlreq-ja.pdf: README-ja.md README-template.tex + pandoc --verbose -f gfm -t latex --pdf-engine=lualatex --template README-template.tex $< -o $@ + +htmldoc: jlreq.html jlreq-ja.html jlreq-trimmarks.html jlreq-trimmarks-ja.html + +jlreq-ja.html: README-ja.md README-template.html + pandoc --verbose -f gfm -t html5 -V lang=ja -M title=jlreq --template README-template.html -o jlreq-ja.html README-ja.md + +jlreq.html: README.md README-template.html + sed -e "s/\\[README-ja.md\\](README-ja.md)/[jlreq-ja.html](jlreq-ja.html)/" README.md | pandoc --verbose -f gfm -t html5 -V lang=en -M title=jlreq --template README-template.html -o jlreq.html + +jlreq-trimmarks-ja.html: jlreq-trimmarks-ja.md README-template.html + pandoc --verbose -f gfm -t html5 -V lang=ja -M title=jlreq-trimmarks --template README-template.html -o jlreq-trimmarks-ja.html jlreq-trimmarks-ja.md + +jlreq-trimmarks.html: jlreq-trimmarks.md README-template.html + pandoc --verbose -f gfm -t html5 -V lang=en -M title=jlreq-trimmarks --template README-template.html -o jlreq-trimmarks.html jlreq-trimmarks.md + + +jfm-install: jfm + mkdir -p ${TEXMF}/fonts/tfm/public/jlreq + install *.tfm ${TEXMF}/fonts/tfm/public/jlreq + mkdir -p ${TEXMF}/fonts/vf/public/jlreq + install *.vf ${TEXMF}/fonts/vf/public/jlreq + mkdir -p ${TEXMF}/tex/luatex/jlreq + install jfm-jlreqv.lua jfm-jlreq.lua ${TEXMF}/tex/luatex/jlreq + +cls-install: + mkdir -p ${TEXMF}/tex/latex/jlreq + install jlreq-helpers.sty ${TEXMF}/tex/latex/jlreq + install jlreq.cls ${TEXMF}/tex/latex/jlreq + +sty-install: + mkdir -p ${TEXMF}/tex/latex/jlreq + install jlreq-trimmarks.sty ${TEXMF}/tex/latex/jlreq + +install: jfm-install cls-install sty-install + +tds: jfm jlreq.cls README.md README-ja.md LICENSE jlreq.html jlreq-ja.html jlreq-trimmarks.html jlreq-trimmarks-ja.html jlreq.pdf jlreq-ja.pdf jlreq-trimmarks.pdf jlreq-trimmarks-ja.pdf + mkdir -p ./tds/fonts/tfm/public/jlreq + cp -f *.tfm ./tds/fonts/tfm/public/jlreq + mkdir -p ./tds/fonts/vf/public/jlreq + cp -f *.vf ./tds/fonts/vf/public/jlreq + mkdir -p ./tds/tex/luatex/jlreq + cp jfm-jlreq.lua ./tds/tex/luatex/jlreq + cp jfm-jlreqv.lua ./tds/tex/luatex/jlreq + mkdir -p ./tds/tex/latex/jlreq + cp jlreq.cls ./tds/tex/latex/jlreq + cp jlreq-helpers.sty ./tds/tex/latex/jlreq + cp jlreq-trimmarks.sty ./tds/tex/latex/jlreq + mkdir -p ./tds/doc/latex/jlreq + cp README.md ./tds/doc/latex/jlreq + cp README-ja.md ./tds/doc/latex/jlreq + cp jlreq-trimmarks.md ./tds/doc/latex/jlreq + cp jlreq-trimmarks-ja.md ./tds/doc/latex/jlreq + cp LICENSE ./tds/doc/latex/jlreq + cp jlreq.html ./tds/doc/latex/jlreq + cp jlreq-ja.html ./tds/doc/latex/jlreq + cp jlreq-trimmarks.html ./tds/doc/latex/jlreq + cp jlreq-trimmarks-ja.html ./tds/doc/latex/jlreq + cp jlreq.pdf ./tds/doc/latex/jlreq + cp jlreq-ja.pdf ./tds/doc/latex/jlreq + mkdir -p ./tds/source/latex/jlreq + cp README-template.html ./tds/source/latex/jlreq + cp README-template.tex ./tds/source/latex/jlreq + cp Makefile ./tds/source/latex/jlreq + cp make_variant_jfm.lua ./tds/source/latex/jlreq + cp luajfm2pl.lua ./tds/source/latex/jlreq + +uninstall: + rm -rf ${TEXMF}/fonts/tfm/public/jlreq + rm -rf ${TEXMF}/fonts/vf/public/jlreq + rm -rf ${TEXMF}/tex/luatex/jlreq + rm -rf ${TEXMF}/tex/latex/jlreq + +jfmclean: + rm -f *jlreq*.tfm *jlreq*.pl *jlreq*.vf + rm -f jfm-jlreqv.lua + rm -f jfm-*jlreq*-pl.lua + +docclean: + rm -f jlreq.tex jlreq.pdf jlreq.html jlreq-ja.tex jlreq-ja.pdf jlreq-ja.html jlreq-trimmarks.html jlreq-trimmarks-ja.html + +clean: jfmclean docclean + + diff --git a/Master/texmf-dist/source/latex/jlreq/README-template.html b/Master/texmf-dist/source/latex/jlreq/README-template.html new file mode 100644 index 00000000000..ac39350120d --- /dev/null +++ b/Master/texmf-dist/source/latex/jlreq/README-template.html @@ -0,0 +1,94 @@ + + + + + + $title$ + + + +
+$body$ +
+ + diff --git a/Master/texmf-dist/source/latex/jlreq/README-template.tex b/Master/texmf-dist/source/latex/jlreq/README-template.tex new file mode 100644 index 00000000000..f8b87bf115f --- /dev/null +++ b/Master/texmf-dist/source/latex/jlreq/README-template.tex @@ -0,0 +1,68 @@ +\documentclass[paper=a4,fontsize=11pt,jafontscale=0.92,lualatex]{jlreq} +\usepackage[jfm_yoko=jlreq,jfm_tate=jlreqv,hiragino-pron,nfssonly]{luatexja-preset} +\usepackage[unicode=true]{hyperref} +\hypersetup{pdfborder={0 0 0},breaklinks=true,colorlinks=true,linkcolor=blue,urlcolor=blue} +\usepackage[T1]{fontenc} +\newcommand{\tightlist}{} +\setlength{\parindent}{0pt} +\IfFileExists{upquote.sty}{\usepackage{upquote}}{} +\renewcommand{\thesection}{} +\renewcommand{\thesubsection}{\arabic{subsection}} +\ModifyHeading{section}{font={\Huge\bfseries\sffamily},indent=0pt,after_label_space=0pt} +\ModifyHeading{paragraph}{indent=0pt} +% \ttfamilyを戻す +\makeatletter +\DeclareRobustCommand\ttfamily{\not@math@alphabet\ttfamily\mathtt\romanfamily\ttdefault\selectfont} +\makeatother +\ltjsetparameter{alxspmode={`\\,allow}} +\ltjsetparameter{alxspmode={`*,allow}} +\usepackage{xcolor} +\usepackage{fancyvrb} +\usepackage{tcolorbox} +\tcbuselibrary{skins} +\usepackage{moreverb} +\renewenvironment{verbatim}{\begingroup\tcbverbatimwrite{\jobname.tmp}} +{\endtcbverbatimwrite\endgroup +\begin{Shaded} +\verbatimtabinput{\jobname.tmp} +\end{Shaded} +} +\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} +\newtcolorbox{Shaded}{colframe=white,beforeafter skip=1\zw} +\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}} +\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{#1}} +\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}} +\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}} +\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}} +\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{#1}} +\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}} +\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}} +\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}} +\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}} +\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}} +\newcommand{\ImportTok}[1]{#1} +\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{#1}} +\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}} +\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{#1}}} +\newcommand{\CommentVarTok}[1]{\textcolor[HTML]{008000}{\textbf{#1}}} +\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{#1}} +\newcommand{\FunctionTok}[1]{\textcolor[HTML]{0040FF}{#1}} +\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}} +\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}} +\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}} +\newcommand{\BuiltInTok}[1]{\textcolor[HTML]{0040FF}{#1}} +\newcommand{\ExtensionTok}[1]{#1} +\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}} +\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}} +\newcommand{\RegionMarkerTok}[1]{#1} +\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}} +\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}} +\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}} +\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}} +\newcommand{\NormalTok}[1]{#1} + +%\setcounter{secnumdepth}{0} + +\begin{document} +$body$ +\end{document} diff --git a/Master/texmf-dist/source/latex/jlreq/luajfm2pl.lua b/Master/texmf-dist/source/latex/jlreq/luajfm2pl.lua new file mode 100644 index 00000000000..5aceea506de --- /dev/null +++ b/Master/texmf-dist/source/latex/jlreq/luajfm2pl.lua @@ -0,0 +1,342 @@ +kpse.set_program_name("texlua","lualatex") + +no_jis_chars = {'⦅','〘','〖','«','〝','⦆','〙','〗','»','〟','‼','⁇','⁈','⁉','〳','〴','〵','〻','ゕ','ゖ','ㇰ','ㇱ','ㇲ','ㇳ','ㇴ','ㇵ','ㇶ','ㇷ','ㇸ','ㇹ','ㇺ','ㇻ','ㇼ','ㇽ','ㇾ','ㇿ','ㇷ゚','€','№','㏋','ℓ','㌃','㌍','㌔','㌘','㌢','㌣','㌦','㌧','㌫','㌶','㌻','㍉','㍊','㍍','㍑','㍗','㎎','㎏','㎜','㎝','㎞','㎡','㏄','ゔ','か゚','き゚','く゚','け゚','こ゚','ヷ','ヸ','ヹ','ヺ','カ゚','キ゚','ク゚','ケ゚','コ゚','セ゚','ツ゚','ト゚','゠','–'} + +if arg[1] == nil then + print('Usage: texlua luajfm2pl.lua [--noutf] []') + os.exit(0) +end + +local luajfm +if arg[1] ~= "--noutf" then + no_jis_chars = {} + luajfm = arg[1] + outputfile = arg[2] +else + luajfm = arg[2] + outputfile = arg[3] +end + +local jfmfile = kpse.find_file("jfm-" .. luajfm .. ".lua") +if jfmfile == nil then + print("JFM " .. luajfm .. " is not found") + os.exit(1) +end + +--. JFMロード +jfm = nil +luatexja = {} +luatexja.jfont = {} + +function luatexja.jfont.define_jfm(j) + jfm = j +end + +dofile(jfmfile) + +local fp = nil +if outputfile == nil then + fp = io.stdout +else + local msg + fp,msg = io.open(outputfile,"w") + if fp == nil then + print(msg) + os.exit(1) + end +end + + +--. 関数群 +local function merge_sort(list,from,to,comp) + local tmplist = {} + if to - from > 1 then + local mid = math.floor((to + from)/2) + merge_sort(list,from,mid,comp) + merge_sort(list,mid+1,to,comp) + local left = from + local right = mid + 1 + local i = 1 + while left <= mid or right <= to do + if left > mid then + tmplist[i] = list[right] + right = right + 1 + elseif right > to then + tmplist[i] = list[left] + left = left + 1 + elseif comp(list[right],list[left]) == true then + tmplist[i] = list[right] + right = right + 1 + else + tmplist[i] = list[left] + left = left + 1 + end + i = i + 1 + end + for j = from,to do + list[j] = tmplist[j - from + 1] + end + elseif to - from == 1 then + if comp(list[to],list[from]) then + list[to],list[from] = list[from],list[to] + end + end + return list +end + +function stable_sort(list,comp) + if comp == nil then comp = function(a,b) return a < b end end + return merge_sort(list,1,#list,comp) +end + +local function array_uniq(t) + local n = 1 + for i = 1,#t do + local newone = true + for j = 1,n - 1 do + if t[i] == t[j] then + newone = false + break + end + end + if newone == true then + t[n] = t[i] + n = n + 1 + end + end + local m = #t + for i = n,m do table.remove(t) end + return t +end + +local function exists(t,v) + for _,val in pairs(t) do + if v == val then return true end + end + return false +end + + +local function isempty(t) return next(t) == nil end +local function isemptyornil(t) return t == nil or isempty(t) end + +--. JFMの改変 +-- デフォルト値の設定 +for cls,val in pairs(jfm) do + if type(cls) == "number" then + if val.width == nil then jfm[cls].width = 1 end + if val.height == nil then + if jfm.dir == 'tate' then jfm[cls].height = 0.5 + else jfm[cls].height = 0.88 end + end + if val.depth == nil then + if jfm.dir == 'tate' then jfm[cls].depth = 0.5 + else jfm[cls].depth = 0.12 end + end + if val.italic == nil then jfm[cls].italic = 0 end + end +end + +-- charsを書き出す文字列に変換しておく. +local no_jis_chars_hash = {} +for _,c in ipairs(no_jis_chars) do no_jis_chars_hash[c] = true end + +alcharclass = nil +noxalcharclass = nil + +for class,val in pairs(jfm) do + if type(class) ~= "number" or class == 0 then goto continue end + local chars = {} + for _,c in ipairs(val.chars) do + local ac = nil + -- 'alchar'や'nox_alchar'が入っているクラスを記憶 + if c == 'alchar' then alcharclass = class + elseif c == 'nox_alchar' then noxalcharclass = class + elseif unicode.utf8.len(c) == 1 then ac = c + elseif unicode.utf8.len(c) == 2 then + local cs = {} + for _,cc in string.utfcharacters(c) do + table.insert(cs,cc) + end + if cs[2] == "*" then ac = cs[1] end + end + if no_jis_chars_hash[ac] ~= true then table.insert(chars,ac) end + end + chars = array_uniq(chars) + -- charsが空になった場合は消しておく + if class ~= alcharclass and class ~= noxalcharclass and isempty(chars) == true then + io.stderr:write("Class " .. class .. " has no char, so we omit it\n") + jfm[class] = nil + else jfm[class].chars = table.concat(chars," ") end + ::continue:: +end + + +if alcharclass == noxalcharclass then noxalcharclass = nil end +for _,class in ipairs({alcharclass,noxalcharclass}) do + if class ~= nil then + if jfm[class].chars == "" then + io.stderr:write("Class " .. class .. " has only Alchar, so we omit it\n") + jfm[class] = nil + end + end +end + + +-- 存在しないクラスに対するglue/kernは消す +for _,gluekern in ipairs({"glue","kern"}) do + for class,val in pairs(jfm) do + if type(class) == "number" and val[gluekern] ~= nil then + for target,_ in pairs(val[gluekern]) do + if jfm[target] == nil then + io.stderr:write("Class " .. tostring(target) .. " does not exist, the corresponding " .. gluekern .. " in Class " .. tostring(class) .. " is omitted\n") + jfm[class][gluekern][target] = nil + end + end + end + end +end + +-- glueやkernが同じ挙動であるか調べる +function isthesamespace(gluekern,clses,c1,c2) + return isthesamespace_before(gluekern,c1,c2) and isthesamespace_after(gluekern,clses,c1,c2) +end +-- c1,c2を前とするグルーが同じか. +function isthesamespace_before(gluekern,c1,c2) + -- 片方がnilの場合 + if jfm[c1][gluekern] == jfm[c2][gluekern] then return true end + if jfm[c1][gluekern] == nil or jfm[c2][gluekern] == nil then return false end + --この段階で両方tableなはず + local targetclses = {} -- c1とc2のglueやkernのunion + for c,_ in pairs(jfm[c1][gluekern]) do table.insert(targetclses,c) end + for c,_ in pairs(jfm[c2][gluekern]) do table.insert(targetclses,c) end + targetclses = array_uniq(targetclses) + for _,chk in ipairs(targetclses) do + if jfm[c1][gluekern][chk] == jfm[c2][gluekern][chk] then goto continue end + if jfm[c1][gluekern][chk] == nil or jfm[c2][gluekern][chk] == nil then return false end + if type(jfm[c1][gluekern][chk]) == "number" or type(jfm[c2][gluekern][chk]) == "number" then return false end + if jfm[c1][gluekern][chk][1] ~= jfm[c2][gluekern][chk][1] then return false end + if gluekern == "glue" then + if jfm[c1][gluekern][chk][2] ~= jfm[c2][gluekern][chk][2] or jfm[c1][gluekern][chk][3] ~= jfm[c2][gluekern][chk][3] then return false end + end + ::continue:: + end + return true +end + +function isthesamespace_after(gluekern,clses,c1,c2) + for _,c in pairs(clses) do + if jfm[c][gluekern] == nil then goto continue end + if jfm[c][gluekern][c1] == jfm[c][gluekern][c2] then goto continue end + if jfm[c][gluekern][c1] == nil or jfm[c][gluekern][c2] == nil then return false end + if type(jfm[c][gluekern][c1]) == "number" or type(jfm[c][gluekern][c2]) == "number" then return false end + if jfm[c][gluekern][c1][1] ~= jfm[c][gluekern][c2][1] then return false end + if kernglue == "glue" then + if jfm[c][gluekern][c1][2] ~= jfm[c][gluekern][c2][2] or jfm[c][gluekern][c1][3] ~= jfm[c][gluekern][c2][3] then return false end + end + ::continue:: + end + return true +end + +-- 同じ挙動を示すクラスをまとめる +local classes = {} +for k,_ in pairs(jfm) do if type(k) == "number" then table.insert(classes,k) end end +classes = stable_sort(classes) +for _,from in pairs(classes) do + for index,to in pairs(classes) do + if to <= from or to == 0 or from == 0 then goto continue end + if jfm[from].width ~= jfm[to].width or jfm[from].height ~= jfm[to].height or jfm[from].depth ~= jfm[to].depth or jfm[from].italic ~= jfm[to].italic then goto continue end + if isthesamespace("glue",classes,from,to) and isthesamespace("kern",classes,from,to) then + io.stderr:write("Class " .. tostring(to) .. " is merged to Class " .. tostring(from) .. "\n") + jfm[from].chars = jfm[from].chars .. " " .. jfm[to].chars + jfm[to] = nil + classes[index] = nil + for _,cls in pairs(classes) do + if jfm[cls].glue ~= nil then jfm[cls].glue[to] = nil end + if jfm[cls].kern ~= nil then jfm[cls].kern[to] = nil end + end + end + ::continue:: + end +end + +-- 番号を連続的にする. +-- classmaptable[JFM内クラス番号] = JPL内クラス番号 +classes = {} +for k,_ in pairs(jfm) do if type(k) == "number" then table.insert(classes,k) end end +classes = stable_sort(classes) +local classmaptable = {} +local jplclass = 1 +for _,class in ipairs(classes) do + if type(class) == "number" then + if class == 0 then classmaptable[class] = 0 + else + if class ~= jplclass then + io.stderr:write("Class " .. tostring(class) .. " is mapped to Class " .. tostring(jplclass) .. "\n") + end + classmaptable[class] = jplclass + jplclass = jplclass + 1 + end + end +end + + +fp:write("(COMMENT JPL file from jfm-" .. luajfm .. ".lua)\n") +fp:write("(CODINGSCHEME TEX KANJI TEXT)\n") +fp:write("(DIRECTION " .. string.upper(jfm.dir) .. ")\n") +-- fp:write("(DESIGNSIZE R 10.0)\n") +fp:write("(FONTDIMEN \n") +fp:write(" (SLANT R 0.0)\n") +fp:write(" (SPACE R " .. tostring(jfm.kanjiskip[1]) .. ")\n") +fp:write(" (STRETCH R " .. tostring(jfm.kanjiskip[2]) .. ")\n") +fp:write(" (SHRINK R " .. tostring(jfm.kanjiskip[3]) .. ")\n") +fp:write(" (XHEIGHT R " .. tostring(jfm.zh) .. ")\n") +fp:write(" (QUAD R " .. tostring(jfm.zw) .. ")\n") +fp:write(" (EXTRASPACE R " .. tostring(jfm.xkanjiskip[1]) .. ")\n") +-- 下二つはFONTDIMENの下で良いのかな? +fp:write(" (EXTRASTRETCH R " .. tostring(jfm.xkanjiskip[2]) .. ")\n") +fp:write(" (EXTRASHRINK R " .. tostring(jfm.xkanjiskip[3]) .. ")\n") +fp:write(")\n") + +classes = {} +for k,_ in pairs(jfm) do if type(k) == "number" then table.insert(classes,k) end end +classes = stable_sort(classes,function(a,b) return classmaptable[a] < classmaptable[b] end) + +for _,class in ipairs(classes) do + if class ~= 0 then + fp:write("(CHARSINTYPE D " .. tostring(classmaptable[class]) .. "\n " .. jfm[class].chars .. "\n)\n") + end + fp:write("(TYPE D " .. tostring(classmaptable[class]) .. "\n") + fp:write(" (CHARWD R " .. tostring(jfm[class].width) .. ")\n") + fp:write(" (CHARHT R " .. tostring(jfm[class].height) .. ")\n") + fp:write(" (CHARDP R " .. tostring(jfm[class].depth) .. ")\n") + fp:write(" (CHARIC R " .. tostring(jfm[class].italic) .. ")\n") + fp:write(")\n") + ::continue:: +end + +fp:write("(GLUEKERN\n") +for _,class in ipairs(classes) do + if (jfm[class].glue == nil or isempty(jfm[class].glue) == true) and (jfm[class].kern == nil or (type(jfm[class].kern) == "table" and isempty(jfm[class].kern) == true)) then goto continue end + fp:write(" (LABEL D " .. tostring(classmaptable[class]) .. ")\n") + if jfm[class].glue ~= nil then + for _,targetcls in ipairs(classes) do + if jfm[class].glue[targetcls] ~= nil then + fp:write(" (GLUE D " .. tostring(classmaptable[targetcls]) .. " R " .. tostring(jfm[class].glue[targetcls][1]) .. " R " .. tostring(jfm[class].glue[targetcls][2]) .. " R " .. tostring(jfm[class].glue[targetcls][3]) .. ")\n") + end + end + end + if jfm[class].kern ~= nil then + for _,targetcls in ipairs(classes) do + if jfm[class].kern[targetcls] ~= nil then + fp:write(" (KRN D " .. tostring(classmaptable[targetcls]) .. " R ") + if type(kernval) == "number" then fp:write(tostring(jfm[class],kern[targetcls]) .. ")\n") + else fp:write(tostring(jfm[class].kern[targetcls][1]) .. ")\n") end + end + end + end + fp:write(" (STOP)\n") + ::continue:: +end +fp:write(")\n") diff --git a/Master/texmf-dist/source/latex/jlreq/make_variant_jfm.lua b/Master/texmf-dist/source/latex/jlreq/make_variant_jfm.lua new file mode 100644 index 00000000000..e91e85cc338 --- /dev/null +++ b/Master/texmf-dist/source/latex/jlreq/make_variant_jfm.lua @@ -0,0 +1,177 @@ +kpse.set_program_name("texlua","lualatex") +require('lualibs') + +function burasage(t) + t = table.fastcopy(t) + -- 句読点の幅を0にして,句読点に続くglueを句読点の幅だけ増やす. + for _,class in ipairs({6,7}) do + local width = t[class].width + t[class].width = 0 + -- 句読点を前とするJFMはすべて定義されていることを仮定. + if t[class].glue ~= nil then + for key,_ in pairs(t[class].glue) do + t[class].glue[key][1] = t[class].glue[key][1] + width + end + end + if t[class].kern ~= nil then + for key,val in pairs(t[class].kern) do + if type(val) == "table" then + t[class].glue[key][1] = t[class].glue[key][1] + width + else + t[class].glue[key] = t[class].glue[key] + width + end + end + end + end + return t +end + +function zenkaku_kakko(t) + t = table.fastcopy(t) + -- 開き括弧のwidthを0.5増やす + t[1].width = t[1].width + 0.5 + for cls,val in pairs(t) do + if type(cls) ~= "number" then goto continue end + if t[cls].glue ~= nil and t[cls].glue[1] ~= nil then + t[cls].glue[1][1] = t[cls].glue[1][1] - 0.5 + end + if t[cls].kern ~= nil and t[cls].kern[1] ~= nil then + if type(t[cls].kern[1]) == "table" then + t[cls].kern[1][1] = t[cls].kern[1][1] - 0.5 + else + t[cls].kern[1] = t[cls].kern[1] - 0.5 + end + end + ::continue:: + end + return t +end + +function tate(t) + t = table.fastcopy(t) + t.dir = 'tate' + for key,_ in pairs(t) do + if type(key) == "number" then + t[key].height = 0.5 + t[key].depth = 0.5 + end + end + return t +end + +function to_pl(t) + t = table.fastcopy(t) + -- 空きの第四段階は消す + for cl1,val in pairs(t) do + if type(cl1) == "number" then + for cl2,glue in pairs(val.glue) do + if glue.priority ~= nil and glue.priority[1] < 0 then + t[cl1].glue[cl2][2] = 0 + end + end + end + end + -- LuaTeX-jaのJFMではalcharが使えることに由来する補正 + t[4].glue[0] = nil + return t +end + +-- jfmのテーブル,ファイル名 +function make_jfmfile(t,f) + table.tofile(f,t,"local jfm") + local fp = io.open(f,"a") + fp:write("luatexja.jfont.define_jfm(jfm)\n") + fp:close() +end + +function tolf(file) + local fp = io.open(file,"r") + local s = ""; + for l in fp:lines() do + s = s .. l .. "\n"; + end + fp:close(); + fp = io.open(file,"wb") + fp:write(s); + fp:close(); +end + +local originaljfm = "jlreq" + +local jfmfile = kpse.find_file("jfm-" .. originaljfm .. ".lua") +if jfmfile == nil then + print("JFM " .. originaljfm .. " is not found") + os.exit(1) +end + +jfm = nil +luatexja = {} +luatexja.jfont = {} + +function luatexja.jfont.define_jfm(j) + jfm = j +end + +dofile(jfmfile) + +make_jfmfile(to_pl(jfm),"jfm-" .. originaljfm .. "-pl.lua") +make_jfmfile(to_pl(burasage(jfm)),"jfm-b" .. originaljfm .. "-pl.lua") +make_jfmfile(to_pl(zenkaku_kakko(jfm)),"jfm-z" .. originaljfm .. "-pl.lua") +make_jfmfile(to_pl(burasage(zenkaku_kakko(jfm))),"jfm-bz" .. originaljfm .. "-pl.lua") +make_jfmfile(to_pl(tate(jfm)),"jfm-" .. originaljfm .. "v-pl.lua") +make_jfmfile(to_pl(burasage(tate(jfm))),"jfm-b" .. originaljfm .. "v-pl.lua") +make_jfmfile(to_pl(zenkaku_kakko(tate(jfm))),"jfm-z" .. originaljfm .. "v-pl.lua") +make_jfmfile(to_pl(burasage(zenkaku_kakko(tate(jfm)))),"jfm-bz" .. originaljfm .. "v-pl.lua") + +local jfm = tate(jfm) +local file = "jfm-" .. originaljfm .. "v.lua" +table.tofile(file,jfm,"local jfm") +local fp = io.open(file,"a") +fp:write([[ +local function add_space(before,after,glueorkern,space,ratio) + if jfm[before][glueorkern] == nil then jfm[before][glueorkern] = {} end + if jfm[before][glueorkern][after] == nil then jfm[before][glueorkern][after] = {0} end + local origratio = jfm[before][glueorkern][after].ratio + if origratio == nil then origratio = 0.5 end + jfm[before][glueorkern][after].ratio = (jfm[before][glueorkern][after][1] * origratio + space * ratio) / (jfm[before][glueorkern][after][1] + ratio) + jfm[before][glueorkern][after][1] = jfm[before][glueorkern][after][1] + space +end + +if jlreq ~= nil then + if type(jlreq.open_bracket_pos) == "string" then + local r = jlreq.open_bracket_pos:find("_") + local danraku = jlreq.open_bracket_pos:sub(1,r - 1) + local orikaeshi = jlreq.open_bracket_pos:sub(r + 1) + + -- 折り返し行頭の開き括弧を二分下げる……つもり + if orikaeshi == "nibu" then + -- widthを二分増やし,その代わりJFMグルーを二分減らす + jfm[1].width = jfm[1].width + 0.5 + for k,v in pairs(jfm) do + if type(k) == "number" then + add_space(k,1,"glue",-0.5,1) + end + end + end + + -- 段落行頭の下げ + if danraku == "zenkakunibu" then + add_space(90,1,"glue",0.5,1) + elseif danraku == "nibu" then + add_space(90,1,"glue",-0.5,1) + end + end + + -- ぶら下げ組を有効にする. + if jlreq.burasage == true then + for _,class in ipairs({6,7}) do + table.insert(jfm[class].end_adjust,-0.5) + end + end +end +luatexja.jfont.define_jfm(jfm) +]]) +fp:close() + +tolf(file); + -- cgit v1.2.3