diff options
author | Karl Berry <karl@freefriends.org> | 2017-09-21 20:59:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-09-21 20:59:31 +0000 |
commit | dea0a0ba1bb1f2ed8c60eb01add2c19c054a2c2f (patch) | |
tree | ad4bc5c8a3f140079c9d50343ad88d32ea0b1b1e /Master/texmf-dist/tex/latex | |
parent | 46c69c97cfe4829801dd8009189eb3b1f56176a3 (diff) |
spark-otf (21sep17)
git-svn-id: svn://tug.org/texlive/trunk@45372 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/spark-otf/spark-otf.sty | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/spark-otf/spark-otf.sty b/Master/texmf-dist/tex/latex/spark-otf/spark-otf.sty new file mode 100644 index 00000000000..4b05b9d668e --- /dev/null +++ b/Master/texmf-dist/tex/latex/spark-otf/spark-otf.sty @@ -0,0 +1,101 @@ +%% $Id: spark-otf.sty 565 2017-09-20 08:23:06Z herbert $ +%% +%% This file is distributed under the terms of the LaTeX Project Public +%% License from CTAN archives in directory macros/latex/base/lppl.txt. +%% Either version 1.3 or, at your option, any later version. +%% +% Copyright 2017 Herbert Voss hvoss@tug.org +%% +\def\spark@version{0.02} +\ProvidesPackage{spark-otf}[% + 2017/09/21 v. \spark@version~(Herbert Voss) Supports spark OpenType for lualatex/xelatex.] +% +\RequirePackage{ifxetex,ifluatex,xkeyval} +% +\newif\ifspark@usefilenames \spark@usefilenamesfalse +\DeclareOptionX{usefilenames}[true]{\@nameuse{spark@usefilenames#1}} +% +\providecommand\spark@DefaultFeatures{} +\DeclareOptionX{DefaultFeatures}{\def\spark@DefaultFeatures{#1}} + +\ProcessOptionsX\relax + +\ifxetex\else\ifluatex\else + \@latex@error{This package can only be used with "XeLaTeX" or "LuaLaTeX"!% + \MessageBreak "pdfLaTeX" or any other "TeX" version are _not_ possible!}% +\fi\fi +\RequirePackage{fontspec,xparse} + +\ifluatex\RequirePackage{luacode}\fi + +\ifspark@usefilenames + \typeout {Using file names for the spark font}% +%----------------------------------------- file names ---------------------------- + \newfontfamily\sparkBarMedium{{Spark - Bar - Medium}}[RawFeature=+calt,\spark@DefaultFeatures] + \newfontfamily\sparkBarNarrow{{Spark - Bar - Narrow}}[RawFeature=+calt,\spark@DefaultFeatures] + \newfontfamily\sparkBarThin{{Spark - Bar - Thin}}[RawFeature=+calt,\spark@DefaultFeatures] +% + \newfontfamily\sparkDotLine{{Spark - Dot-line - Medium}}[RawFeature=+calt,\spark@DefaultFeatures] +% + \newfontfamily\sparkDotMedium{{Spark - Dot - Medium}}[RawFeature=+calt,\spark@DefaultFeatures] + \newfontfamily\sparkDotSmall{{Spark - Dot - Small}}[RawFeature=+calt,\spark@DefaultFeatures] +%Spark - Bar - Medium.otf Spark - Bar - Thin.otf Spark - Dot - Medium.otf +%Spark - Bar - Narrow.otf Spark - Dot-line - Medium.otf Spark - Dot - Small.otf + +\else + \typeout {Using symbolic names for the spark font}% +%----------------------------------------- symbolic names ---------------------------- + \newfontfamily\sparkBarMedium{SparkBar-Medium}[RawFeature=+calt,\spark@DefaultFeatures] + \newfontfamily\sparkBarNarrow{SparkBar-Narrow}[RawFeature=+calt,\spark@DefaultFeatures] + \newfontfamily\sparkBarThin{SparkBar-Thin}[RawFeature=+calt,\spark@DefaultFeatures] +% + \newfontfamily\sparkDotLine{Spark-Dot-lineMedium}[RawFeature=+calt,\spark@DefaultFeatures] +% + \newfontfamily\sparkDotMedium{Spark-DotMedium}[RawFeature=+calt,\spark@DefaultFeatures] + \newfontfamily\sparkDotSmall{Spark-DotSmall}[RawFeature=+calt,\spark@DefaultFeatures] +\fi +% +\ifluatex +\begin{luacode} +function RelativeValues(v,m) + local Values = {} + for k,x in ipairs(v) do + Values[k] = x + end + table.sort(Values) + local MaxVal = (Values[#Values]) + for k,x in ipairs(v) do + Values[k] = math.floor(x/MaxVal*m) + end + for i,k in ipairs(Values) do + tex.sprint(k) + if (i < #Values) then tex.sprint(",") end + end +end +\end{luacode} +\def\spark@line{Line} + \NewDocumentCommand\sparkBar{sO{Medium}O{}mO{}}{{% + \IfValueTF{#1}% + {\edef\spark@values{\directlua{RelativeValues({#4},99)}}}% + {\def\spark@values{#4}}% + \@nameuse{sparkBar#2}#3\string{\spark@values\string}#5% + }} + \NewDocumentCommand\sparkDot{sO{Medium}O{}mO{}}{{% + \IfValueTF{#1}% + {\def\spark@arg{#2}% + \ifx\spark@line\spark@arg \edef\spark@values{\directlua{RelativeValues({#4},9)}}% + \else \edef\spark@values{\directlua{RelativeValues({#4},99)}}% + \fi}% + {\def\spark@values{#4}}% + \@nameuse{sparkDot#2}#3\string{\spark@values\string}#5% + }} +\else %% XeLaTeX + \NewDocumentCommand\sparkBar{O{Medium}O{}mO{}}{{% + \@nameuse{sparkBar#1}#2\string{#3\string}#4% + }} + \NewDocumentCommand\sparkDot{O{Medium}O{}mO{}}{{% + \@nameuse{sparkDot#1}#2\string{#3\string}#4% + }} +\fi +%% +\endinput |