26#if !defined(SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS)
27 void shape(
const char* utf8,
size_t utf8Bytes,
31 RunHandler*)
const override;
33 void shape(
const char* utf8,
size_t utf8Bytes,
39 RunHandler*)
const override;
42 void shape(
const char* utf8,
size_t utf8Bytes,
47 const Feature*,
size_t featureSize,
49 RunHandler*)
const override;
88 const char* wordStart =
text;
93 const char* prevText =
text;
95 accumulatedWidth += advance[glyphIndex++];
98 if (!currWS && prevWS) {
103 if (
width < accumulatedWidth) {
104 bool consumeWhitespace =
false;
107 if (prevText ==
start) {
111 consumeWhitespace =
true;
112 }
else if (wordStart !=
start) {
115 }
else if (prevText >
start) {
121 consumeWhitespace =
true;
123 if (consumeWhitespace) {
129 *trailing =
text - prevText;
139#if !defined(SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS)
148 return this->
shape(utf8, utf8Bytes, font, bidi, script, lang,
nullptr, 0,
width, handler);
157 std::unique_ptr<FontRunIterator> fontRuns(
166 return this->
shape(utf8, utf8Bytes, *fontRuns, bidi, script, lang,
nullptr, 0,
width, handler);
181 if (!fontRuns.
atEnd()) {
188 if (glyphCount < 0) {
195 std::unique_ptr<SkScalar[]> advances(
new SkScalar[glyphCount]);
196 font.getWidthsBounds(
glyphs.get(), glyphCount, advances.get(),
nullptr,
nullptr);
198 size_t glyphOffset = 0;
199 size_t utf8Offset = 0;
201 size_t bytesCollapsed;
202 size_t bytesConsumed =
linebreak(utf8, utf8 + utf8Bytes, font,
width,
203 advances.get() + glyphOffset, &bytesCollapsed);
204 size_t bytesVisible = bytesConsumed - bytesCollapsed;
207 const RunHandler::RunInfo
info = {
212 RunHandler::Range(utf8Offset, bytesVisible)
215 if (
info.glyphCount) {
219 if (
info.glyphCount) {
224 for (
size_t i = 0; i <
info.glyphCount; ++i) {
225 buffer.positions[i] = position;
226 position.
fX += advances[i + glyphOffset];
229 const char* txtPtr = utf8;
230 for (
size_t i = 0; i <
info.glyphCount; ++i) {
241 utf8Offset += bytesConsumed;
242 utf8 += bytesConsumed;
243 utf8Bytes -= bytesConsumed;
244 }
while (0 < utf8Bytes);
247#if !defined(SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS)
252std::unique_ptr<SkShaper> PrimitiveText() {
return std::make_unique<SkShaperPrimitive>(); }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static float next(float f)
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static bool is_breaking_whitespace(SkUnichar c)
static size_t linebreak(const char text[], const char stop[], const SkFont &font, SkScalar width, SkScalar *advance, size_t *trailing)
constexpr uint32_t SkToU32(S x)
void shape(const char *utf8, size_t utf8Bytes, const SkFont &srcFont, bool leftToRight, SkScalar width, RunHandler *) const override
virtual const SkFont & currentFont() const =0
virtual void commitLine()=0
virtual void commitRunBuffer(const RunInfo &)=0
virtual void commitRunInfo()=0
virtual void runInfo(const RunInfo &)=0
virtual void beginLine()=0
virtual Buffer runBuffer(const RunInfo &)=0
virtual bool atEnd() const =0
static std::unique_ptr< FontRunIterator > MakeFontMgrRunIterator(const char *utf8, size_t utf8Bytes, const SkFont &font, sk_sp< SkFontMgr > fallback)
static std::unique_ptr< SkShaper > MakePrimitive()
static const uint8_t buffer[]
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
SK_SPI int CountUTF8(const char *utf8, size_t byteLength)