share tiny bit of code for std language iter
Change-Id: I928ba956c1ff038332d7c7497fe5fc0c297f4f22 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217140 Commit-Queue: Ben Wagner <bungeman@google.com> Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Reed <reed@google.com> Auto-Submit: Mike Reed <reed@google.com>
This commit is contained in:
parent
3a79bf4959
commit
c72216583d
@ -128,9 +128,9 @@ public:
|
||||
public:
|
||||
TrivialLanguageRunIterator(const char* language, size_t utf8Bytes)
|
||||
: TrivialRunIterator(utf8Bytes), fLanguage(language) {}
|
||||
const char* currentLanguage() const override { return fLanguage; }
|
||||
const char* currentLanguage() const override { return fLanguage.c_str(); }
|
||||
private:
|
||||
const char* fLanguage;
|
||||
SkString fLanguage;
|
||||
};
|
||||
|
||||
class RunHandler {
|
||||
|
@ -124,37 +124,9 @@ SkShaper::MakeFontMgrRunIterator(const char* utf8, size_t utf8Bytes,
|
||||
return skstd::make_unique<FontMgrRunIterator>(utf8, utf8Bytes, font, std::move(fallback));
|
||||
}
|
||||
|
||||
class StdLanguageRunIterator final : public SkShaper::LanguageRunIterator {
|
||||
public:
|
||||
StdLanguageRunIterator(const char* utf8, size_t utf8Bytes)
|
||||
: fCurrent(utf8), fBegin(utf8), fEnd(fCurrent + utf8Bytes)
|
||||
, fLanguage(std::locale().name().c_str())
|
||||
{ }
|
||||
void consume() override {
|
||||
// Ideally something like cld2/3 could be used, or user signals.
|
||||
SkASSERT(fCurrent < fEnd);
|
||||
fCurrent = fEnd;
|
||||
}
|
||||
size_t endOfCurrentRun() const override {
|
||||
return fCurrent - fBegin;
|
||||
}
|
||||
bool atEnd() const override {
|
||||
return fCurrent == fEnd;
|
||||
}
|
||||
|
||||
const char* currentLanguage() const override {
|
||||
return fLanguage.c_str();
|
||||
}
|
||||
private:
|
||||
char const * fCurrent;
|
||||
char const * const fBegin;
|
||||
char const * const fEnd;
|
||||
const SkString fLanguage;
|
||||
};
|
||||
|
||||
std::unique_ptr<SkShaper::LanguageRunIterator>
|
||||
SkShaper::MakeStdLanguageRunIterator(const char* utf8, size_t utf8Bytes) {
|
||||
return skstd::make_unique<StdLanguageRunIterator>(utf8, utf8Bytes);
|
||||
return skstd::make_unique<TrivialLanguageRunIterator>(std::locale().name().c_str(), utf8Bytes);
|
||||
}
|
||||
|
||||
void SkTextBlobBuilderRunHandler::beginLine() {
|
||||
|
Loading…
Reference in New Issue
Block a user