# Copy/search of old style numbers with kpfonts

I have old style figures enabled globally with kpfonts. However, numbers are represented as special unicode characters from the point of view of copy-paste or search. I would like them to function as normal digits instead.

Minimal example:

\documentclass{article}
\usepackage[oldstylenums]{kpfonts}
\begin{document}
0123456789
\end{document}


Copy-paste gives '' instead of '0123456789'. I'm hoping there's a way to fix this globally without having to add a command to each number in the document.

## 1 Answer

You can map the names used by the kpfonts to the unicode positions of the digits:

\documentclass{article}
\usepackage[oldstylenums]{kpfonts}
\pdfglyphtounicode{zerooldstyle}{0030}
\pdfglyphtounicode{oneoldstyle}{0031}
\pdfglyphtounicode{twooldstyle}{0032}
\pdfglyphtounicode{threeoldstyle}{0033}

\pdfgentounicode=1
\begin{document}
0123
\end{document}