зеркало из https://github.com/mozilla/moz-skia.git
Remove unused complex script support from android builds
R=reed@google.com Author: djsollen@google.com Review URL: https://chromiumcodereview.appspot.com/14942003 git-svn-id: http://skia.googlecode.com/svn/trunk@9011 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
da5e6e9098
Коммит
e4faa14de8
|
@ -11,60 +11,6 @@
|
|||
|
||||
#include "SkTypeface.h"
|
||||
|
||||
enum FallbackScripts {
|
||||
kArabic_FallbackScript,
|
||||
kArmenian_FallbackScript,
|
||||
kBengali_FallbackScript,
|
||||
kDevanagari_FallbackScript,
|
||||
kEthiopic_FallbackScript,
|
||||
kGeorgian_FallbackScript,
|
||||
kHebrewRegular_FallbackScript,
|
||||
kHebrewBold_FallbackScript,
|
||||
kKannada_FallbackScript,
|
||||
kMalayalam_FallbackScript,
|
||||
kTamilRegular_FallbackScript,
|
||||
kTamilBold_FallbackScript,
|
||||
kThai_FallbackScript,
|
||||
kTelugu_FallbackScript,
|
||||
kFallbackScriptNumber
|
||||
};
|
||||
|
||||
// This particular mapping will be removed after WebKit is updated to use the
|
||||
// new mappings. No new caller should use the kTamil_FallbackScript but rather
|
||||
// the more specific Tamil scripts in the standard enum.
|
||||
#define kTamil_FallbackScript kTamilRegular_FallbackScript
|
||||
|
||||
#define SkTypeface_ValidScript(s) (s >= 0 && s < kFallbackScriptNumber)
|
||||
|
||||
/**
|
||||
* Return a new typeface for a fallback script. If the script is
|
||||
* not valid, or can not map to a font, returns null.
|
||||
* @param script The script id.
|
||||
* @return reference to the matching typeface. Caller must call
|
||||
* unref() when they are done.
|
||||
*/
|
||||
SK_API SkTypeface* SkCreateTypefaceForScript(FallbackScripts script);
|
||||
|
||||
/**
|
||||
* Return the string representation for the fallback script on Android.
|
||||
* If the script is not valid, returns null.
|
||||
*/
|
||||
SK_API const char* SkGetFallbackScriptID(FallbackScripts script);
|
||||
|
||||
/**
|
||||
* Return the fallback script enum for the ID on Android.
|
||||
* If the ID is not valid, or can not map to a fallback
|
||||
* script, returns kFallbackScriptNumber.
|
||||
*/
|
||||
SK_API FallbackScripts SkGetFallbackScriptFromID(const char* id);
|
||||
|
||||
/**
|
||||
* Return a new typeface of the font in the fallback font list containing
|
||||
* the specified chararacter. If no typeface is found, returns null.
|
||||
*/
|
||||
SK_API SkTypeface* SkCreateFallbackTypefaceForChar(SkUnichar uni,
|
||||
SkTypeface::Style style);
|
||||
|
||||
/**
|
||||
* Get the family name of the font in the fallback font list containing
|
||||
* the specified chararacter. if no font is found, returns false.
|
||||
|
|
|
@ -878,40 +878,6 @@ SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
|
|||
// Function from SkTypeface_android.h
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct FBScriptInfo {
|
||||
const FallbackScripts fScript;
|
||||
const char* fScriptID;
|
||||
const SkTypeface::Style fStyle;
|
||||
const SkUnichar fChar; // representative character for that script type
|
||||
SkFontID fFontID;
|
||||
};
|
||||
|
||||
#define SK_DEFINE_SCRIPT_ENTRY(script, style, unichar) \
|
||||
{ script, #script, style, unichar, 0 }
|
||||
|
||||
static FBScriptInfo gFBScriptInfo[] = {
|
||||
SK_DEFINE_SCRIPT_ENTRY(kArabic_FallbackScript, SkTypeface::kNormal, 0x0627),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kArmenian_FallbackScript, SkTypeface::kNormal, 0x0531),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kBengali_FallbackScript, SkTypeface::kNormal, 0x0981),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kDevanagari_FallbackScript, SkTypeface::kNormal, 0x0901),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kEthiopic_FallbackScript, SkTypeface::kNormal, 0x1200),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kGeorgian_FallbackScript, SkTypeface::kNormal, 0x10A0),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kHebrewRegular_FallbackScript, SkTypeface::kNormal, 0x0591),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kHebrewBold_FallbackScript, SkTypeface::kBold, 0x0591),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kKannada_FallbackScript, SkTypeface::kNormal, 0x0C90),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kMalayalam_FallbackScript, SkTypeface::kNormal, 0x0D10),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kTamilRegular_FallbackScript, SkTypeface::kNormal, 0x0B82),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kTamilBold_FallbackScript, SkTypeface::kBold, 0x0B82),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kThai_FallbackScript, SkTypeface::kNormal, 0x0E01),
|
||||
SK_DEFINE_SCRIPT_ENTRY(kTelugu_FallbackScript, SkTypeface::kNormal, 0x0C10),
|
||||
};
|
||||
|
||||
static bool gFBScriptInitialized = false;
|
||||
static const int gFBScriptInfoCount = sizeof(gFBScriptInfo) / sizeof(FBScriptInfo);
|
||||
|
||||
// ensure that if any value is added to the public enum it is also added here
|
||||
SK_COMPILE_ASSERT(gFBScriptInfoCount == kFallbackScriptNumber, FBScript_count_mismatch);
|
||||
|
||||
// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
|
||||
static bool typefaceContainsChar(SkTypeface* face, SkUnichar uni) {
|
||||
SkPaint paint;
|
||||
|
@ -940,103 +906,6 @@ static SkTypeface* findFallbackTypefaceForChar(SkUnichar uni) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
|
||||
static SkFontID findFallbackFontIDForChar(SkUnichar uni, SkTypeface::Style style) {
|
||||
const SkTypeface* tf = findFallbackTypefaceForChar(uni);
|
||||
if (!tf) {
|
||||
return 0;
|
||||
}
|
||||
return find_typeface(tf, style)->uniqueID();
|
||||
}
|
||||
|
||||
// this function can't be called if the gFamilyHeadAndNameListMutex is already locked
|
||||
static void initFBScriptInfo() {
|
||||
if (gFBScriptInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure the system fonts are loaded
|
||||
gFamilyHeadAndNameListMutex.acquire();
|
||||
load_system_fonts();
|
||||
gFamilyHeadAndNameListMutex.release();
|
||||
|
||||
for (int i = 0; i < gFBScriptInfoCount; i++) {
|
||||
FBScriptInfo& scriptInfo = gFBScriptInfo[i];
|
||||
// selects the best available style for the desired font. However, if
|
||||
// bold is requested and no bold font exists for the typeface containing
|
||||
// the character the next best style is chosen (e.g. normal).
|
||||
scriptInfo.fFontID = findFallbackFontIDForChar(scriptInfo.fChar, scriptInfo.fStyle);
|
||||
#if SK_DEBUG_FONTS
|
||||
SkDebugf("gFBScriptInfo[%s] --> %d", scriptInfo.fScriptID, scriptInfo.fFontID);
|
||||
#endif
|
||||
}
|
||||
// mark the value as initialized so we don't repeat our work unnecessarily
|
||||
gFBScriptInitialized = true;
|
||||
}
|
||||
|
||||
SkTypeface* SkCreateTypefaceForScript(FallbackScripts script) {
|
||||
if (!SkTypeface_ValidScript(script)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ensure that our table is populated
|
||||
initFBScriptInfo();
|
||||
|
||||
FBScriptInfo& scriptInfo = gFBScriptInfo[script];
|
||||
|
||||
// ensure the element with that index actually maps to the correct script
|
||||
SkASSERT(scriptInfo.fScript == script);
|
||||
|
||||
// if a suitable script could not be found then return NULL
|
||||
if (scriptInfo.fFontID == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
|
||||
|
||||
// retrieve the typeface the corresponds to this fontID
|
||||
SkTypeface* tf = find_from_uniqueID(scriptInfo.fFontID);
|
||||
// we ref(), since the semantic is to return a new instance
|
||||
tf->ref();
|
||||
return tf;
|
||||
}
|
||||
|
||||
const char* SkGetFallbackScriptID(FallbackScripts script) {
|
||||
for (int i = 0; i < gFBScriptInfoCount; i++) {
|
||||
if (gFBScriptInfo[i].fScript == script) {
|
||||
return gFBScriptInfo[i].fScriptID;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FallbackScripts SkGetFallbackScriptFromID(const char* id) {
|
||||
for (int i = 0; i < gFBScriptInfoCount; i++) {
|
||||
if (strcmp(gFBScriptInfo[i].fScriptID, id) == 0) {
|
||||
return gFBScriptInfo[i].fScript;
|
||||
}
|
||||
}
|
||||
return kFallbackScriptNumber; // Use kFallbackScriptNumber as an invalid value.
|
||||
}
|
||||
|
||||
SkTypeface* SkCreateFallbackTypefaceForChar(SkUnichar uni,
|
||||
SkTypeface::Style style) {
|
||||
{
|
||||
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
|
||||
load_system_fonts();
|
||||
}
|
||||
|
||||
SkTypeface* tf = findFallbackTypefaceForChar(uni);
|
||||
if (!tf) {
|
||||
return NULL;
|
||||
}
|
||||
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
|
||||
tf = find_typeface(tf, style);
|
||||
// we ref(), since the semantic is to return a new instance
|
||||
tf->ref();
|
||||
return tf;
|
||||
}
|
||||
|
||||
bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
|
||||
SkASSERT(name);
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче