MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / wrap_words

Function wrap_words

src/framework/text/subtitle.cpp:52–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52std::vector<std::string> wrap_words(
53 const std::vector<runtime::WordTimestamp> & words,
54 size_t begin,
55 size_t end,
56 int max_chars_per_line) {
57 std::vector<std::string> lines;
58 std::string line;
59 for (size_t i = begin; i < end; ++i) {
60 const std::string & word = words[i].word;
61 if (line.empty()) {
62 line = word;
63 } else if (line.size() + 1 + word.size() <= static_cast<size_t>(max_chars_per_line)) {
64 line.push_back(' ');
65 line += word;
66 } else {
67 lines.push_back(line);
68 line = word;
69 }
70 }
71 if (!line.empty()) {
72 lines.push_back(line);
73 }
74 return lines;
75}
76
77bool would_exceed_text_limit(
78 const std::vector<runtime::WordTimestamp> & words,

Callers 2

would_exceed_text_limitFunction · 0.85
build_subtitle_blocksFunction · 0.85

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected