Skip to content

Commit

Permalink
Revert "[libtxt] Assign a unique ID to each glyph cluster within a li…
Browse files Browse the repository at this point in the history
…ne (flutter#15742)"

This reverts commit 4ac4153.
  • Loading branch information
NoamDev authored Feb 27, 2020
1 parent 0ee7ca6 commit 05f1fa9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
12 changes: 5 additions & 7 deletions third_party/txt/src/txt/paragraph_txt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ void ParagraphTxt::Layout(double width) {

double run_x_offset = 0;
double justify_x_offset = 0;
size_t cluster_unique_id = 0;
std::vector<PaintRecord> paint_records;

for (auto line_run_it = line_runs.begin(); line_run_it != line_runs.end();
Expand Down Expand Up @@ -957,20 +956,19 @@ void ParagraphTxt::Layout(double width) {
float grapheme_advance =
glyph_advance / grapheme_code_unit_counts.size();

glyph_positions.emplace_back(
run_x_offset + glyph_x_offset, grapheme_advance,
run.start() + glyph_code_units.start,
grapheme_code_unit_counts[0], cluster_unique_id);
glyph_positions.emplace_back(run_x_offset + glyph_x_offset,
grapheme_advance,
run.start() + glyph_code_units.start,
grapheme_code_unit_counts[0], cluster);

// Compute positions for the additional graphemes in the ligature.
for (size_t i = 1; i < grapheme_code_unit_counts.size(); ++i) {
glyph_positions.emplace_back(
glyph_positions.back().x_pos.end, grapheme_advance,
glyph_positions.back().code_units.start +
grapheme_code_unit_counts[i - 1],
grapheme_code_unit_counts[i], cluster_unique_id);
grapheme_code_unit_counts[i], cluster);
}
cluster_unique_id++;

bool at_word_start = false;
bool at_word_end = false;
Expand Down
31 changes: 0 additions & 31 deletions third_party/txt/tests/paragraph_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,37 +175,6 @@ TEST_F(ParagraphTest, GetGlyphPositionAtCoordinateSegfault) {
ASSERT_TRUE(Snapshot());
}

// Check that GetGlyphPositionAtCoordinate computes correct text positions for
// a paragraph containing multiple styled runs.
TEST_F(ParagraphTest, GetGlyphPositionAtCoordinateMultiRun) {
txt::ParagraphStyle paragraph_style;
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_families = std::vector<std::string>(1, "Ahem");
text_style.color = SK_ColorBLACK;
text_style.font_size = 10;
builder.PushStyle(text_style);
builder.AddText(u"A");
text_style.font_size = 20;
builder.PushStyle(text_style);
builder.AddText(u"B");
text_style.font_size = 30;
builder.PushStyle(text_style);
builder.AddText(u"C");

auto paragraph = BuildParagraph(builder);
paragraph->Layout(GetTestCanvasWidth());

paragraph->Paint(GetCanvas(), 10.0, 15.0);

ASSERT_EQ(paragraph->GetGlyphPositionAtCoordinate(2.0, 5.0).position, 0ull);
ASSERT_EQ(paragraph->GetGlyphPositionAtCoordinate(12.0, 5.0).position, 1ull);
ASSERT_EQ(paragraph->GetGlyphPositionAtCoordinate(32.0, 5.0).position, 2ull);

ASSERT_TRUE(Snapshot());
}

TEST_F(ParagraphTest, LineMetricsParagraph1) {
const char* text = "Hello! What is going on?\nSecond line \nthirdline";
auto icu_text = icu::UnicodeString::fromUTF8(text);
Expand Down

0 comments on commit 05f1fa9

Please sign in to comment.