X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdocument.cpp;h=c4ba2103748ef4007ffd09ef35708509d8336c75;hp=48e15a8a23bb77d33b5d34e964b4f81d58f220dc;hb=16f404f3edf222c467639f3e898eeb505075cde8;hpb=398e6b2732decd57cdb57deb3f91d3ff08669e8b diff --git a/src/document.cpp b/src/document.cpp index 48e15a8..c4ba210 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -798,11 +798,11 @@ void Document::AddText(const string & text, Real scale, Real x, Real y) 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) { @@ -820,7 +820,6 @@ void Document::AddText(const string & text, Real scale, Real x, Real y) { 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);