35#ifdef SK_TYPEFACE_FACTORY_FONTATIONS
51 int countOfFallbackFonts = 0;
52 for (
int i = 0; i < fontFamilies.
size(); i++) {
53 if (fontFamilies[i]->fIsFallbackFont) {
54 countOfFallbackFonts++;
57 return countOfFallbackFonts;
62 return (
'a' <= c && c <=
'z') || (
'A' <= c && c <=
'Z');
67 return (
'0' <= c && c <=
'9');
75 !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), firstExpectedFile));
79 for (
const auto& fontFamily : fontFamilies) {
80 for (
const auto& lang : fontFamily->fLanguages) {
81 const SkString& langString = lang.getTag();
82 for (
size_t i = 0; i < langString.
size(); ++i) {
83 int c = langString[i];
92 for (
int i = 0; i < fontFamilies.
size(); ++i) {
94 for (
int j = 0; j < family.
fFonts.
size(); ++j) {
97 file.fFileName[0] >=
'A' &&
98 file.fFileName[0] <=
'Z');
104 for (
int j = 0; j < fontFamily.
fFonts.
size(); ++j) {
109 (
char)((coordinate.axis >> 24) & 0xFF),
110 (
char)((coordinate.axis >> 16) & 0xFF),
111 (
char)((coordinate.axis >> 8) & 0xFF),
112 (
char)((coordinate.axis) & 0xFF),
120 if (!FLAGS_verboseFontMgr) {
124 SkDebugf(
"\n--- Dumping %s\n", label);
125 for (
int i = 0; i < fontFamilies.
size(); ++i) {
127 switch(fontFamilies[i]->fVariant) {
132 SkDebugf(
" basePath %s\n", fontFamilies[i]->fBasePath.c_str());
133 if (!fontFamilies[i]->fLanguages.
empty()) {
135 for (
const auto& lang : fontFamilies[i]->fLanguages) {
136 SkDebugf(
" %s", lang.getTag().c_str());
140 for (
int j = 0; j < fontFamilies[i]->fNames.
size(); ++j) {
141 SkDebugf(
" name %s\n", fontFamilies[i]->fNames[j].c_str());
144 for (
const auto& [
unused, fallbackFamily] : fontFamilies[i]->fallbackFamilies) {
145 SkDebugf(
" Fallback for: %s\n", fallbackFamily->fFallbackFor.c_str());
153 double low,
double high,
double inc)
155 double SK_FixedMax_double = nextafter(1 << (
sizeof(
T) * CHAR_BIT -
N - 1), 0.0);
156 double SK_FixedEpsilon_double = (1.0 / (1 <<
N));
159 for (
double f = low; f < high; f += inc) {
163 sprintf(
buffer,
"%.20f", f);
165 bool b = parse_fixed<N>(
buffer, &fix);
167 double f2 = fix * SK_FixedEpsilon_double;
168 double error = fabs(f - f2);
170 maxError = std::max(maxError,
error);
181 test_parse_fixed_r<27, int32_t>(
reporter, -8.1, -7.9, 0.000001);
182 test_parse_fixed_r<27, int32_t>(
reporter, -0.1, 0.1, 0.000001);
183 test_parse_fixed_r<27, int32_t>(
reporter, 7.9, 8.1, 0.000001);
184 test_parse_fixed_r<16, int32_t>(
reporter, -0.125, 0.125, 1.0 / (1 << 19));
185 test_parse_fixed_r<16, int32_t>(
reporter, -32768.125, -32766.875, 1.0 / (1 << 17));
186 test_parse_fixed_r<16, int32_t>(
reporter, 32766.875, 32768.125, 1.0 / (1 << 17));
187 test_parse_fixed_r<16, int32_t>(
reporter, -1.1, 1.1, 0.0001);
199#ifdef SK_TYPEFACE_FACTORY_FONTATIONS
200#define DEF_TEST_FONTATIONS(name, reporter) \
201 DEF_TEST(name##Fontations, reporter) { name(reporter, std::make_unique<SkFontScanner_Fontations>()); }
203#define DEF_TEST_FONTATIONS(name, reporter)
206#define DEF_TEST_SCANNERS(name, reporter) \
207 static void name(skiatest::Reporter*, std::unique_ptr<SkFontScanner>); \
208 DEF_TEST(name, reporter) { name(reporter, std::make_unique<SkFontScanner_FreeType>()); } \
209 DEF_TEST_FONTATIONS(name, reporter) \
210 void name(skiatest::Reporter* reporter, std::unique_ptr<SkFontScanner> fs)
215 bool resourcesMissing =
false;
223 if (preV17FontFamilies.
size() > 0) {
230 resourcesMissing =
true;
235 preV17FontFamilies.
reset();
245 if (v17FontFamilies.
size() > 0) {
252 resourcesMissing =
true;
257 v17FontFamilies.
reset();
266 if (v22FontFamilies.
size() > 0) {
273 resourcesMissing =
true;
278 v22FontFamilies.
reset();
280 if (resourcesMissing) {
281 SkDebugf(
"---- Resource files missing for FontConfigParser test\n");
286 constexpr char fontsXmlFilename[] =
"fonts/fonts.xml";
308 for (
int y = 0;
y <
test.height(); ++
y) {
309 for (
int x = 0;
x <
test.width(); ++
x) {
312 if (refColor != testColor) {
321 constexpr char fontsXmlFilename[] =
"fonts/fonts.xml";
343 SkCanvas canvasStream(bitmapStream);
353 paint.setAntiAlias(
true);
354 constexpr float kTextSize = 20;
356 std::unique_ptr<SkStreamAsset> distortableStream(
358 if (!distortableStream) {
365 for (
int i = 0; i < 10; ++i) {
369 coordinates[] = {{tag, styleValue}};
371 position = {coordinates, std::size(coordinates)};
381 typeface->makeClone(
SkFontArguments().setVariationDesignPosition(position)), kTextSize);
384 constexpr char text[] =
"abc";
398 constexpr char fontsXmlFilename[] =
"fonts/fonts.xml";
#define DECLARE_bool(name)
static bool isDIGIT(int c)
static void test_parse_fixed(skiatest::Reporter *reporter)
static void DumpLoadedFonts(SkTDArray< FontFamily * > fontFamilies, const char *label)
static void DumpFiles(const FontFamily &fontFamily)
#define DEF_TEST_SCANNERS(name, reporter)
static bool isALPHA(int c)
static double test_parse_fixed_r(skiatest::Reporter *reporter, double low, double high, double inc)
static void ValidateLoadedFonts(SkTDArray< FontFamily * > fontFamilies, const char *firstExpectedFile, skiatest::Reporter *reporter)
static bool bitmap_compare(const SkBitmap &ref, const SkBitmap &test)
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
SkString GetResourcePath(const char *resource)
constexpr SkColor SK_ColorGRAY
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts *custom)
bool sk_exists(const char *path, SkFILE_Flags=(SkFILE_Flags) 0)
#define SkDoubleToScalar(x)
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
#define REPORTER_ASSERT(r, cond,...)
SkColor getColor(int x, int y) const
void allocN32Pixels(int width, int height, bool isOpaque=false)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
sk_sp< SkTypeface > matchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const
sk_sp< SkTypeface > makeFromStream(std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const
sk_sp< SkTypeface > legacyMakeTypeface(const char familyName[], SkFontStyle style) const
static constexpr SkFontStyle Bold()
void setEdging(Edging edging)
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
const char * c_str() const
sk_sp< SkFontMgr > fontMgr
static const uint8_t buffer[]
const uint8_t uint32_t uint32_t GError ** error
void GetCustomFontFamilies(SkTDArray< FontFamily * > &fontFamilies, const SkString &basePath, const char *fontsXml, const char *fallbackFontsXml, const char *langFallbackFontsDir=nullptr)
skia_private::TArray< FontFileInfo, true > fFonts
skia_private::TArray< SkFontArguments::VariationPosition::Coordinate, true > fVariationDesignPosition
const char * fFallbackFontsXml
SystemFontUse fSystemFontUse
static constexpr SkPoint Make(float x, float y)