void FontBuilder::setScript(const AtomicString& locale)
{
    set(PropertySetFlag::Script);

    m_fontDescription.setLocale(locale);
    m_fontDescription.setScript(localeToScriptCodeForFontSelection(locale));
}
void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, RenderStyle* documentStyle)
{
    FontDescription fontDescription = FontDescription();
    fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->locale()));
    if (Settings* settings = m_document->settings()) {
        fontDescription.setUsePrinterFont(m_document->printing());
        const AtomicString& standardFont = settings->standardFontFamily(fontDescription.script());
        if (!standardFont.isEmpty()) {
            fontDescription.setGenericFamily(FontDescription::StandardFamily);
            fontDescription.firstFamily().setFamily(standardFont);
            fontDescription.firstFamily().appendFamily(0);
        }
        fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
        int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, false);
        fontDescription.setSpecifiedSize(size);
        fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, documentStyle->effectiveZoom(), size));
    } else {
        fontDescription.setUsePrinterFont(m_document->printing());
    }

    FontOrientation fontOrientation;
    NonCJKGlyphOrientation glyphOrientation;
    getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation);
    fontDescription.setOrientation(fontOrientation);
    fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
    documentStyle->setFontDescription(fontDescription);
    documentStyle->font().update(fontSelector);
}
FontDescription::FontDescription()
    : m_orientation(Horizontal)
    , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight)
    , m_widthVariant(RegularWidth)
    , m_italic(FontItalicOff)
    , m_smallCaps(FontSmallCapsOff)
    , m_weight(FontWeightNormal)
    , m_renderingMode(NormalRenderingMode)
    , m_textRendering(AutoTextRendering)
    , m_script(localeToScriptCodeForFontSelection(m_locale))
    , m_fontSynthesis(FontSynthesisWeight | FontSynthesisStyle)
    , m_variantCommonLigatures(static_cast<unsigned>(FontVariantLigatures::Normal))
    , m_variantDiscretionaryLigatures(static_cast<unsigned>(FontVariantLigatures::Normal))
    , m_variantHistoricalLigatures(static_cast<unsigned>(FontVariantLigatures::Normal))
    , m_variantContextualAlternates(static_cast<unsigned>(FontVariantLigatures::Normal))
    , m_variantPosition(static_cast<unsigned>(FontVariantPosition::Normal))
    , m_variantCaps(static_cast<unsigned>(FontVariantCaps::Normal))
    , m_variantNumericFigure(static_cast<unsigned>(FontVariantNumericFigure::Normal))
    , m_variantNumericSpacing(static_cast<unsigned>(FontVariantNumericSpacing::Normal))
    , m_variantNumericFraction(static_cast<unsigned>(FontVariantNumericFraction::Normal))
    , m_variantNumericOrdinal(static_cast<unsigned>(FontVariantNumericOrdinal::Normal))
    , m_variantNumericSlashedZero(static_cast<unsigned>(FontVariantNumericSlashedZero::Normal))
    , m_variantAlternates(static_cast<unsigned>(FontVariantAlternates::Normal))
    , m_variantEastAsianVariant(static_cast<unsigned>(FontVariantEastAsianVariant::Normal))
    , m_variantEastAsianWidth(static_cast<unsigned>(FontVariantEastAsianWidth::Normal))
    , m_variantEastAsianRuby(static_cast<unsigned>(FontVariantEastAsianRuby::Normal))
{
}
void FontBuilder::setScript(const String& locale)
{
    FontDescriptionChangeScope scope(this);

    scope.fontDescription().setLocale(locale);
    scope.fontDescription().setScript(localeToScriptCodeForFontSelection(locale));
}
Exemple #5
0
void Settings::initializeDefaultFontFamilies()
{
    static const char* kLanguages[] = {
        "ar",
        "bn",
        "gu",
        "he",
        "hi",
        "ja",
        "kn",
        "ko",
        "ml",
        "pa",
        "ta",
        "te",
        "th",
        "zh-CN",
        "zh-TW",
    };

    static BlackBerry::Platform::String* languages[WTF_ARRAY_LENGTH(kLanguages)];
    static bool init = false;
    if (!init) {
        for (size_t i = 0; i < WTF_ARRAY_LENGTH(kLanguages); ++i)
            languages[i] = new BlackBerry::Platform::String(kLanguages[i]);
        init = true;
    }

    STATIC_LOCAL_STRING(s_webkitCursive, "-webkit-cursive");
    STATIC_LOCAL_STRING(s_webkitFantasy, "-webkit-fantasy");
    STATIC_LOCAL_STRING(s_webkitMonospace, "-webkit-monospace");
    STATIC_LOCAL_STRING(s_webkitSansSerif, "-webkit-sans-serif");
    STATIC_LOCAL_STRING(s_webkitSerif, "-webkit-serif");
    STATIC_LOCAL_STRING(s_webkitStandard, "-webkit-standard");

    setCursiveFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_webkitCursive, BlackBerry::Platform::String::emptyString()));
    setFantasyFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_webkitFantasy, BlackBerry::Platform::String::emptyString()));
    setFixedFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_webkitMonospace, BlackBerry::Platform::String::emptyString()));
    setSansSerifFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_webkitSansSerif, BlackBerry::Platform::String::emptyString()));
    setSerifFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_webkitSerif, BlackBerry::Platform::String::emptyString()));
    setStandardFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_webkitStandard, BlackBerry::Platform::String::emptyString()));

    STATIC_LOCAL_STRING(s_monospace, "monospace");
    STATIC_LOCAL_STRING(s_serif, "serif");
    STATIC_LOCAL_STRING(s_sansSerif, "sans-serif");
    for (size_t i = 0; i < WTF_ARRAY_LENGTH(languages); ++i) {
        UScriptCode script = localeToScriptCodeForFontSelection(*languages[i]);
        setFixedFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_monospace, *languages[i]), script);
        setSansSerifFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_sansSerif, *languages[i]), script);
        setSerifFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(s_serif, *languages[i]), script);
        setStandardFontFamily(BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::emptyString(), *languages[i]), script);
    }
}
void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, ComputedStyle& documentStyle)
{
    FontDescription fontDescription = FontDescription();
    fontDescription.setLocale(documentStyle.locale());
    fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle.locale()));

    setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription());
    setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false));
    updateSpecifiedSize(fontDescription, documentStyle);
    updateComputedSize(fontDescription, documentStyle);

    updateOrientation(fontDescription, documentStyle);
    documentStyle.setFontDescription(fontDescription);
    documentStyle.font().update(fontSelector);
}
void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, RenderStyle* documentStyle)
{
    FontDescription fontDescription = FontDescription();
    fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->locale()));

    setFontFamilyToStandard(fontDescription, m_document);
    fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
    int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, false);
    fontDescription.setSpecifiedSize(size);
    fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, documentStyle->effectiveZoom(), size));

    FontOrientation fontOrientation;
    NonCJKGlyphOrientation glyphOrientation;
    getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation);
    fontDescription.setOrientation(fontOrientation);
    fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
    documentStyle->setFontDescription(fontDescription);
    documentStyle->font().update(fontSelector);
}
void createFontForDocument(RenderStyle* style)
{
    FontDescription fontDescription = FontDescription();
    fontDescription.setScript(localeToScriptCodeForFontSelection(style->locale()));

    // Using 14px default to match Material Design English Body1:
    // http://www.google.com/design/spec/style/typography.html#typography-typeface
    const float defaultFontSize = 14.0;

    fontDescription.setSpecifiedSize(defaultFontSize);
    fontDescription.setComputedSize(defaultFontSize);

    FontOrientation fontOrientation = Horizontal;
    NonCJKGlyphOrientation glyphOrientation = NonCJKGlyphOrientationVerticalRight;

    fontDescription.setOrientation(fontOrientation);
    fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
    style->setFontDescription(fontDescription);
    style->font().update(UIDartState::Current()->font_selector());
}
void FontDescription::setLocale(const AtomicString& locale)
{
    m_locale = locale;
    m_script = localeToScriptCodeForFontSelection(m_locale);
}
UScriptCode scriptCodeForHanFromLocale(const String& locale, char delimiter)
{
    UScriptCode script = localeToScriptCodeForFontSelection(locale);
    return scriptCodeForHanFromLocale(script, locale, delimiter);
}
Exemple #11
0
PassRef<RenderStyle> resolveForDocument(const Document& document)
{
    ASSERT(document.hasLivingRenderTree());

    RenderView& renderView = *document.renderView();

    // HTML5 states that seamless iframes should replace default CSS values
    // with values inherited from the containing iframe element. However,
    // some values (such as the case of designMode = "on") still need to
    // be set by this "document style".
    auto documentStyle = RenderStyle::create();
    bool seamlessWithParent = document.shouldDisplaySeamlesslyWithParent();
    if (seamlessWithParent) {
        RenderStyle* iframeStyle = document.seamlessParentIFrame()->renderStyle();
        if (iframeStyle)
            documentStyle.get().inheritFrom(iframeStyle);
    }

    // FIXME: It's not clear which values below we want to override in the seamless case!
    documentStyle.get().setDisplay(BLOCK);
    if (!seamlessWithParent) {
        documentStyle.get().setRTLOrdering(document.visuallyOrdered() ? VisualOrder : LogicalOrder);
        documentStyle.get().setZoom(!document.printing() ? renderView.frame().pageZoomFactor() : 1);
        documentStyle.get().setPageScaleTransform(renderView.frame().frameScaleFactor());
        documentStyle.get().setLocale(document.contentLanguage());
    }
    // This overrides any -webkit-user-modify inherited from the parent iframe.
    documentStyle.get().setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONLY);

    Element* docElement = document.documentElement();
    RenderObject* docElementRenderer = docElement ? docElement->renderer() : 0;
    if (docElementRenderer) {
        // Use the direction and writing-mode of the body to set the
        // viewport's direction and writing-mode unless the property is set on the document element.
        // If there is no body, then use the document element.
        RenderObject* bodyRenderer = document.body() ? document.body()->renderer() : 0;
        if (bodyRenderer && !document.writingModeSetOnDocumentElement())
            documentStyle.get().setWritingMode(bodyRenderer->style()->writingMode());
        else
            documentStyle.get().setWritingMode(docElementRenderer->style()->writingMode());
        if (bodyRenderer && !document.directionSetOnDocumentElement())
            documentStyle.get().setDirection(bodyRenderer->style()->direction());
        else
            documentStyle.get().setDirection(docElementRenderer->style()->direction());
    }

    const Pagination& pagination = renderView.frameView().pagination();
    if (pagination.mode != Pagination::Unpaginated) {
        documentStyle.get().setColumnStylesFromPaginationMode(pagination.mode);
        documentStyle.get().setColumnGap(pagination.gap);
        if (renderView.hasColumns())
            renderView.updateColumnInfoFromStyle(&documentStyle.get());
    }

    // Seamless iframes want to inherit their font from their parent iframe, so early return before setting the font.
    if (seamlessWithParent)
        return documentStyle;

    const Settings& settings = renderView.frame().settings();

    FontDescription fontDescription;
    fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle.get().locale()));
    fontDescription.setUsePrinterFont(document.printing() || !settings.screenFontSubstitutionEnabled());
    fontDescription.setRenderingMode(settings.fontRenderingMode());
    const AtomicString& standardFont = settings.standardFontFamily(fontDescription.script());
    if (!standardFont.isEmpty()) {
        fontDescription.setGenericFamily(FontDescription::StandardFamily);
        fontDescription.setOneFamily(standardFont);
    }
    fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
    int size = fontSizeForKeyword(CSSValueMedium, false, document);
    fontDescription.setSpecifiedSize(size);
    bool useSVGZoomRules = document.isSVGDocument();
    fontDescription.setComputedSize(computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), useSVGZoomRules, &documentStyle.get(), document));

    FontOrientation fontOrientation;
    NonCJKGlyphOrientation glyphOrientation;
    documentStyle.get().getFontAndGlyphOrientation(fontOrientation, glyphOrientation);
    fontDescription.setOrientation(fontOrientation);
    fontDescription.setNonCJKGlyphOrientation(glyphOrientation);

    documentStyle.get().setFontDescription(fontDescription);

    CSSFontSelector* fontSelector = document.styleResolverIfExists() ? document.styleResolverIfExists()->fontSelector() : 0;
    documentStyle.get().font().update(fontSelector);

    return documentStyle;
}