This generates the following in Projucer’s Live component preview:
class Test : public Component
{
Test() {}
void paint(Graphics& g) override
{
int fontHeight = 60;
Font font("Times", fontHeight, Font::FontStyleFlags::plain);
Array<int> pos;
Array<float> offsets;
font.getGlyphPositions("D", pos, offsets);
Path p;
if( font.getTypeface()->getOutlineForGlyph(pos[0], p) )
{
p.applyTransform(AffineTransform::scale(fontHeight));
}
auto r = p.getBounds();
g.setColour(Colours::black);
g.setFont(font);
g.drawSingleLineText("D", 0, r.getHeight() + 10);
g.setColour(Colours::red);
g.drawRect(r.withPosition(r.getX(), r.getY() + r.getHeight() + 10));
}
};
the red rectangle is 60 pixels high, right in line with the specified font height, and is positioned right at the 10px mark.