public override void Apply(ComputedStyle style, Value value) { // Get the text: TextRenderingProperty text = GetText(style); if (text == null) { return; } // Get the standard space size for this text property: float standardSize = text.StandardSpaceSize(); // Apply the property: if (value == null) { // Standard space size: text.SpaceSize = standardSize; } else if (value.Single != 0f) { // Relative, e.g. 200% text.SpaceSize = standardSize * value.Single; } else if (value.PX != 0) { // Straight pixel size: text.SpaceSize = (float)value.PX; } else { // Standard space size (will be overwritten): text.SpaceSize = standardSize; } // Prompt the renderer to recalculate the width of the words: text.SetDimensions(); // Apply: text.RequestLayout(); }
public override void Apply(ComputedStyle style, Value value) { // Get the text: TextRenderingProperty text = GetText(style); if (text == null) { return; } // Apply the property: if (value == null) { // No spacing: text.LetterSpacing = 0; } else if (value.Type == ValueType.Pixels) { // Fixed space: text.LetterSpacing = value.PX; } else if (value.Single != 0f) { // Apply a relative %: text.LetterSpacing = text.FontSize * (value.Single - 1f); } else { // Default no spacing: text.LetterSpacing = 0; } // Apply: text.RequestLayout(); // Recalc size: text.SetDimensions(); }
public override void Apply(ComputedStyle style, Value value) { // Get the text: TextRenderingProperty text = GetText(style); if (text == null) { return; } // Get the decoration: TextDecorationInfo decoration = text.TextLine; // Apply the property: if (value == null) { if (decoration == null) { return; } text.TextLine = null; } else { TextLineType type; switch (value.Text) { case "underline": type = TextLineType.Underline; break; case "overline": type = TextLineType.Overline; break; case "line-through": type = TextLineType.StrikeThrough; break; default: type = TextLineType.None; if (decoration == null) { return; } text.TextLine = null; break; } if (type != TextLineType.None) { // We need a line. if (decoration == null) { decoration = new TextDecorationInfo(type); text.TextLine = decoration; // Need colour applying? value = style["text-decoration-color"]; if (value != null && value.Text != "initial") { // Apply colour: decoration.SetColour(value.ToColor()); } } else { decoration.Type = type; } } } // Apply the changes - doesn't change anything about the text: text.RequestLayout(); }