Add TextStyle properties to better support Flutter API
Change-Id: I13174dafa497328c80aada02fe144bd1b3d7f396
This commit is contained in:
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -23,7 +23,7 @@ enum class TextAlign {
|
||||
left,
|
||||
right,
|
||||
center,
|
||||
// justify,
|
||||
justify,
|
||||
};
|
||||
|
||||
} // namespace txt
|
||||
|
||||
29
engine/src/flutter/src/text_baseline.h
Normal file
29
engine/src/flutter/src/text_baseline.h
Normal file
@@ -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_
|
||||
22
engine/src/flutter/src/text_decoration.cc
Normal file
22
engine/src/flutter/src/text_decoration.cc
Normal file
@@ -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 <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "lib/txt/src/text_decoration.h"
|
||||
|
||||
namespace txt {} // namespace txt
|
||||
39
engine/src/flutter/src/text_decoration.h
Normal file
39
engine/src/flutter/src/text_decoration.h
Normal file
@@ -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_
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user