Skip to content

Commit

Permalink
Merge branch 'ctex-uptex'
Browse files Browse the repository at this point in the history
update #159
  • Loading branch information
leo-liu committed Apr 25, 2016
2 parents 8bc54f2 + ee0818d commit 1fb82d4
Show file tree
Hide file tree
Showing 9 changed files with 1,011 additions and 129 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.aux
*.dmp
*.dvi
*.fd
*.glo
*.gls
Expand All @@ -8,6 +9,7 @@
*.ilg
*.ind
*.ins
*.log
*.out
*.swp
*.synctex.gz
Expand Down Expand Up @@ -138,6 +140,13 @@ zhmetrics/zhmCJK.sty
zhmetrics/zhmCJK-test.pdf
zhmetrics/zhmCJK-test.tex

# zhmetrics-uptex
zhmetrics-uptex/*.tfm
zhmetrics-uptex/*.vf
zhmetrics-uptex/*.pdf
zhmetrics-uptex/ctan/*
zhmetrics-uptex/tds/*

# zhnumber

zhnumber/build/
Expand Down
565 changes: 436 additions & 129 deletions ctex/ctex.dtx

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions zhmetrics-uptex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
zhmetrics-uptex
===============================================

**2016/04/23 Ver 1.0**

The `zhmetrics-uptex` package contains some Chinese font metrics (JFM, VF, etc) for upTeX engine, together with a simple DVIPDFMx font mapping of Fandol fonts for DVIPDFMx.

The font mapping can be loaded in the TeX source file, or changed in the document to use other fonts.

Files
-----

* `upzh*-{h,v}.tfm` are the JFM files used by upTeX.
* `upzh*-{h,v}.vf` are the virtual fonts used by the output driver (dvipdfmx).
* `up*-{h,v}.tfm` are the PS TFM files used by the output driver.
* `upzhfandolfonts.tex` contains the font mappings of Fandol fonts for DVIPDFMx.
* `upzhfandolfonts-test.tex` is a small LaTeX test file.
* `upzhm-{h,v}.pl` are the JPL source files used to produce JFM files.
* `makemetrics.lua` is the build script.

Build
-----

To create the metric files, just run:
```shell
texlua makemetrics.lua
```
in the source directory.

Contributing
------------

This font package is a part of the [ctex-kit](https://github.com/CTeX-org/ctex-kit) project.

Issues and pull requests are welcome.

Copyright and Licence
---------------------

Copyright (C) 2016 by Leo Liu <[email protected]>

This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version. The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status `maintained'.

The Current Maintainer of this work is Leo Liu.

This work consists of the files
makemetrics.lua
upzhm-{h,v}.pl
upzhfandolfonts.tex
upzhfandolfongs-test.tex
README.md
and the derived files
upzhserif-{h,v}.tfm
upzhserifit-{h,v}.tfm
upzhserifb-{h,v}.tfm
upzhsans-{h,v}.tfm
upzhsnasb-{h,v}.tfm
upzhmono-{h,v}.tfm
upzhserif-{h,v}.vf
upzhserifit-{h,v}.vf
upzhserifb-{h,v}.vf
upzhsans-{h,v}.vf
upzhsnasb-{h,v}.vf
upzhmono-{h,v}.vf
upserif-{h,v}.tfm
upserifit-{h,v}.tfm
upserifb-{h,v}.tfm
upsans-{h,v}.tfm
upsnasb-{h,v}.tfm
upmono-{h,v}.tfm
144 changes: 144 additions & 0 deletions zhmetrics-uptex/build.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/usr/bin/env texlua

-- zhmetrics-uptex v1.0
-- Copyright (C) 2016 by Leo Liu <[email protected]>

local fonts = {'serif', 'serifit', 'serifb', 'sans', 'sansb', 'mono'}

function copyfile(path_src, path_dst)
local cp = 'cp -f'
if os.type == 'windows' then
cp = 'copy /y'
path_src = path_src:gsub('/', '\\')
path_dst = path_dst:gsub('/', '\\')
end
os.execute(cp .. ' ' .. path_src .. ' ' .. path_dst)
end

function move(path_src, path_dst)
local mv = 'mv -f'
if os.type == 'windows' then
mv = 'move /y'
path_src = path_src:gsub('/', '\\')
path_dst = path_dst:gsub('/', '\\')
end
os.execute(mv .. ' ' .. path_src .. ' ' .. path_dst)
end

function mkdir(dir)
if lfs.attributes(dir) ~= nil then
do return end
end
local md = 'mkdir -p'
if os.type == 'windows' then
md = 'mkdir'
dir = dir:gsub('/', '\\')
end
os.execute(md .. ' ' .. dir)
end

function rmdir(dir)
if lfs.attributes(dir) == nil then
do return end
end
local rd = 'rm -r -f'
if os.type == windows then
rd = 'rmdir /s /q'
dir = dir:gsub('/', '\\')
end
os.execute(rd .. ' ' .. dir)
end

function packfiles(zipname, workdir, tfmdir, vfdir, texdir, sourcedir, docdir)
mkdir(tfmdir)
mkdir(vfdir)
mkdir(texdir)
mkdir(sourcedir)
mkdir(docdir)
for _, hv in pairs({'h', 'v'}) do
for _, fnt in pairs(fonts) do
local jfm = string.format('upzh%s-%s.tfm', fnt, hv)
local vf = string.format('upzh%s-%s.vf', fnt, hv)
local pstfm = string.format('up%s-%s.tfm', fnt, hv)
copyfile(jfm, tfmdir .. '/')
copyfile(pstfm, tfmdir .. '/')
copyfile(vf, vfdir .. '/')
end
local pl = string.format('upzhm-%s.pl', hv)
copyfile(pl, sourcedir .. '/')
end
copyfile('makemetrics.lua', sourcedir .. '/')
copyfile('upzhfandolfonts.tex', texdir .. '/')
copyfile('README.md', docdir .. '/')
copyfile('upzhfandolfonts-test.tex', docdir .. '/')
copyfile('upzhfandolfonts-test.pdf', docdir .. '/')
local tdszipname = 'zhmetrics-uptex.tds.zip'
if lfs.attributes(zipname) then
os.remove(zipname)
end
local curdir = lfs.currentdir()
lfs.chdir(workdir)
os.execute('zip -r ' .. curdir .. '/' .. zipname .. ' *')
lfs.chdir(curdir)
end

function tds()
packfiles('zhmetrics-uptex.tds.zip', 'tds',
'tds/fonts/tfm/zhmetrics-uptex',
'tds/fonts/vf/zhmetrics-uptex',
'tds/tex/uptex/zhmetrics-uptex',
'tds/source/fonts/zhmetrics-uptex',
'tds/doc/fonts/zhmetrics-uptex')
end

function ctan()
packfiles('zhmetrics-uptex.zip', 'ctan',
'ctan/tfm',
'ctan/vf',
'ctan/tex',
'ctan/source',
'ctan/doc')
copyfile('README.md', 'ctan/')
os.execute('zip zhmetrics-uptex.zip README.md')
end

function clean()
for _, hv in pairs({'h', 'v'}) do
for _, fnt in pairs(fonts) do
local jfm = string.format('upzh%s-%s.tfm', fnt, hv)
local vf = string.format('upzh%s-%s.vf', fnt, hv)
local pstfm = string.format('up%s-%s.tfm', fnt, hv)
os.remove(jfm)
os.remove(vf)
os.remove(pstfm)
end
end
rmdir('tds')
rmdir('ctan')
end

function main(target)
local unpack = function()
dofile('makemetrics.lua')
os.execute('uplatex upzhfandolfonts-test')
os.execute('dvipdfmx upzhfandolfonts-test')
for _, suf in pairs({'.aux', '.log', '.dvi'}) do
os.remove('upzhfandolfonts-test' .. suf)
end
end
if target == 'unpack' then
unpack()
elseif target == 'tds' then
unpack()
tds()
elseif target == 'ctan' then
unpack()
ctan()
elseif target == 'clean' then
clean()
else
print('Usage: ' .. arg[0] .. ' [unpack|tds|ctan|clean]')
end
end

main(arg[1])
19 changes: 19 additions & 0 deletions zhmetrics-uptex/makemetrics.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env texlua

-- zhmetrics-uptex v1.0
-- Copyright (C) 2016 by Leo Liu <[email protected]>

local fonts = {'serif', 'serifit', 'serifb', 'sans', 'sansb', 'mono'}
local pltopf = 'uppltotf -kanji=uptex'
local makejvf = 'makejvf -i -u gb'

for _, hv in pairs({'h', 'v'}) do
for _, fnt in pairs(fonts) do
local pl = string.format('upzhm-%s.pl', hv)
local jfm = string.format('upzh%s-%s.tfm', fnt, hv)
local vf = string.format('upzh%s-%s.vf', fnt, hv)
local pstfm = string.format('up%s-%s.tfm', fnt, hv)
os.execute(string.format('%s %s %s', pltopf, pl, jfm))
os.execute(string.format('%s %s %s', makejvf, jfm, pstfm))
end
end
42 changes: 42 additions & 0 deletions zhmetrics-uptex/upzhfandolfonts-test.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
\documentclass{article}

\usepackage[dvipdfm,a5paper,margin=1in]{geometry}
\newcommand\vertical{%
\clearpage
\newgeometry{width=\textheight,height=\textwidth,left=1in,top=1in}%
\tate}

\font\rm=upzhserif-h
\font\it=upzhserifit-h
\font\bf=upzhserifb-h
\font\sf=upzhsans-h
\font\sfbf=upzhsansb-h
\font\tt=upzhmono-h
\font\vrm=upzhserif-v
\font\vit=upzhserifit-v
\font\vbf=upzhserifb-v
\font\vsf=upzhsans-v
\font\vsfbf=upzhsansb-v
\font\vtt=upzhmono-v

\AtBeginDvi{\input{upzhfandolfonts}}

\begin{document}

\makeatletter
\@for\fnt:=\rm,\it,\bf,\sf,\sfbf,\tt \do{%
{\fnt
庄子曰:“吾生也有涯,而知也无涯。以有涯随无涯,殆已!已而为知者,殆而已矣!
为善无近名,为恶无近刑,缘督以为经,可以保身,可以全生,可以养亲,可以尽年。”
\par}
}

\vertical

\@for\fnt:=\vrm,\vit,\vbf,\vsf,\vsfbf,\vtt \do{%
{\fnt
庄子曰:「吾生也有涯,而知也无涯。以有涯随无涯,殆已!已而为知者,殆而已矣!
为善无近名,为恶无近刑,缘督以为经,可以保身,可以全生,可以养亲,可以尽年。」
\par}
}
\end{document}
17 changes: 17 additions & 0 deletions zhmetrics-uptex/upzhfandolfonts.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
% Fandol font mapping for dvipdfmx

\special{pdf:mapline upserif-h UniGB-UTF16-H FandolSong-Regular.otf}
\special{pdf:mapline upserifit-h UniGB-UTF16-H FandolKai-Regular.otf}
\special{pdf:mapline upserifb-h UniGB-UTF16-H FandolSong-Bold.otf}
\special{pdf:mapline upsans-h UniGB-UTF16-H FandolHei-Regular.otf}
\special{pdf:mapline upsansb-h UniGB-UTF16-H FandolHei-Bold.otf}
\special{pdf:mapline upmono-h UniGB-UTF16-H FandolFang-Regular.otf}

\special{pdf:mapline upserif-v UniGB-UTF16-V FandolSong-Regular.otf}
\special{pdf:mapline upserifit-v UniGB-UTF16-V FandolKai-Regular.otf}
\special{pdf:mapline upserifb-v UniGB-UTF16-V FandolSong-Bold.otf}
\special{pdf:mapline upsans-v UniGB-UTF16-V FandolHei-Regular.otf}
\special{pdf:mapline upsansb-v UniGB-UTF16-V FandolHei-Bold.otf}
\special{pdf:mapline upmono-v UniGB-UTF16-V FandolFang-Regular.otf}

\endinput
Loading

0 comments on commit 1fb82d4

Please sign in to comment.