cccb-formulare/fonttest.tex

61 lines
1.9 KiB
TeX
Raw Permalink Normal View History

2024-11-18 04:37:59 +01:00
\documentclass[a4paper,12pt]{scrartcl}
\usepackage{luacode}
\usepackage{fontspec}
\usepackage{xcolor}
\begin{document}
\setmainfont{Recursive}[
Renderer=HarfBuzz,
ItalicFont=Recursive,
BoldFont=Recursive,
BoldItalicFont=Recursive,
UprightFeatures={
RawFeature={+ss01,+ss02,+ss08,+case},
},
BoldFeatures={RawFeature={+axis={wght=700}}},
BoldItalicFeatures={RawFeature={+axis={wght=700,slnt=-15,CRSV=1}}},
ItalicFeatures={RawFeature={+axis={slnt=-15,CRSV=1}}}
]
\begin{luacode*}
local vft =
[[\addfontfeatures{RawFeature={+axis={MONO=%.2f,CASL=%.2f,slnt=%.2f,CRSV=%d,wght=%.0f}}}]]
function vf( MONO, CASL, slnt, CRSV, wght )
local s = vft:format( MONO, CASL, slnt, CRSV, wght )
return s
end
local N, buf = 3, { }
function c( v )
if type( v ) == "number" then return { v, v } end
if not v[2] then v[2] = v[1] end
return v
end
function lerp( MONO, CASL, slnt, CRSV, wght, C,M,Y,J,F )
F = F or 1
local B = { c(MONO), c(CASL), c(slnt), c(CRSV), c(wght) }
local color = { C,M,Y }
local params = { }
for k = 0, N do
local t = k/N
color[J] = (F<0) and (1+(F*t)) or (F*t)
for i = 1, #B do
params[i] = B[i][1] + (B[i][2] - B[i][1])*t
end
local s = vf( table.unpack( params ) )
--[[ texio.write_nl( s ) ]]
buf[#buf+1] = s
local C = ("%.2f,%.2f,%.2f,0.65"):format( table.unpack( color ) )
buf[#buf+1] = "\\textcolor[cmyk]{"..C.."}{Test?} "
end
buf[#buf+1] = "\\par "
end
lerp( 0, {0,1}, 0, 0, 300, 0,0,0,2 )
lerp( 0, 1, {-15,0}, 0, 300, 0,1,0,3 )
lerp( 0, {1,0}, -15, 0, 300, 0,1,1,2,-1 )
lerp( 0, 0, -15, 0, {800,300}, 0,0,1,1 )
lerp( 0, {0,1}, -15, 0, 800, 1,0,1,2 )
lerp( 0, 1, {0,-15}, 0, 800, 1,1,1,3,-1 )
lerp( 0, {1,0}, 0, 0, 800, 1,1,0,2,-1 )
lerp( 0, 0, 0, 0, {300,800}, 1,0,0,1,-1 )
tex.print( table.concat( buf, "" ) )
\end{luacode*}
\end{document}