浏览代码

fix text scale factor

/main
fzhangtj 6 年前
当前提交
cea34501
共有 4 个文件被更改,包括 11 次插入11 次删除
  1. 2
      Runtime/painting/text_painter.cs
  2. 8
      Runtime/painting/text_span.cs
  3. 6
      Runtime/painting/text_style.cs
  4. 6
      Runtime/ui/txt/paragraph_builder.cs

2
Runtime/painting/text_painter.cs


var builder = new ParagraphBuilder(this._createParagraphStyle(TextDirection.ltr)
); // direction doesn't matter, text is just a space
if (this.text != null && this.text.style != null) {
builder.pushStyle(this.text.style);
builder.pushStyle(this.text.style, this.textScaleFactor);
}
builder.addText(" ");

8
Runtime/painting/text_span.cs


}
public void build(ParagraphBuilder builder, float textScaleFactor = 1.0f) {
var hasTyle = this.style != null;
if (hasTyle) {
builder.pushStyle(this.style);
var hasStyle = this.style != null;
if (hasStyle) {
builder.pushStyle(this.style, textScaleFactor);
}
if (!string.IsNullOrEmpty(this.text)) {

}
}
if (hasTyle) {
if (hasStyle) {
builder.pop();
}
}

6
Runtime/painting/text_style.cs


this.background = background;
}
public ui.TextStyle getTextStyle(ui.TextStyle currentStyle = null) {
public ui.TextStyle getTextStyle(ui.TextStyle currentStyle = null, float textScaleFactor = 1.0f) {
fontSize: this.fontSize ?? currentStyle.fontSize,
fontSize: this.fontSize != null ? this.fontSize * textScaleFactor : currentStyle.fontSize,
fontWeight: this.fontWeight ?? currentStyle.fontWeight,
fontStyle: this.fontStyle ?? currentStyle.fontStyle,
letterSpacing: this.letterSpacing ?? currentStyle.letterSpacing,

return new ui.TextStyle(
color: this.color,
fontSize: this.fontSize,
fontSize: this.fontSize * textScaleFactor,
fontWeight: this.fontWeight,
fontStyle: this.fontStyle,
letterSpacing: this.letterSpacing,

6
Runtime/ui/txt/paragraph_builder.cs


int _paragraph_style_index;
public interface ITextStyleProvider {
TextStyle getTextStyle(TextStyle current = null);
TextStyle getTextStyle(TextStyle current = null, float textScaleFactor = 1.0f);
}
public ParagraphBuilder(ParagraphStyle style) {

return paragraph;
}
public void pushStyle(ITextStyleProvider style) {
var newStyle = style.getTextStyle(this.peekStyle());
public void pushStyle(ITextStyleProvider style, float textScaleFactor) {
var newStyle = style.getTextStyle(this.peekStyle(), textScaleFactor: textScaleFactor);
var styleIndex = this._runs.addStyle(newStyle);
this._styleStack.Add(styleIndex);
this._runs.startRun(styleIndex, this._text.Length);

正在加载...
取消
保存