chromium/third_party/skia/src/ports/SkFontMgr_android_parser.cpp

/*
 * Copyright 2011 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

// Despite the name and location, this is portable code.

#include "include/core/SkFontMgr.h"
#include "include/core/SkStream.h"
#include "include/private/base/SkFixed.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/base/SkTLogic.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkTSearch.h"
#include "src/core/SkOSFile.h"
#include "src/ports/SkFontMgr_android_parser.h"

#include <expat.h>

#include <stdlib.h>
#include <string.h>

#include <memory>

usingnamespaceskia_private;

#define LMP_SYSTEM_FONTS_FILE
#define OLD_SYSTEM_FONTS_FILE
#define FALLBACK_FONTS_FILE
#define VENDOR_FONTS_FILE

#define LOCALE_FALLBACK_FONTS_SYSTEM_DIR
#define LOCALE_FALLBACK_FONTS_VENDOR_DIR
#define LOCALE_FALLBACK_FONTS_PREFIX
#define LOCALE_FALLBACK_FONTS_SUFFIX

#ifndef SK_FONT_FILE_PREFIX
#define SK_FONT_FILE_PREFIX
#endif

/**
 * This file contains TWO 'familyset' handlers:
 * One for JB and earlier which works with
 *   /system/etc/system_fonts.xml
 *   /system/etc/fallback_fonts.xml
 *   /vendor/etc/fallback_fonts.xml
 *   /system/etc/fallback_fonts-XX.xml
 *   /vendor/etc/fallback_fonts-XX.xml
 * and the other for LMP and later which works with
 *   /system/etc/fonts.xml
 *
 * If the 'familyset' 'version' attribute is 21 or higher the LMP parser is used, otherwise the JB.
 */

struct FamilyData;

struct TagHandler {};

/** Represents the current parsing state. */
struct FamilyData {};

static bool memeq(const char* s1, const char* s2, size_t n1, size_t n2) {}
#define MEMEQ(c, s, n)

#define ATTS_NON_NULL(a, i)

#define SK_FONTMGR_ANDROID_PARSER_PREFIX

#define SK_FONTCONFIGPARSER_WARNING(message, ...)

static bool is_whitespace(char c) {}

static void trim_string(SkString* s) {}

static void parse_space_separated_languages(const char* value, size_t valueLen,
                                            TArray<SkLanguage, true>& languages)
{}

namespace lmpParser {

static const TagHandler axisHandler =& file =axisTag =axisStyleValue =bool axisTagIsValid =bool axisStyleValueIsValid =i =const char* name =const char* value =nameLen =valueLen =int j =auto& coordinate =;

static const TagHandler fontHandler =& file =fallbackFor;
        for (size_t i =const char* name =const char* value =nameLen =valueLen =::unique_ptr<FontFamily>* fallbackFamily =::unique_ptr<FontFamily> newFallbackFamily(
                        new FontFamily(self->fCurrentFamily->fBasePath, true));
                fallbackFamily =len =* self =;

static const TagHandler familyHandler =* family =i =const char* name =const char* value =nameLen =valueLen =tolc(value);
                family->fNames.push_back().set(tolc.lc());
                family->fIsFallbackFont =len =;

static FontFamily* find_family(FamilyData* self, const SkString& familyName) {}

static const TagHandler aliasHandler =aliasName;
        SkString to;
        int weight =i =const char* name =const char* value =nameLen =tolc(value);
                aliasName.set(tolc.lc());
            } else if (MEMEQ("to", name, nameLen)) {} else if (MEMEQ("weight", name, nameLen)) {}
        }

        // Assumes that the named family is already declared
        FontFamily* targetFamily =* family =int i =;

static const TagHandler familySetHandler =len =;

}  // namespace lmpParser

namespace jbParser {

static const TagHandler fileHandler =& currentFamily =& newFileInfo =i =const char* name =const char* value =nameLen =valueLen =const FontVariant prevVariant =currentLanguage =bool showWarning =* self =;

static const TagHandler fileSetHandler =len =;

static const TagHandler nameHandler =* self =tolc(s, len);
        self->fCurrentFamily->fNames.back().append(tolc.lc(), len);
    }
};

static const TagHandler nameSetHandler =len =;

static const TagHandler familyHandler =i =const char* value =len =;

static const TagHandler familySetHandler =len =;

} // namespace jbParser

static const TagHandler topLevelHandler =len =i =const char* name =nameLen =const char* value =;

static void XMLCALL start_element_handler(void *data, const char *tag, const char **attributes) {}

static void XMLCALL end_element_handler(void* data, const char* tag) {}

static void XMLCALL xml_entity_decl_handler(void *data,
                                            const XML_Char *entityName,
                                            int is_parameter_entity,
                                            const XML_Char *value,
                                            int value_length,
                                            const XML_Char *base,
                                            const XML_Char *systemId,
                                            const XML_Char *publicId,
                                            const XML_Char *notationName)
{}

static const XML_Memory_Handling_Suite sk_XML_alloc =;

/**
 * This function parses the given filename and stores the results in the given
 * families array. Returns the version of the file, negative if the file does not exist.
 */
static int parse_config_file(const char* filename, SkTDArray<FontFamily*>& families,
                             const SkString& basePath, bool isFallback)
{}

/** Returns the version of the system font file actually found, negative if none. */
static int append_system_font_families(SkTDArray<FontFamily*>& fontFamilies,
                                       const SkString& basePath)
{}

/**
 * In some versions of Android prior to Android 4.2 (JellyBean MR1 at API
 * Level 17) the fallback fonts for certain locales were encoded in their own
 * XML files with a suffix that identified the locale.  We search the provided
 * directory for those files,add all of their entries to the fallback chain, and
 * include the locale as part of each entry.
 */
static void append_fallback_font_families_for_locale(SkTDArray<FontFamily*>& fallbackFonts,
                                                     const char* dir,
                                                     const SkString& basePath)
{}

static void append_system_fallback_font_families(SkTDArray<FontFamily*>& fallbackFonts,
                                                 const SkString& basePath)
{}

static void mixin_vendor_fallback_font_families(SkTDArray<FontFamily*>& fallbackFonts,
                                                const SkString& basePath)
{}

void SkFontMgr_Android_Parser::GetSystemFontFamilies(SkTDArray<FontFamily*>& fontFamilies) {}

void SkFontMgr_Android_Parser::GetCustomFontFamilies(SkTDArray<FontFamily*>& fontFamilies,
                                                     const SkString& basePath,
                                                     const char* fontsXml,
                                                     const char* fallbackFontsXml,
                                                     const char* langFallbackFontsDir)
{}

SkLanguage SkLanguage::getParent() const {}