public override double GetMeanline(object backend) { var t = (TextLayoutBackend)backend; var fd = (FontData)ApplicationContext.Toolkit.GetSafeBackend(t.Font); var tf = new Typeface(fd.Family, fd.Style, fd.Weight, fd.Stretch); return(t.FormattedText.Baseline - tf.StrikethroughPosition * WpfFontBackendHandler.GetDeviceUnitsFromPoints(fd.Size)); }
public static FontData FromControl(SW.Controls.Control control) { double size = WpfFontBackendHandler.GetPointsFromDeviceUnits(control.FontSize); return(new FontData(control.FontFamily, size) { Style = control.FontStyle, Stretch = control.FontStretch, Weight = control.FontWeight }); }
FontData GetWidgetFont() { if (!(Widget is Control)) { double size = WpfFontBackendHandler.GetPointsFromDeviceUnits(SystemFonts.MessageFontSize); return(new FontData(SystemFonts.MessageFontFamily, size) { Style = SystemFonts.MessageFontStyle, Weight = SystemFonts.MessageFontWeight }); } return(FontData.FromControl((Control)Widget)); }
public double GetDeviceIndependentPixelSize() { return(WpfFontBackendHandler.GetDeviceUnitsFromPoints(Size)); }
void GenerateBlocks(SWD.InlineCollection col, string text, ref int i, int spanEnd, List <Drawing.TextAttribute> attributes, ref int attrIndex) { while (attrIndex < attributes.Count) { var at = attributes[attrIndex]; if (at.StartIndex > spanEnd) { FlushText(col, text, ref i, spanEnd); return; } FlushText(col, text, ref i, at.StartIndex); var s = new SWD.Span(); if (at is Drawing.BackgroundTextAttribute) { s.Background = new SWM.SolidColorBrush(((Drawing.BackgroundTextAttribute)at).Color.ToWpfColor()); } else if (at is Drawing.FontWeightTextAttribute) { s.FontWeight = ((Drawing.FontWeightTextAttribute)at).Weight.ToWpfFontWeight(); } else if (at is Drawing.FontStyleTextAttribute) { s.FontStyle = ((Drawing.FontStyleTextAttribute)at).Style.ToWpfFontStyle(); } else if (at is Drawing.UnderlineTextAttribute) { var xa = (Drawing.UnderlineTextAttribute)at; var dec = new TextDecoration(TextDecorationLocation.Underline, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended); s.TextDecorations.Add(dec); } else if (at is Drawing.StrikethroughTextAttribute) { var xa = (Drawing.StrikethroughTextAttribute)at; var dec = new TextDecoration(TextDecorationLocation.Strikethrough, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended); s.TextDecorations.Add(dec); } else if (at is Drawing.FontTextAttribute) { var xa = (Drawing.FontTextAttribute)at; s.FontFamily = new SWM.FontFamily(xa.Font.Family); s.FontSize = WpfFontBackendHandler.GetPointsFromDeviceUnits(xa.Font.Size); s.FontStretch = xa.Font.Stretch.ToWpfFontStretch(); s.FontStyle = xa.Font.Style.ToWpfFontStyle(); s.FontWeight = xa.Font.Weight.ToWpfFontWeight(); } else if (at is Drawing.ColorTextAttribute) { s.Foreground = new SWM.SolidColorBrush(((Drawing.ColorTextAttribute)at).Color.ToWpfColor()); } else if (at is Drawing.LinkTextAttribute) { var link = new SWD.Hyperlink() { NavigateUri = ((Drawing.LinkTextAttribute)at).Target }; link.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(link_RequestNavigate); s = link; } col.Add(s); var max = i + at.Count; if (max > spanEnd) { max = spanEnd; } attrIndex++; GenerateBlocks(s.Inlines, text, ref i, i + at.Count, attributes, ref attrIndex); } FlushText(col, text, ref i, spanEnd); }