Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0cbd587

Browse files
reed-at-googleSkia Commit-Bot
authored andcommitted
be sure to keep the fonts alive for the two loops
Bug: skia:10124 Change-Id: I449b72a00d714207a6bbc7948b5cdbb9a541b43f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287819 Reviewed-by: Ben Wagner <[email protected]> Commit-Queue: Mike Reed <[email protected]>
1 parent e8ffb08 commit 0cbd587

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/skshaper/src/SkShaper_coretext.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ void SkShaper_CoreText::shape(const char* utf8, size_t utf8Bytes,
210210

211211
// We have to compute RunInfos in a loop, and then reuse them in a 2nd loop,
212212
// so we store them in an array (we reuse the array's storage for each line).
213+
std::vector<SkFont> fontStorage;
213214
std::vector<SkShaper::RunHandler::RunInfo> infos;
214215

215216
LineBreakIter iter(typesetter.get(), width);
@@ -220,6 +221,7 @@ void SkShaper_CoreText::shape(const char* utf8, size_t utf8Bytes,
220221
continue;
221222
}
222223
handler->beginLine();
224+
fontStorage.clear();
223225
infos.clear();
224226
for (CFIndex j = 0; j < runCount; ++j) {
225227
CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(run_array, j);
@@ -237,10 +239,10 @@ void SkShaper_CoreText::shape(const char* utf8, size_t utf8Bytes,
237239

238240
CFRange range = CTRunGetStringRange(run);
239241

240-
SkFont run_font = run_to_font(run, font);
242+
fontStorage.push_back(run_to_font(run, font));
241243
infos.push_back({
242-
run_font,
243-
0, // need fBidiLevel
244+
fontStorage.back(), // info just stores a ref to the font
245+
0, // need fBidiLevel
244246
{adv, 0},
245247
(size_t)runGlyphs,
246248
{(size_t)range.location, (size_t)range.length},

0 commit comments

Comments
 (0)