diff --git a/businesscard-qrcode.cls b/businesscard-qrcode.cls index e8fa7d7..a33b19b 100644 --- a/businesscard-qrcode.cls +++ b/businesscard-qrcode.cls @@ -153,15 +153,31 @@ \newcommand\ifboth[3]{\ifcsdef{#1}{\ifcsdef{#2}{#3}{}}{}} \newcommand\ifany[3]{\ifcsdef{#1}{#3}{\ifcsdef{#2}{#3}{}}} \newcommand\cond[1]{\ifcsdef{#1}{\exec{#1}}{}} -\newcommand\heightscale{\dimexpr\textheight-\ifcsempty{name}{0em}{2em}-\ifcsdef{Xpgpfingerprint}{2em}{0em}-\ifcsdef{Xcompany}{2em}{0em}\relax} + +% internal boxes and lengths for measuring +\newsavebox{\BCQ@namebox} +\newlength{\BCQ@logoheightdimen} +\setlength{\BCQ@logoheightdimen}{0pt}% initialize to prevent errors +\newlength{\BCQ@reservedheight} +\newlength{\BCQ@heightscale} + +% heightscale - calculate available height for text/QR +% Uses actual logo height if logo is taller than default reserved space +% This is computed as a length and stored, not a macro +\newcommand\computeheightscale{% + \setlength{\BCQ@reservedheight}{\dimexpr\ifcsempty{name}{0em}{2em}+\ifcsdef{Xcompany}{2em}{0em}\relax}% + \ifdim\BCQ@logoheightdimen>\BCQ@reservedheight + \setlength{\BCQ@heightscale}{\dimexpr\textheight-\BCQ@logoheightdimen-\ifcsdef{Xpgpfingerprint}{2em}{0em}\relax}% + \else + \setlength{\BCQ@heightscale}{\dimexpr\textheight-\BCQ@reservedheight-\ifcsdef{Xpgpfingerprint}{2em}{0em}\relax}% + \fi +} +\newcommand\heightscale{\BCQ@heightscale} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % name - assemble full name from the parts, such as Xgivennames and Xfamilynames \newcommand\name{\ifexists{Xhonoricprefix}{\Xhonoricprefix\ }\ifexists{Xgivennames}{\Xgivennames\ }\ifexists{Xfamilynames}{\Xfamilynames}\ifexists{Xhonoricsuffix}{\ \Xhonoricsuffix}} -% internal box for measuring name height when logo is present -\newsavebox{\BCQ@namebox} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % vcard - the content of the vcard @@ -332,6 +348,14 @@ END:VCARD\BCQ@nl} \ifx\BCQ@logoheight\@empty \ifcsdef{Xcompany}{\def\BCQ@logoheight{4em}}{\def\BCQ@logoheight{2em}}% \fi + % Store logo height as dimension for heightscale calculation + \ifcsdef{Xlogo}{% + \setlength{\BCQ@logoheightdimen}{\BCQ@logoheight}% + }{% + \setlength{\BCQ@logoheightdimen}{0pt}% + }% + % Compute heightscale after logo height is known + \computeheightscale \ifcsdef{Xlogo}{% logo defined \ifBCQ@logoinqr % Logo in QR code: show name only diff --git a/examples/background-image-example.pdf b/examples/background-image-example.pdf index 97b2a2c..59ceada 100644 Binary files a/examples/background-image-example.pdf and b/examples/background-image-example.pdf differ diff --git a/examples/background-image-example.tex b/examples/background-image-example.tex index b421538..7b8c320 100644 --- a/examples/background-image-example.tex +++ b/examples/background-image-example.tex @@ -1,5 +1,5 @@ % !TeX program = xelatex -\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8]{businesscard-qrcode} +\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,logoheight=6em]{businesscard-qrcode} \type{home} \givennames{Petra} diff --git a/photo-large-example.pdf b/photo-large-example.pdf new file mode 100644 index 0000000..2a8364b --- /dev/null +++ b/photo-large-example.pdf @@ -0,0 +1,2 @@ +%PDF-1.7 +%äðíø diff --git a/screenshots/photo-example.png b/screenshots/photo-example.png index 200c859..d7ea540 100644 Binary files a/screenshots/photo-example.png and b/screenshots/photo-example.png differ diff --git a/screenshots/photo-in-qr-example.png b/screenshots/photo-in-qr-example.png index ac35eba..072f029 100644 Binary files a/screenshots/photo-in-qr-example.png and b/screenshots/photo-in-qr-example.png differ