예제 #1
0
TextRunComponent::TextRunComponent(const UChar *start, int length, const TextRun& parentTextRun, const Font &font, int o)
    : m_textRun(start, length, parentTextRun.allowTabs(), 0, 0
        , parentTextRun.rtl()
        , parentTextRun.directionalOverride()
        , parentTextRun.applyRunRounding()
        , parentTextRun.applyWordRounding())
    , m_offset(o)
    , m_spaces(0)
{
    WidthIterator it(&font, m_textRun);
    it.advance(m_textRun.length(), 0);
    m_width = it.m_runWidthSoFar;
}
예제 #2
0
파일: FontWinCE.cpp 프로젝트: aosm/WebCore
TextRunComponent::TextRunComponent(const UChar *start, int length, const TextRun& parentTextRun, const Font &font, int o)
    : m_textRun(start, length, 0, 0
        , parentTextRun.allowsTrailingExpansion() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion
        , parentTextRun.direction()
        , parentTextRun.directionalOverride())
    , m_offset(o)
    , m_spaces(0)
{
    m_textRun.setTabSize(parentTextRun.allowTabs(), parentTextRun.tabSize());

    WidthIterator it(&font, m_textRun);
    it.advance(m_textRun.length(), 0);
    m_width = it.m_runWidthSoFar;
}
ShapeResultSpacing::ShapeResultSpacing(const TextRun& run,
    const FontDescription& fontDescription)
    : m_textRun(run)
    , m_letterSpacing(fontDescription.letterSpacing())
    , m_wordSpacing(fontDescription.wordSpacing())
    , m_expansion(run.expansion())
    , m_expansionPerOpportunity(0)
    , m_expansionOpportunityCount(0)
    , m_textJustify(TextJustify::TextJustifyAuto)
    , m_hasSpacing(false)
    , m_normalizeSpace(run.normalizeSpace())
    , m_allowTabs(run.allowTabs())
    , m_isAfterExpansion(false)
    , m_isVerticalOffset(fontDescription.isVerticalAnyUpright())
{
    if (m_textRun.spacingDisabled())
        return;

    if (!m_letterSpacing && !m_wordSpacing && !m_expansion)
        return;

    m_hasSpacing = true;

    if (!m_expansion)
        return;

    // Setup for justifications (expansions.)
    m_textJustify = run.getTextJustify();
    m_isAfterExpansion = !run.allowsLeadingExpansion();

    bool isAfterExpansion = m_isAfterExpansion;
    m_expansionOpportunityCount = Character::expansionOpportunityCount(run,
        isAfterExpansion);
    if (isAfterExpansion && !run.allowsTrailingExpansion()) {
        ASSERT(m_expansionOpportunityCount > 0);
        --m_expansionOpportunityCount;
    }

    if (m_expansionOpportunityCount)
        m_expansionPerOpportunity = m_expansion / m_expansionOpportunityCount;
}