# Background

Looking to create a stylized chapter heading using the first character of the heading title.

# Problem

The stem (descender) distance of text causes the containing frame's offset to alter the location of the emphasized first letter, which is obvious from the following picture:

The problematic line in the code below is this line, which was added to ensure the title text does not incur a line-break, as suggested from an answer to a previous question:

\scale[maxwidth=\textwidth-(\marginwidth)]{#1}


When the line above is simply:

#1


Then the alignment is perfect, but when the text is too long an undesired line-break ensues.

# Code

A minimal working example:

\definecolor[BookColourPrimary][h=A45F62]
\definecolor[BookColourSecondary][h=9A957A]
\definespotcolor[BookColourSecondaryLightest]
[BookColourSecondary][a=1,t=.2]
\definefont[BookStyleFontChapterCharacter][SerifItalic scaled 20000]

\defineframed[BookStyleChapterFramed][
frame=on,
align={left,low,nothyphenated,verytolerant},
width=\dimexpr\textwidth-(.2\marginwidth),
height=\dimexpr\textheight+0.25\footerheight,
]

% Extract first character
\define[1]\BookStyleChapterChar{\cldcontext{string.sub("#1",1,1)}}

% Use a nested frame to keep the overlain large letter together with
% the chapter title.
\define[1]\BookStyleChapter{%
\BookStyleChapterFramed{%
\inframed[align=right, frame=on]{%
\startoverlay
% Calculate the large letter's offset using the first character's
% width. This allows font changes without significantly affecting
% the distance between the emphasized first character of the
% chapter title and the complete chapter title.
\setbox\scratchbox\hbox{%
\BookStyleFontChapterCharacter\BookStyleChapterChar{#1}}%
% Shift the first character back relative to the chapter title.
\hskip-.55\wd\scratchbox%
\color[BookColourSecondaryLightest]{%
\BookStyleFontChapterCharacter%
\BookStyleChapterChar{#1}%
}
\vskip-1.9em
% Ensure the text fits on the page.
\scale[maxwidth=\textwidth-(\marginwidth)]{#1}
\stopoverlay
}
}
}

% Avoid duplication...
\define[1]\BookChapterText{
}

\starttext
\BookChapterText{Test-a}
\page
\BookChapterText{Test-g}
\stoptext


# Question

How do you make ConTeXt ignore the stem height while still scaling the text to fit within the \textwidth margins?

• Try \inframed[align=right, frame=on, location=height]{%, the frame will be positioned relative to the baseline (not the depth) of the text. Jan 6, 2014 at 21:58

height=\dimexpr\textheight-\footerheight,

The frame needs to be adjusted as per phg's comment:
\inframed[align=right, frame=off, location=height]