Alternatively,thecontentsofthisfilemaybeusedunderthetermsofthe MozillaPublicLicense(http://mozilla.org/MPL) or the GNU General Public License,aspublishedbytheFreeSoftwareFoundation,eitherversion2 oftheLicenseor(atyouroption)anylaterversion.
*/
if (width < 0 && !(silf()->flags())) return width;
if ((m_dir & 1) != m_silf->dir() && m_silf->bidiPass() != m_silf->numPasses())
{
reverseSlots();
std::swap(pFirst, pLast);
} if (!pFirst) pFirst = pSlot; while (!pFirst->isBase()) pFirst = pFirst->attachedTo(); if (!pLast) pLast = last(); while (!pLast->isBase()) pLast = pLast->attachedTo(); constfloat base = pFirst->origin().x / scale;
width = width / scale; if ((jflags & gr_justEndInline) == 0)
{ while (pLast != pFirst && pLast)
{
Rect bbox = theGlyphBBoxTemporary(pLast->glyph()); if (bbox.bl.x != 0.f || bbox.bl.y != 0.f || bbox.tr.x != 0.f || bbox.tr.y == 0.f) break;
pLast = pLast->prev();
}
}
if (pLast)
end = pLast->nextSibling(); if (pFirst)
pFirst = pFirst->nextSibling();
int icount = 0; int numLevels = silf()->numJustLevels(); if (!numLevels)
{ for (Slot *s = pSlot; s && s != end; s = s->nextSibling())
{
CharInfo *c = charinfo(s->before()); if (isWhitespace(c->unicodeChar()))
{
s->setJustify(this, 0, 3, 1);
s->setJustify(this, 0, 2, 1);
s->setJustify(this, 0, 0, -1);
++icount;
}
} if (!icount)
{ for (Slot *s = pSlot; s && s != end; s = s->nextSibling())
{
s->setJustify(this, 0, 3, 1);
s->setJustify(this, 0, 2, 1);
s->setJustify(this, 0, 0, -1);
}
}
++numLevels;
}
Vector<JustifyTotal> stats(numLevels); for (Slot *s = pFirst; s && s != end; s = s->nextSibling())
{ float w = s->origin().x / scale + s->advance() - base; if (w > currWidth) currWidth = w; for (int j = 0; j < numLevels; ++j)
stats[j].accumulate(s, this, j);
s->just(0);
}
for (int i = (width < 0.0f) ? -1 : numLevels - 1; i >= 0; --i)
{ float diff; float error = 0.; float diffpw; int tWeight = stats[i].weight(); if (tWeight == 0) continue;
do {
error = 0.;
diff = width - currWidth;
diffpw = diff / tWeight;
tWeight = 0; for (Slot *s = pFirst; s && s != end; s = s->nextSibling()) // don't include final glyph
{ int w = s->getJustify(this, i, 3); float pref = diffpw * w + error; int step = s->getJustify(this, i, 2); if (!step) step = 1; // handle lazy font developers if (pref > 0)
{ float max = uint16(s->getJustify(this, i, 0)); if (i == 0) max -= s->just(); if (pref > max) pref = max; else tWeight += w;
} else
{ float max = uint16(s->getJustify(this, i, 1)); if (i == 0) max += s->just(); if (-pref > max) pref = -max; else tWeight += w;
} int actual = int(pref / step) * step;
if (actual)
{
error += diffpw * w - actual; if (i == 0)
s->just(s->just() + actual); else
s->setJustify(this, i, 4, actual);
}
}
currWidth += diff - error;
} while (i == 0 && int(std::abs(error)) > 0 && tWeight);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.