10

Suppose you have got a character that sits above the reference point. When you measure its height, the empty space above reference point gets also included in its height measurement but that is not the true height of the character itself. Thus How do you measure the correct height of a character.

To see this better, please see the output of the following document:

\documentclass{minimal}
\usepackage{fontspec}
\usepackage{showcharinbox}
\newfontfamily\testfont{XB Zar}
\begin{document}
\begin{center}
\ShowCharInBox{\fontsize{500}{510}\testfont \char"0640}
\end{center}
\end{document}

XB Zar font can be obtained from here.

8

With XeTeX the primitive \XeTeXglyphbounds is available.

\documentclass{article}
\usepackage{fontspec}

\newfontface{\geeza}{Geeza Pro}

\begin{document}
\edef\gid{\the\XeTeXcharglyph`- }

Top: \the\XeTeXglyphbounds2 \gid

Bottom: \the\XeTeXglyphbounds4 \gid

-\,\vrule 
  width\dimexpr\fontcharwd\font`- -\XeTeXglyphbounds1 \gid -\XeTeXglyphbounds3 \gid\relax
  height \XeTeXglyphbounds2 \gid
  depth \XeTeXglyphbounds4 \gid
\,\vrule
  width \fontcharwd\font`- height \fontcharht\font`- depth \fontchardp\font`-
\ Real height \the\dimexpr\XeTeXglyphbounds2 \gid + \XeTeXglyphbounds4 \gid\relax

\edef\gid{\the\XeTeXcharglyph`; }

;\,\vrule 
  width\dimexpr\fontcharwd\font`- -\XeTeXglyphbounds1 \gid -\XeTeXglyphbounds3 \gid\relax
  height \XeTeXglyphbounds2 \gid
  depth \XeTeXglyphbounds4 \gid
\,\vrule
  width \fontcharwd\font`; height \fontcharht\font`; depth \fontchardp\font`;
\ Real height \the\dimexpr\XeTeXglyphbounds2 \gid + \XeTeXglyphbounds4 \gid\relax

{\geeza
\edef\gid{\the\XeTeXcharglyph"0640 }

\char"0640 \,\vrule 
  width\dimexpr\fontcharwd\font"0640 -\XeTeXglyphbounds1 \gid -\XeTeXglyphbounds3 \gid\relax
  height \XeTeXglyphbounds2 \gid
  depth \XeTeXglyphbounds4 \gid
\,\vrule
  width \fontcharwd\font"0640 height \fontcharht\font"0640 depth \fontchardp\font"0640
\xdef\therealheight{\the\dimexpr\XeTeXglyphbounds2 \gid + \XeTeXglyphbounds4 \gid\relax}%
}\ Real height \therealheight

\end{document}

enter image description here

In the examples each character is followed by a rule drawn using the “real” dimensions and by a rule using the bounding box data. The first two lines show how the bounding box data are represented for the hyphen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.