Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fb73ab8 authored by Victoria Lease's avatar Victoria Lease Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE Han Preference" into jb-mr1-dev

parents 80618d66 ac1cbaf2
Loading
Loading
Loading
Loading
+46 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include <ScopedUtfChars.h>

#include "SkBlurDrawLooper.h"
#include "SkColorFilter.h"
@@ -30,6 +31,7 @@
#include "SkShader.h"
#include "SkTypeface.h"
#include "SkXfermode.h"
#include "unicode/uloc.h"
#include "unicode/ushape.h"
#include "TextLayout.h"

@@ -254,11 +256,51 @@ public:
        obj->setTextAlign(align);
    }

    // generate bcp47 identifier for the supplied locale
    static void toLanguageTag(char* output, size_t outSize,
            const char* locale) {
        if (output == NULL || outSize <= 0) {
            return;
        }
        if (locale == NULL) {
            output[0] = '\0';
            return;
        }
        char canonicalChars[ULOC_FULLNAME_CAPACITY];
        UErrorCode uErr = U_ZERO_ERROR;
        uloc_canonicalize(locale, canonicalChars, ULOC_FULLNAME_CAPACITY,
                &uErr);
        if (U_SUCCESS(uErr)) {
            char likelyChars[ULOC_FULLNAME_CAPACITY];
            uErr = U_ZERO_ERROR;
            uloc_addLikelySubtags(canonicalChars, likelyChars,
                    ULOC_FULLNAME_CAPACITY, &uErr);
            if (U_SUCCESS(uErr)) {
                uErr = U_ZERO_ERROR;
                uloc_toLanguageTag(likelyChars, output, outSize, FALSE, &uErr);
                if (U_SUCCESS(uErr)) {
                    return;
                } else {
                    ALOGD("uloc_toLanguageTag(\"%s\") failed: %s", likelyChars,
                            u_errorName(uErr));
                }
            } else {
                ALOGD("uloc_addLikelySubtags(\"%s\") failed: %s",
                        canonicalChars, u_errorName(uErr));
            }
        } else {
            ALOGD("uloc_canonicalize(\"%s\") failed: %s", locale,
                    u_errorName(uErr));
        }
        // unable to build a proper language identifier
        output[0] = '\0';
    }

    static void setTextLocale(JNIEnv* env, jobject clazz, SkPaint* obj, jstring locale) {
        const char* localeArray = env->GetStringUTFChars(locale, NULL);
        SkString skLocale(localeArray);
        obj->setTextLocale(skLocale);
        env->ReleaseStringUTFChars(locale, localeArray);
        ScopedUtfChars localeChars(env, locale);
        char langTag[ULOC_FULLNAME_CAPACITY];
        toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, localeChars.c_str());
        obj->setLanguage(SkLanguage(langTag));
    }

    static jfloat getTextSize(JNIEnv* env, jobject paint) {
+15 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "TextLayoutCache.h"
#include "TextLayout.h"
#include "SkFontHost.h"
#include "SkTypeface_android.h"
#include <unicode/unistr.h>
#include <unicode/normlzr.h>
#include <unicode/uchar.h>
@@ -224,7 +225,7 @@ void TextLayoutCache::dumpCacheStats() {
 */
TextLayoutCacheKey::TextLayoutCacheKey(): text(NULL), start(0), count(0), contextCount(0),
        dirFlags(0), typeface(NULL), textSize(0), textSkewX(0), textScaleX(0), flags(0),
        hinting(SkPaint::kNo_Hinting)  {
        hinting(SkPaint::kNo_Hinting), variant(SkPaint::kDefault_Variant), language()  {
}

TextLayoutCacheKey::TextLayoutCacheKey(const SkPaint* paint, const UChar* text,
@@ -237,6 +238,8 @@ TextLayoutCacheKey::TextLayoutCacheKey(const SkPaint* paint, const UChar* text,
    textScaleX = paint->getTextScaleX();
    flags = paint->getFlags();
    hinting = paint->getHinting();
    variant = paint->getFontVariant();
    language = paint->getLanguage();
}

TextLayoutCacheKey::TextLayoutCacheKey(const TextLayoutCacheKey& other) :
@@ -251,7 +254,9 @@ TextLayoutCacheKey::TextLayoutCacheKey(const TextLayoutCacheKey& other) :
        textSkewX(other.textSkewX),
        textScaleX(other.textScaleX),
        flags(other.flags),
        hinting(other.hinting) {
        hinting(other.hinting),
        variant(other.variant),
        language(other.language) {
    if (other.text) {
        textCopy.setTo(other.text, other.contextCount);
    }
@@ -288,6 +293,12 @@ int TextLayoutCacheKey::compare(const TextLayoutCacheKey& lhs, const TextLayoutC
    deltaInt = lhs.dirFlags - rhs.dirFlags;
    if (deltaInt) return (deltaInt);

    deltaInt = lhs.variant - rhs.variant;
    if (deltaInt) return (deltaInt);

    if (lhs.language < rhs.language) return -1;
    if (lhs.language > rhs.language) return +1;

    return memcmp(lhs.getText(), rhs.getText(), lhs.contextCount * sizeof(UChar));
}

@@ -615,6 +626,8 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars
    mShapingPaint.setTextScaleX(paint->getTextScaleX());
    mShapingPaint.setFlags(paint->getFlags());
    mShapingPaint.setHinting(paint->getHinting());
    mShapingPaint.setFontVariant(paint->getFontVariant());
    mShapingPaint.setLanguage(paint->getLanguage());

    // Split the BiDi run into Script runs. Harfbuzz will populate the pos, length and script
    // into the shaperItem
+3 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
#include <SkTemplates.h>
#include <SkUtils.h>
#include <SkAutoKern.h>
#include "SkTypeface_android.h"
#include <SkLanguage.h>

#include <unicode/ubidi.h>
#include <unicode/ushape.h>
@@ -102,6 +102,8 @@ private:
    SkScalar textScaleX;
    uint32_t flags;
    SkPaint::Hinting hinting;
    SkPaint::FontVariant variant;
    SkLanguage language;

    inline const UChar* getText() const { return text ? text : textCopy.string(); }

+1 −10
Original line number Diff line number Diff line
@@ -76,14 +76,6 @@ LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := fallback_fonts-ja.xml
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
include $(BUILD_PREBUILT)

droidsans_fallback_src := DroidSansFallbackFull.ttf
extra_font_files := \
	DroidSans.ttf \
@@ -91,8 +83,7 @@ extra_font_files := \
	DroidSansEthiopic-Regular.ttf \
	DroidSansTamil-Regular.ttf \
	DroidSansTamil-Bold.ttf \
	MTLmr3m.ttf \
	fallback_fonts-ja.xml
	MTLmr3m.ttf
endif  # SMALLER_FONT_FOOTPRINT

################################

data/fonts/fallback_fonts-ja.xml

deleted100644 → 0
+0 −121
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Fallback Fonts

    This file specifies the fonts, and the priority order, that will be searched for any
    glyphs not handled by the default fonts specified in /system/etc/system_fonts.xml.
    Each entry consists of a family tag and a list of files (file names) which support that
    family. The fonts for each family are listed in the order of the styles that they
    handle (the order is: regular, bold, italic, and bold-italic). The order in which the
    families are listed in this file represents the order in which these fallback fonts
    will be searched for glyphs that are not supported by the default system fonts (which are
    found in /system/etc/system_fonts.xml).

    Note that there is not nameset for fallback fonts, unlike the fonts specified in
    system_fonts.xml. The ability to support specific names in fallback fonts may be supported
    in the future. For now, the lack of files entries here is an indicator to the system that
    these are fallback fonts, instead of default named system fonts.

    There is another optional file in /vendor/etc/fallback_fonts.xml. That file can be used to
    provide references to other font families that should be used in addition to the default
    fallback fonts. That file can also specify the order in which the fallback fonts should be
    searched, to ensure that a vendor-provided font will be used before another fallback font
    which happens to handle the same glyph.

    Han languages (Chinese, Japanese, and Korean) share a common range of unicode characters;
    their ordering in the fallback or vendor files gives priority to the first in the list.
    Locale-specific ordering can be configured by adding language and region codes to the end
    of the filename (e.g. /system/etc/fallback_fonts-ja.xml). When no region code is used,
    as with this example, all regions are matched. Use separate files for each supported locale.
    The standard fallback file (fallback_fonts.xml) is used when a locale does not have its own
    file. All fallback files must contain the same complete set of fonts; only their ordering
    can differ.
-->
<familyset>
    <family>
        <fileset>
            <file variant="elegant">DroidNaskh-Regular.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file variant="compact">DroidNaskh-Regular-SystemUI.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansEthiopic-Regular.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansHebrew-Regular.ttf</file>
            <file>DroidSansHebrew-Bold.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansThai.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansArmenian.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansGeorgian.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansDevanagari-Regular.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansTamil-Regular.ttf</file>
            <file>DroidSansTamil-Bold.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>AnjaliNewLipi-light.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>Lohit-Bengali.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>Lohit-Kannada.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>AndroidEmoji.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>MTLmr3m.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansFallback.ttf</file>
        </fileset>
    </family>
    <!--
        Fonts below this point have problematic glyphs and should not be moved
        higher in the fallback list until those glyphs have been fixed.
    -->
    <family>
        <fileset>
            <file>Lohit-Telugu.ttf</file> <!-- masks U+FFBC-10007 -->
        </fileset>
    </family>
</familyset>
Loading