307{
310 utf8Text = nullptr;
311 textByteLen = 0;
312 }
313 std::unique_ptr<SkShaper> shaper = nullptr;
314#if defined(SK_SHAPER_HARFBUZZ_AVAILABLE) && defined(SK_SHAPER_UNICODE_AVAILABLE)
317#else
319#endif
321
323 RunHandler runHandler(utf8Text, textByteLen);
324 if (textByteLen) {
325 result.glyphBounds.resize(textByteLen);
327 c =
SkRect{-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX};
328 }
330
331 static constexpr uint8_t kBidiLevelLTR = 0;
332 std::unique_ptr<SkShaper::BiDiRunIterator> bidi = nullptr;
333#if defined(SK_SHAPER_HARFBUZZ_AVAILABLE) && defined(SK_SHAPER_UNICODE_AVAILABLE)
335 unicode, utf8Text, textByteLen, kBidiLevelLTR);
336#endif
337 if (!bidi) {
338 bidi = std::make_unique<SkShaper::TrivialBiDiRunIterator>(kBidiLevelLTR, textByteLen);
339 }
341
342 std::unique_ptr<SkShaper::LanguageRunIterator> language =
345
346 std::unique_ptr<SkShaper::ScriptRunIterator>
script =
349
350 std::unique_ptr<SkShaper::FontRunIterator> fontRuns =
353
354 shaper->shape(utf8Text,
355 textByteLen,
356 *fontRuns,
357 *bidi,
359 *language,
360 nullptr,
361 0,
363 &runHandler);
364 if (runHandler.lineEndOffsets().size() > 1) {
365 result.lineBreakOffsets = runHandler.lineEndOffsets();
367 result.lineBreakOffsets.pop_back();
368 }
370 result.blob = runHandler.makeBlob();
371 }
372 result.glyphBounds.push_back(runHandler.finalRect(
font));
376}
sk_sp< SkUnicode > get_unicode()
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
static std::unique_ptr< ScriptRunIterator > MakeScriptRunIterator(const char *utf8, size_t utf8Bytes, SkFourByteTag script)
static std::unique_ptr< FontRunIterator > MakeFontMgrRunIterator(const char *utf8, size_t utf8Bytes, const SkFont &font, sk_sp< SkFontMgr > fallback)
static std::unique_ptr< LanguageRunIterator > MakeStdLanguageRunIterator(const char *utf8, size_t utf8Bytes)
sk_sp< SkFontMgr > fontMgr
static float max(float r, float g, float b)
SKSHAPER_API std::unique_ptr< SkShaper > ShaperDrivenWrapper(sk_sp< SkUnicode > unicode, sk_sp< SkFontMgr > fallback)
SKSHAPER_API std::unique_ptr< SkShaper > PrimitiveText()
SKSHAPER_API std::unique_ptr< SkShaper::BiDiRunIterator > BidiRunIterator(sk_sp< SkUnicode > unicode, const char *utf8, size_t utf8Bytes, uint8_t bidiLevel)
SK_SPI int CountUTF8(const char *utf8, size_t byteLength)
font
Font Metadata and Metrics.
static void set_character_bounds(void *context, const char *utf8Text, size_t utf8TextBytes, size_t glyphCount, const SkGlyphID *glyphs, const SkPoint *positions, const uint32_t *clusters, const SkFont &font)
std::vector< bool > GetUtf8WordBoundaries(const char *begin, size_t byteCount, const char *locale)