git.ucc.asn.au
/
ipdf
/
code.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
The QuadTree is ~72% more amazing.
[ipdf/code.git]
/
src
/
document.cpp
diff --git
a/src/document.cpp
b/src/document.cpp
index
0aeee1d
..
5890730
100644
(file)
--- 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);
}
UCC
git Repository :: git.ucc.asn.au