void ControlPanel::InsertTextIntoDocument()
{
const Rect & bounds = m_view.GetBounds();
- Real xx = bounds.x + bounds.w/Real(2);
+ Real xx = bounds.x;
Real yy = bounds.y + bounds.h/Real(2);
string msg = m_text_edit->toPlainText().toStdString();
- Real scale = bounds.w / Real(2);
+ Real scale = bounds.h / Real(2);
Debug("Insert \"%s\" at %f, %f, scale %f", msg.c_str(), Float(xx), Float(yy), Float(scale));
- //m_doc.Add(RECT_OUTLINE, bounds, 0); // debugging; text needs to go in the boujnds
- m_doc.AddText(msg, xx, yy, scale);
+ m_doc.AddText(msg, scale, xx, yy);
m_view.ForceRenderDirty();
m_view.ForceBufferDirty();
m_view.ForceBoundsDirty();
return;
}
- float font_scale = stbtt_ScaleForPixelHeight(&m_font, scale);
Real x0(x);
//Real y0(y);
int ascent = 0, descent = 0, line_gap = 0;
stbtt_GetFontVMetrics(&m_font, &ascent, &descent, &line_gap);
+ float font_scale = scale / (float)(ascent - descent);
Real y_advance = Real(font_scale) * Real(ascent - descent + line_gap);
for (unsigned i = 0; i < text.size(); ++i)
{
{
kerning = stbtt_GetCodepointKernAdvance(&m_font, text[i-1], text[i]);
}
- Debug("%c: lsb %d, kern %d, adv_width %d", text[i], left_side_bearing, kerning, advance_width);
x += Real(font_scale) * Real(kerning);
AddFontGlyphAtPoint(&m_font, text[i], font_scale, x, y);
x += Real(font_scale) * Real(advance_width);