diff --git a/engine/src/flutter/src/BUILD.gn b/engine/src/flutter/src/BUILD.gn index 2d5792f88a..3ff3e9c6b0 100644 --- a/engine/src/flutter/src/BUILD.gn +++ b/engine/src/flutter/src/BUILD.gn @@ -33,6 +33,9 @@ source_set("src") { "styled_runs.cc", "styled_runs.h", "text_align.h", + "text_baseline.h", + "text_decoration.cc", + "text_decoration.h", "text_style.cc", "text_style.h", ] diff --git a/engine/src/flutter/src/paragraph.cc b/engine/src/flutter/src/paragraph.cc index ce2edaa866..517be88eb6 100644 --- a/engine/src/flutter/src/paragraph.cc +++ b/engine/src/flutter/src/paragraph.cc @@ -194,7 +194,7 @@ void Paragraph::Layout(const ParagraphConstraints& constraints, x = 0.0f; // TODO(abarth): Use the line height, which is something like the max // font_size for runs in this line times the paragraph's line height. - y += run.style.font_size; + y += run.style.font_size * run.style.height; break_index += 1; } else { x += layout.getAdvance(); diff --git a/engine/src/flutter/src/text_align.h b/engine/src/flutter/src/text_align.h index 91a291ff9f..52922a2f72 100644 --- a/engine/src/flutter/src/text_align.h +++ b/engine/src/flutter/src/text_align.h @@ -23,7 +23,7 @@ enum class TextAlign { left, right, center, - // justify, + justify, }; } // namespace txt diff --git a/engine/src/flutter/src/text_baseline.h b/engine/src/flutter/src/text_baseline.h new file mode 100644 index 0000000000..67f88cac8c --- /dev/null +++ b/engine/src/flutter/src/text_baseline.h @@ -0,0 +1,29 @@ +/* + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LIB_TXT_SRC_TEXT_BASELINE_H_ +#define LIB_TXT_SRC_TEXT_BASELINE_H_ + +namespace txt { + +enum TextBaseline { + kAlphabetic, + kIdeographic, +}; + +} // namespace txt + +#endif // LIB_TXT_SRC_TEXT_BASELINE_H_ diff --git a/engine/src/flutter/src/text_decoration.cc b/engine/src/flutter/src/text_decoration.cc new file mode 100644 index 0000000000..28804c144f --- /dev/null +++ b/engine/src/flutter/src/text_decoration.cc @@ -0,0 +1,22 @@ +/* + * Copyright 2017 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "lib/txt/src/text_decoration.h" + +namespace txt {} // namespace txt diff --git a/engine/src/flutter/src/text_decoration.h b/engine/src/flutter/src/text_decoration.h new file mode 100644 index 0000000000..8e7b1654a4 --- /dev/null +++ b/engine/src/flutter/src/text_decoration.h @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LIB_TXT_SRC_TEXT_DECORATION_H_ +#define LIB_TXT_SRC_TEXT_DECORATION_H_ + +namespace txt { + +enum TextDecoration { + kNone = 0x0, + kUnderline = 0x1, + kOverline = 0x2, + kLineThrough = 0x4, +}; + +enum TextDecorationStyle { + kSolid, + kDouble, // "double" is reserved. + kDotted, + kDashed, + kWavy +}; + +} // namespace txt + +#endif // LIB_TXT_SRC_TEXT_DECORATION_H_ \ No newline at end of file diff --git a/engine/src/flutter/src/text_style.h b/engine/src/flutter/src/text_style.h index 13b322f2c9..23c2043b0a 100644 --- a/engine/src/flutter/src/text_style.h +++ b/engine/src/flutter/src/text_style.h @@ -21,6 +21,8 @@ #include "lib/txt/src/font_style.h" #include "lib/txt/src/font_weight.h" +#include "lib/txt/src/text_baseline.h" +#include "lib/txt/src/text_decoration.h" #include "third_party/skia/include/core/SkColor.h" namespace txt { @@ -28,13 +30,13 @@ namespace txt { class TextStyle { public: SkColor color = SK_ColorWHITE; - // TextDecoration decoration, - // SkColor decoration_color; - // TextDecorationStyle decoration_style + TextDecoration decoration = TextDecoration::kNone; + SkColor decoration_color = SK_ColorWHITE; + TextDecorationStyle decoration_style = TextDecorationStyle::kSolid; FontWeight font_weight = FontWeight::w400; FontStyle font_style = FontStyle::normal; bool fake_bold = false; - // TextBaseline text_baseline; + TextBaseline text_baseline = TextBaseline::kAlphabetic; std::string font_family = ""; double font_size = 14.0; double letter_spacing = 0.0; diff --git a/engine/src/flutter/tests/txt/paragraph_unittests.cc b/engine/src/flutter/tests/txt/paragraph_unittests.cc index 344418efa2..e3901f02f0 100644 --- a/engine/src/flutter/tests/txt/paragraph_unittests.cc +++ b/engine/src/flutter/tests/txt/paragraph_unittests.cc @@ -291,6 +291,7 @@ TEST_F(RenderTest, LinebreakParagraph) { // Letter spacing not yet implemented text_style.letter_spacing = 10; text_style.color = SK_ColorBLACK; + text_style.height = 1.15; builder.PushStyle(text_style); builder.AddText(u16_text);