X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fdocument.cpp;h=589073039f7361164340532fc11da8e13695f70c;hb=20788af97c06b76040ea2de5ab3ddc683a261365;hp=0aeee1ddb101f675569a99ae4d8be577b7158087;hpb=e7066887c0d142ddef87ec9ae07ef08ff31573dc;p=ipdf%2Fcode.git diff --git a/src/document.cpp b/src/document.cpp index 0aeee1d..5890730 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -105,6 +105,7 @@ int Document::ClipObjectToQuadChild(int object_id, QuadTreeNodeChildren type) { case RECT_FILLED: case RECT_OUTLINE: + case PATH: { Rect obj_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); if (obj_bounds.x < 0) @@ -147,6 +148,7 @@ int Document::ClipObjectToQuadChild(int object_id, QuadTreeNodeChildren type) Rect new_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); Bezier new_curve_data = new_curves[i].ToAbsolute(TransformToQuadChild(m_objects.bounds[object_id],type)); new_bounds = new_curve_data.SolveBounds(); + Debug("New bounds: %s", new_bounds.Str().c_str()); new_curve_data = new_curve_data.ToRelative(new_bounds); unsigned index = AddBezierData(new_curve_data); m_objects.bounds.push_back(new_bounds); @@ -301,6 +303,7 @@ unsigned Document::AddPath(unsigned start_index, unsigned end_index, const Colou unsigned data_index = AddPathData(path); Rect bounds = path.SolveBounds(m_objects); unsigned result = Add(PATH, bounds,data_index); + //Debug("Added path %u -> %u (%u objects) colour {%u,%u,%u,%u}, stroke {%u,%u,%u,%u}", start_index, end_index, (end_index - start_index), fill.r, fill.g, fill.b, fill.a, stroke.r, stroke.g, stroke.b, stroke.a); return result; } @@ -929,7 +932,8 @@ void Document::AddText(const string & text, Real scale, Real x, Real y) //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 font_scale = scale; + font_scale /= Real(ascent - descent); Real y_advance = Real(font_scale) * Real(ascent - descent + line_gap); for (unsigned i = 0; i < text.size(); ++i) { @@ -947,9 +951,9 @@ void Document::AddText(const string & text, Real scale, Real x, Real y) { kerning = stbtt_GetCodepointKernAdvance(&m_font, text[i-1], text[i]); } - x += Real(font_scale) * Real(kerning); + x += font_scale * Real(kerning); AddFontGlyphAtPoint(&m_font, text[i], font_scale, x, y); - x += Real(font_scale) * Real(advance_width); + x += font_scale * Real(advance_width); } } @@ -1007,7 +1011,7 @@ void Document::AddFontGlyphAtPoint(stbtt_fontinfo *font, int character, Real sca { AddPath(start_index, end_index); } - Debug("Added Glyph \"%c\" at %f %f, scale %f", (char)character, Float(x), Float(y), Float(scale)); + //Debug("Added Glyph \"%c\" at %f %f, scale %f", (char)character, Float(x), Float(y), Float(scale)); stbtt_FreeShape(font, instructions); }