skia2/modules/skparagraph/utils/TestFontCollection.cpp
Mike Klein 52337de95c re-run tools/rewrite_includes.py
PS2 adds a rewrite for Skia #include <...> to #include "...", letting
them be otherwise rewritten and sorted too.  (We do need one exception
for the Vulkan headers, which will otherwise be rewritten to always
point to our own.)  I don't think it's particularly important to
favor "" or <>, but picking one keeps things consistent.

PS3 adds a missing SkMutex.h include.

PS4 fixes a terrible readability problem.

Change-Id: Id9fe752727ef30e802b1daf755ee2ed15e267577
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229742
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-07-25 15:40:33 +00:00

39 lines
1.1 KiB
C++

// Copyright 2019 Google LLC.
#include "modules/skparagraph/src/ParagraphImpl.h"
#include "modules/skparagraph/utils/TestFontCollection.h"
#include "src/core/SkOSFile.h"
#include "src/utils/SkUTF.h"
#include "tools/Resources.h"
namespace skia {
namespace textlayout {
TestFontCollection::TestFontCollection(const std::string& resourceDir)
: fResourceDir(resourceDir)
, fFontsFound(0) {
if (fDirs == resourceDir) {
return;
}
fFontProvider = sk_make_sp<TypefaceFontProvider>();
SkOSFile::Iter iter(fResourceDir.c_str());
SkString path;
while (iter.next(&path)) {
SkString file_path;
file_path.printf("%s/%s", fResourceDir.c_str(), path.c_str());
// fonts from data are faster (skips file overhead), so we use them here for testing
auto data = SkData::MakeFromFileName(file_path.c_str());
if (data) {
fFontProvider->registerTypeface(SkTypeface::MakeFromData(data));
}
}
fFontsFound = fFontProvider->countFamilies();
this->setTestFontManager(fFontProvider);
this->disableFontFallback();
fDirs = resourceDir;
}
} // namespace textlayout
} // namespace skia