blob: 4df8d7e7252eeca9980b82322e669628257a3d01 [file] [log] [blame]
djsollen@google.combfae9d32013-05-21 16:53:50 +00001/*
2 * Copyright 2011 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKFONTCONFIGPARSER_ANDROID_H_
9#define SKFONTCONFIGPARSER_ANDROID_H_
10
Derek Sollenbergerda7a9442014-08-06 16:34:40 -040011#include "SkTypes.h"
12
13#include "SkPaintOptionsAndroid.h"
djsollen@google.com9a70f342013-06-25 18:07:45 +000014#include "SkString.h"
djsollen@google.combfae9d32013-05-21 16:53:50 +000015#include "SkTDArray.h"
16
17struct FontFileInfo {
tomhudson07544752014-08-05 13:35:00 -070018 FontFileInfo() : fIndex(0), fWeight(0) { }
bungeman8d84c992014-07-24 08:05:09 -070019
commit-bot@chromium.org31db71d2014-04-04 18:14:39 +000020 SkString fFileName;
bungeman8d84c992014-07-24 08:05:09 -070021 int fIndex;
Derek Sollenbergerda7a9442014-08-06 16:34:40 -040022 SkPaintOptionsAndroid fPaintOptions;
tomhudson07544752014-08-05 13:35:00 -070023 int fWeight;
djsollen@google.combfae9d32013-05-21 16:53:50 +000024};
25
26/**
27 * The FontFamily data structure is created during parsing and handed back to
28 * Skia to fold into its representation of font families. fNames is the list of
29 * font names that alias to a font family. fontFileArray is the list of information
30 * about each file. Order is the priority order for the font. This is
31 * used internally to determine the order in which to place fallback fonts as
32 * they are read from the configuration files.
33 */
34struct FontFamily {
tomhudson07544752014-08-05 13:35:00 -070035 FontFamily()
Derek Sollenbergerda7a9442014-08-06 16:34:40 -040036 : fVariant(SkPaintOptionsAndroid::kDefault_Variant)
tomhudson07544752014-08-05 13:35:00 -070037 , order(-1)
38 , fIsFallbackFont(false) { }
djsollen@google.combfae9d32013-05-21 16:53:50 +000039
tomhudson07544752014-08-05 13:35:00 -070040 SkTArray<SkString> fNames;
41 SkTArray<FontFileInfo> fFontFiles;
42 SkLanguage fLanguage;
Derek Sollenbergerda7a9442014-08-06 16:34:40 -040043 SkPaintOptionsAndroid::FontVariant fVariant;
tomhudson07544752014-08-05 13:35:00 -070044 int order; // only used internally by SkFontConfigParser
45 bool fIsFallbackFont;
djsollen@google.combfae9d32013-05-21 16:53:50 +000046};
47
48namespace SkFontConfigParser {
49
50/**
51 * Parses all system font configuration files and returns the results in an
52 * array of FontFamily structures.
53 */
54void GetFontFamilies(SkTDArray<FontFamily*> &fontFamilies);
55
56/**
57 * Parses all test font configuration files and returns the results in an
58 * array of FontFamily structures.
59 */
60void GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies,
61 const char* testMainConfigFile,
62 const char* testFallbackConfigFile);
63
djsollen@google.combfae9d32013-05-21 16:53:50 +000064} // SkFontConfigParser namespace
65
66#endif /* SKFONTCONFIGPARSER_ANDROID_H_ */