% \iffalse meta-comment % % Copyright (c) 2026 David Purton % % This work may be distributed and/or modified under the conditions of % the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. % %<*driver> \RequirePackage{pdfmanagement} \documentclass[a4paper]{l3doc} \usepackage[T1]{fontenc} \usepackage{microtype} \usepackage{mlmodern} \usepackage[font=small, skip=6pt]{caption} \usepackage{xcolor} \usepackage{listings} \usepackage{sblfonts} \AddToHook{env/macrocode/before}{% \addvspace{\medskipamount}} \AddToHook{env/macro/before}{% \addvspace{\medskipamount}} \begin{document} \DocInput{\jobname.dtx} \end{document} % % \fi % % \title{The \pkg{sblfonts} Package} % \author{David Purton\thanks{Email: \url{dcpurton@marshwiggle.net}}} % \date{2026-05-06 v1.1} % % \maketitle % % \begin{abstract} % \pkg{sblfonts} provides a LaTeX package for setting up font and language % support for documents conforming to the requirements of the Society of % Biblical Literature. Greek and Hebrew languages are supported using the % SBL fonts. If these fonts are not available then fonts included with % TeXLive are used. % \end{abstract} % % \tableofcontents % % \section{Introduction} % % This package is intended to be used with the SBL fonts and a Unicode \TeX\ % engine (|lualatex| is recommended). The SBL fonts are free for personal use % and can be downloaded from \url{https://www.sbl-site.org/resources/fonts/}. % It is, however, possible to use the package with any Unicode font and there % is limited support for 8bit fonts under |pdflatex| (in particular pointed % Hebrew is not easily possible). % % The \pkg{sblfonts} package only sets up fonts for the default Roman family. % You can set up typewriter and sans serif families in the usual way if you % need them. % % \subsection{Usage} % % To use default \LaTeX\ fonts, load the package with no options. The \LaTeX\ % source is shown in Figure \ref{exampleusage} and the output is shown in % Figure \ref{exampleoutput}. % % In reality, you will want to install the SBL fonts, use |lualatex|, and load % the package with |\usepackage[sblfonts]{sblfonts}|. Note that it is not % necessary to mark up inline Greek and Hebrew with |lualatex|. % % \begin{figure} % \centering % \framebox[\linewidth]{% % \parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{% % \small\ttfamily % \textbackslash\textcolor{blue!70!black}{documentclass}\{article\}\\ % \textbackslash\textcolor{blue!70!black}{usepackage}\{sblfonts\}\\ % \textbackslash\textcolor{blue!70!black}{begin}\{document\}\\ % \textbackslash\textcolor{blue!70!black}{begin}\{quotation\}\\ % \phantom{..}\textbackslash\textcolor{blue!70!black}{selectlanguage}\{polytonicgreek\}\\ % {\fontencoding{LGR}\fontfamily{cmtt}\selectfont % \phantom{..}Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς ἦν ὁ λόγος.\\ % \phantom{..}οὗτος ἦν ἐν ἀρχῇ πρὸς τὸν θεόν.}\\ % \textbackslash\textcolor{blue!70!black}{end}\{quotation\}\\ % \textbackslash\textcolor{blue!70!black}{begin}\{quotation\}\\ % \phantom{..}\textbackslash\textcolor{blue!70!black}{selectlanguage}\{hebrew\}\\ % {\fontencoding{NHE8}\fontfamily{miriam}\fontseries{b}\selectfont % \phantom{..}\foreignlanguage{hebrew}{ב\kern-4.6pt ּ\kern-1ptראש\kern-5.3pt ׁית % ב\kern-4.6pt ּ\kern-1ptרא אלהים את הש\kern-5.3pt ׁ\kern-6.3pt ּ\kern1ptמים ואת % הארץ׃ והארץ היתה תהו\kern-4pt ּ ובהו\kern-4pt ּ וחש\kern-5.3pt ׁך}\\ % \phantom{..}\foreignlanguage{hebrew}{על־פ\kern-5.8pt ּני תהום % ורו\kern-4pt ּח אלהים מרחפת על־פ\kern-5.8pt ּני המ\kern-5.5pt ּים׃}}\\ % \textbackslash\textcolor{blue!70!black}{end}\{quotation\}\\ % Inline Greek % (\textbackslash\textcolor{blue!70!black}{foreignlanguage}\{polytonicgreek\}\{{\fontencoding{LGR}\fontfamily{cmtt}\selectfont % Ἐν ἀρχῇ}\}) and Hebrew % (\textbackslash\textcolor{blue!70!black}{foreignlanguage}\{hebrew\}\{{\fontencoding{NHE8}\fontfamily{miriam}\fontseries{b}\selectfont\foreignlanguage{hebrew}{ב\kern-4.6pt ּ\kern-1ptראש\kern-5.3pt ׁית}}\}) % are also possible.\\ % \textbackslash\textcolor{blue!70!black}{end}\{document\}% % }% % } % \caption{Example \LaTeX\ source showing default Greek and Hebrew fonts.} % \label{exampleusage} % \end{figure} % % \begin{figure} % \centering % \framebox[\linewidth]{% % \parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{% % \begin{quotation} % \selectlanguage{polytonicgreek} % Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς ἦν ὁ % λόγος. οὗτος ἦν ἐν ἀρχῇ πρὸς τὸν θεόν. % \end{quotation} % \begin{quotation} % \selectlanguage{hebrew} % בּראשׁית בּרא אלהים את השּׁמים ואת הארץ׃ והארץ היתה תהוּ ובהוּ וחשׁך על־פּני % תהום ורוּח אלהים מרחפת על־פּני המּים׃ % \end{quotation} % Inline Greek (\foreignlanguage{polytonicgreek}{Ἐν ἀρχῇ}) and Hebrew % (\foreignlanguage{hebrew}{בּראשׁית}) are also possible. % }% % } % \caption{Example output showing Greek and Hebrew in default \LaTeX\ % fonts.} % \label{exampleoutput} % \end{figure} % % \subsection{Bug Reports and Feature Requests} % % Bug reports and feature requests can be made at the \pkg{sbltex} % GitHub repository. See \url{https://github.com/dcpurton/sbltex}. % % \section{Package Options} % % \begin{function}{mainlang} % \begin{syntax} % mainlang = \meta{babel language}\hfill Default: \emph{unset} % \end{syntax} % Set the main language of the document. If this is unset, the main language % is the language passed to the document class or if that is unset, % |american|. % \end{function} % % \begin{function}{mainlangoptions} % \begin{syntax} % mainlanguageoptions = \meta{babelprovide options}\hfill Default: \emph{unset} % \end{syntax} % Set the options passed to \cs{babelprovide} when loading the main language % (in addition to |import, main|). This is not used if the main language is % passed to \pkg{babel} via the document class options. % \end{function} % % \begin{function}{mainfont} % \begin{syntax} % mainfont = \meta{package} \textbar\ \meta{fontspec name}\hfill Default: \emph{unset} % \end{syntax} % Set the main font. Under |pdftex| this is the name of a font package to % load. Under Unicode engines it should be a \pkg{fontspec} name which is % passed to \cs{babelfont}. The optional arguments passed to the package or % \cs{babelfont} can be specified in the |mainfontoptions| option. % \end{function} % % \begin{function}{mainfontoptions} % \begin{syntax} % mainfontoptions = \meta{package options} \textbar\ \meta{fontspec options}\hfill Default: \emph{unset} % \end{syntax} % The optional arguments passed to the font package under |pdflatex| or % \cs{babelfont} under Unicode engines. % \end{function} % % \begin{function}{grfont} % \begin{syntax} % grfont = \meta{NFSS font} \textbar\ \meta{fontspec name}\hfill Default: \emph{unset} % \end{syntax} % Set the Greek font. For |pdflatex| this should be an NFSS font name which % supports the LGR encoding. For Unicode engines this should be a % \pkg{fontspec} font name. If unset, then under |pdflatex| the default % font is |grmn1000| and under Unicode engines the default font is CMU Serif % or |mainfont| if it supports Greek. With the Unicode engines, the optional % arguments passed to \cs{babelfont} can be specified in the |grfontoptions| % option. % \end{function} % % \begin{function}{grfontoptions} % \begin{syntax} % grfontoptions = \meta{fontspec options}\hfill Default: \emph{unset} % \end{syntax} % The optional arguments passed to \cs{babelfont} for the Greek font under % Unicode engines. This option is ignored under |pdftex|. % \end{function} % % \begin{function}{grlangoptions} % \begin{syntax} % grlangoptions = \meta{babelprovide options}\hfill Default: \emph{unset} % \end{syntax} % Set the options passed to \cs{babelprovide} when loading |polytonicgreek| % (in addition to |import, onchar=ids fonts|). % \end{function} % % \begin{function}{hefont} % \begin{syntax} % hefont = \meta{NFSS font} \textbar\ \meta{fontspec name}\hfill Default: \emph{unset} % \end{syntax} % Set the Hebrew font. For |pdflatex| this should be an NFSS font name which % supports the NHE8 encoding. For Unicode engines this should be a % \pkg{fontspec} font name. If unset, then under |pdflatex| the default % font is |david| and under Unicode engines the default font is David CLM % or |mainfont| if it supports Hebrew. With the Unicode engines, the optional % arguments passed to \cs{babelfont} can be specified in the |hefontoptions| % option. % \end{function} % % In reality, |pdflatex| is really only supported for interest. You should use % |lualatex| for any right-to-left languages. % % \begin{function}{hefontoptions} % \begin{syntax} % hefontoptions = \meta{fontspec options}\hfill Default: \emph{unset} % \end{syntax} % The optional arguments passed to \cs{babelfont} for the Hebrew font under % Unicode engines. This option is ignored under |pdftex|. % \end{function} % % \begin{function}{helangoptions} % \begin{syntax} % helangoptions = \meta{babelprovide options}\hfill Default: \emph{unset} % \end{syntax} % Set the options passed to \cs{babelprovide} when loading |hebrew| (in % addition to |import, onchar=ids fonts|). % \end{function} % % \subsection{Using SBL Greek and Hebrew fonts} % % Under Unicode engines, the following options control whether the SBL Greek % and Hebrew fonts should be used. Under |pdftex| the similar looking % |Alegreya-OsF| and |frank| fonts are used. % % \begin{function}{sblfonts} % \begin{syntax} % sblfonts = true \textbar\ false \textbar\ fallback\hfill Default: fallback % \end{syntax} % This is a shortcut option for setting both |sblgreek| and |sblhebrew| at % the same time. Under |pdftex|, |false| and |fallback| behave the same. % \end{function} % % \begin{function}{sblgreek} % \begin{syntax} % sblgreek = true \textbar\ false \textbar\ fallback\hfill Default: fallback % \end{syntax} % This option controls if and when the SBL Greek font should be used. The order % of fonts tried for each option is: % \end{function} % \begin{description} % \item[\texttt{true}] Under Unicode engines: SBL BibLit, SBL Greek, % Alegreya. Under |pdftex|: |Alegreya-OsF|. % \item[\texttt{false}] Under Unicode engines: |mainfont| (if specified) % otherwise CMU Serif. This is useful if the test to detect Greek support % in |mainfont| is not accurate. Under |pdftex|: the same as the % |fallback| option. % \item[\texttt{fallback}] Under Unicode engines: |mainfont| (if specified % and if Greek is supported) otherwise CMU Serif. Under |pdftex|: % |mainfont| (if specified and if the LGR encoding is supported), % otherwise |grmn1000|. % \end{description} % % \begin{function}{sblhebrew} % \begin{syntax} % sblhebrew = true \textbar\ false \textbar\ fallback\hfill Default: fallback % \end{syntax} % This option controls if and when the SBL Hebrew font should be used. The order % of fonts tried for each option is: % \end{function} % \begin{description} % \item[\texttt{true}] Under Unicode engines: SBL BibLit, SBL Hebrew, Frank % Ruehl CLM. Under |pdftex|: |frank|. % \item[\texttt{false}] Under Unicode engines: |mainfont| (if specified) % otherwise David CLM. This is useful if the test to detect Hebrew support % in |mainfont| is not accurate. Under |pdftex|: the same as the % |fallback| option. % \item[\texttt{fallback}] Under Unicode engines: |mainfont| (if specified % and if Hebrew is supported) otherwise David CLM. Under |pdftex|: % |mainfont| (if specified and if the NHE8 encoding is supported), % otherwise |david|. % \end{description} % % \section{Implementation} % % \setlength{\parindent}{0em} % % \begin{macrocode} %<*package> %<@@=sblfonts> % \end{macrocode} % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesExplPackage{sblfonts}{2026-05-06}{1.1} {Society of Biblical Literature Font and Language Set Up (DCP)} % \end{macrocode} % % \begin{macrocode} \keys_define:nn { sblfonts } { , mainlang .tl_set:N = \l_@@_mainlang_tl , mainlangoptions .clist_set:N = \l_@@_mainlang_options_clist , mainfont .tl_set:N = \l_@@_mainfont_tl , mainfontoptions .clist_set:N = \l_@@_mainfont_options_clist , grfont .tl_set:N = \l_@@_grfont_tl , grfontoptions .clist_set:N = \l_@@_grfont_options_clist , grlangoptions .clist_set:N = \l_@@_grlang_options_clist , hefont .tl_set:N = \l_@@_hefont_tl , hefontoptions .clist_set:N = \l_@@_hefont_options_clist , helangoptions .clist_set:N = \l_@@_helang_options_clist } % \end{macrocode} % % \begin{macrocode} \str_new:N \l_@@_sblgreek_str \str_new:N \l_@@_sblhebrew_str % \end{macrocode} % % \begin{macrocode} \sys_if_engine_opentype:TF { \keys_define:nn { sblfonts } { , sblfonts .choices:nn = { true, false, fallback } { \str_set:NV \l_@@_sblgreek_str \l_keys_choice_str \str_set:NV \l_@@_sblhebrew_str \l_keys_choice_str } , sblfonts .default:n = { true } , sblgreek .choices:nn = { true, false, fallback } { \str_set:NV \l_@@_sblgreek_str \l_keys_choice_str } , sblgreek .default:n = { true } , sblgreek .initial:n = { fallback } , sblhebrew .choices:nn = { true, false, fallback } { \str_set:NV \l_@@_sblhebrew_str \l_keys_choice_str } , sblhebrew .default:n = { true } , sblhebrew .initial:n = { fallback } } } % \end{macrocode} % % For |pdftex| make |sblfonts|, |sblgreek| and |sblhebrew| noops. % % \begin{macrocode} { \keys_define:nn { sblfonts } { , sblfonts .meta:n = { sblgreek = #1 , sblhebrew = #1 } , sblfonts .default:n = { true } , sblgreek .code:n = { \str_if_eq:nnT {#1} { true } { \tl_set:Nn \l_@@_grfont_tl { Alegreya-OsF } } } , sblgreek .default:n = { true } , sblhebrew .code:n = { \str_if_eq:nnT {#1} { true } { \tl_set:Nn \l_@@_hefont_tl { frank } } } , sblhebrew .default:n = { true } } } % \end{macrocode} % % \begin{macrocode} \ProcessKeyOptions % \end{macrocode} % % \subsection{Language Set Up} % % \cs{babelprovide} macros need to be run outside of ExplSyntax. % % \begin{macrocode} \tl_set_eq:NN \@sblfonts@mainlang \l_@@_mainlang_tl \clist_set:Ne \@sblfonts@mainlang@options { , import , \clist_use:N \l_@@_mainlang_options_clist , main } \clist_set:Ne \@sblfonts@grlang@options { , import , onchar = ids ~ fonts , \clist_use:N \l_@@_grlang_options_clist } \clist_set:Ne \@sblfonts@helang@options { , import , onchar = ids ~ fonts , \clist_use:N \l_@@_helang_options_clist } % \end{macrocode} % % \begin{macrocode} \ExplSyntaxOff % \end{macrocode} % % \begin{macrocode} \newcommand*{\@sblfonts@load@american}{% \expandafter\babelprovide\expandafter [\@sblfonts@mainlang@options]{american}} \newcommand*{\@sblfonts@load@mainlang}{% \expandafter\babelprovide\expandafter [\@sblfonts@mainlang@options]{\@sblfonts@mainlang}} \newcommand*{\@sblfonts@load@polytonicgreek}{% \expandafter\babelprovide\expandafter [\@sblfonts@grlang@options]{polytonicgreek}} \newcommand*{\@sblfonts@load@hebrew}{% \expandafter\babelprovide\expandafter [\@sblfonts@helang@options]{hebrew}} % \end{macrocode} % % \begin{macrocode} \ExplSyntaxOn % \end{macrocode} % % \begin{macro}{\@@_load_languages:} % % Load American, Polytonic Greek and Hebrew languages using \pkg{babel}. % % \begin{macrocode} \cs_new_protected:Nn \@@_load_languages: { \tl_if_eq:NnT \languagename { nil } { \tl_if_empty:NTF \l_@@_mainlang_tl { \@sblfonts@load@american } { \@sblfonts@load@mainlang } } \@sblfonts@load@polytonicgreek \@sblfonts@load@hebrew \babeladjust{ select.write = shift } } % \end{macrocode} % % \begin{macrocode} \cs_set_eq:NN \@sblfonts@load@languages \@@_load_languages: % \end{macrocode} % \end{macro} % % \begin{macrocode} \sys_if_engine_opentype:TF { \RequirePackage { fontspec } \sys_if_engine_luatex:T { \RequirePackage [ bidi=basic, provide*=* ] { babel } } \sys_if_engine_xetex:T { \RequirePackage [ bidi=default, provide*=* ] { babel } } } { \RequirePackage [ NHE8, LGR, T1 ] { fontenc } \RequirePackage [ bidi=default, provide*=* ] { babel } } % \end{macrocode} % % \cs{babelprovide} macros need to be run outside of ExplSyntax. % % \begin{macrocode} \ExplSyntaxOff \@sblfonts@load@languages \ExplSyntaxOn % \end{macrocode} % % \subsection{Font Set Up} % % \begin{macro}{\@@_load_default_greek_font:} % % Load the default \LaTeX\ Greek font. % % \begin{macrocode} \cs_new_protected:Nn \@@_load_default_greek_font: { \babelfont [ polytonicgreek ] { rm } [ Extension = .otf , ItalicFont = cmunti , BoldFont = cmunbx , BoldItalicFont = cmunbi , \l_@@_grfont_options_clist ] { cmunrm } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_load_default_hebrew_font:} % \begin{macrocode} % % Load the default \LaTeX\ Hebrew font. % \cs_new_protected:Nn \@@_load_default_hebrew_font: { \babelfont [ hebrew ] { rm } [ Extension = .otf , UprightFont = *-Medium , ItalicFont = *-MediumItalic , BoldFont = *-Bold , BoldItalicFont = *-BoldItalic , \l_@@_hefont_options_clist ] { DavidCLM } } % \end{macrocode} % \end{macro} % % \begin{macrocode} \sys_if_engine_opentype:TF { % \end{macrocode} % % Use main font for Greek and Hebrew if it supports it unless SBL fonts have % been explicitly asked for. \textbf{Note:} Some fonts support only monotonic % Greek, but there generally isn't a way to tell this without checking which % glyphs are actually present. % % \begin{macrocode} \tl_if_empty:NTF \l_@@_mainfont_tl { % \end{macrocode} % % Initially set Greek and Hebrew to CMU Serif and David CLM % % \begin{macrocode} \@@_load_default_greek_font: \@@_load_default_hebrew_font: } { \babelfont { rm } [ \l_@@_mainfont_options_clist ] { \l_@@_mainfont_tl } \fontspec_if_script:nF { grek } { \str_if_eq:VnT \l_@@_sblgreek_str { fallback } { \@@_load_default_greek_font: } } \fontspec_if_script:nF { hebr } { \str_if_eq:VnT \l_@@_sblhebrew_str { fallback } { \@@_load_default_hebrew_font: } } } % \end{macrocode} % % Try to load SBL fonts if asked for. % \begin{description} % \item[For Greek:] SBL BibLit, SBL Greek, Alegreya % \item[For Hebrew:] SBL BibLit, SBL Hebrew, Frank Ruehl CLM % \end{description} % \textbf{Note:} The SBL font is strongly advised for biblical Hebrew. % Alegreya and Frank Ruehl CLM are included in TeXLive so should be present. % % \begin{macrocode} \str_if_eq:VnT \l_@@_sblgreek_str { true } { \fontspec_font_if_exist:nTF { SBL ~ BibLit } { \babelfont [ polytonicgreek ] { rm } [ ItalicFont = SBL ~ BibLit , BoldFont = SBL ~ BibLit , BoldItalicFont = SBL ~ BibLit , \l_@@_grfont_options_clist ] { SBL ~ BibLit } } { \fontspec_font_if_exist:nTF { SBL ~ Greek } { \babelfont [ polytonicgreek ] { rm } [ ItalicFont = SBL ~ Greek , BoldFont = SBL ~ Greek , BoldItalicFont = SBL ~ Greek , \l_@@_grfont_options_clist ] { SBL ~ Greek } } { \babelfont [ polytonicgreek ] { rm } [ Extension = .otf , UprightFont = *-Regular , ItalicFont = *-Italic , BoldFont = *-Bold , BoldItalic = *-BoldItalic , \l_@@_grfont_options_clist ] { Alegreya } } } } % \end{macrocode} % % \begin{macrocode} \str_if_eq:VnT \l_@@_sblhebrew_str { true } { \fontspec_font_if_exist:nTF { SBL ~ BibLit } { \babelfont [ hebrew ] { rm } [ ItalicFont = SBL ~ BibLit , BoldFont = SBL ~ BibLit , BoldItalicFont = SBL ~ BibLit , \l_@@_hefont_options_clist ] { SBL ~ BibLit } } { \fontspec_font_if_exist:nTF { SBL ~ Hebrew } { \babelfont [ hebrew ] { rm } [ ItalicFont = SBL ~ Hebrew , BoldFont = SBL ~ Hebrew , BoldItalicFont = SBL ~ Hebrew , \l_@@_hefont_options_clist ] { SBL ~ Hebrew } } { \babelfont [ hebrew ] { rm } [ Extension = .ttf , UprightFont = *-Medium , ItalicFont = *-MediumOblique , BoldFont = *-Bold , BoldItalic = *-BoldOblique , \l_@@_hefont_options_clist ] { FrankRuehlCLM } } } } % \end{macrocode} % % Override Greek and Hebrew fonts if specified in |grfont| and |hefont| % options. % % \begin{macrocode} \tl_if_empty:NF \l_@@_grfont_tl { \babelfont [ polytonicgreek ] { rm } [ \l_@@_grfont_options_clist ] { \l_@@_grfont_tl } } \tl_if_empty:NF \l_@@_hefont_tl { \babelfont [ hebrew ] { rm } [ \l_@@_hefont_options_clist ] { \l_@@_hefont_tl } } } { % \end{macrocode} % % For |pdflatex|, load font using a package. % % \begin{macrocode} \tl_if_empty:NF \l_@@_mainfont_tl { \RequirePackage [ \l_@@_mainfont_options_clist ] { \l_@@_mainfont_tl } } % \end{macrocode} % % Override Greek and Hebrew fonts if specified in |grfont| and |hefont| % options. % % \begin{macrocode} \tl_if_empty:NF \l_@@_grfont_tl { \DeclareFontFamilySubstitution { LGR } { \rmdefault } { \l_@@_grfont_tl } } \tl_if_empty:NF \l_@@_hefont_tl { \DeclareFontFamilySubstitution { NHE8 } { \rmdefault } { \l_@@_hefont_tl } } } % \end{macrocode} % % \begin{macrocode} \endinput % \end{macrocode} % % \begin{macrocode} % % \end{macrocode}