# Identifying the current font

As I’m working on The Preppy Lion, I was not happy with how the LaTeX logo was being typeset in the main body typeface that I’m using, Monotype Ehrhardt. I decided to make some small adjustments to the spacing and decided that I also wanted to make slight variations if the logo was being typeset in bold or italic or bold italic. The catch was being able to identify what the current font was.

This should be simple. I could simply compare `\f@shape` to `\itdefault` or `\f@series` to `\bfdefault`. Problem solved right?

So I did the following in my code:

```\ifx\f@shape\itdefault
italic code
\else
non-italic code
\fi
```

and discovered that it didn’t work.


These also weren’t working. I’d done the same `\renewcommand` magic for `\bfdefault` but something was still wrong. It appeared that the `fontspec` package was adding `\@empty` to the end of the `\bfdefault` definition.

The old-school way to deal with this would be to write something like:

```\edef\next{\bfdefault}
\ifx\f@series\next ...```

but this was ugly. It turned out though, while digging through the `fontspec` code in search of where the `\@empty` was being added that there was a simpler approach. The expl3 macros provide a way to compare the fully expanded definitions of two macros with the `\str_if_eq:eeTF` command. I ended up creating two utility macros to handle the checks for bold and italic as:

```\DeclareDocumentCommand{\ForIt}{ mm }
{
\str_if_eq:eeTF
\f@shape
\itdefault
{#1}
{#2}
}

\DeclareDocumentCommand{\ForBf}{ mm }
{
\str_if_eq:eeTF
\f@series
\bfdefault
{#1}
{#2}
}
```

and was able to make my adjustments without difficulty afterwards.