diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs index 9f4157ed..a1c07134 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs @@ -1,4 +1,7 @@ +using Xamarin.Forms.PlatformConfiguration.TizenSpecific; + using EColor = ElmSharp.Color; +using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Label; namespace Xamarin.Forms.Platform.Tizen { @@ -19,6 +22,7 @@ namespace Xamarin.Forms.Platform.Tizen RegisterPropertyHandler(Label.HorizontalTextAlignmentProperty, UpdateTextAlignment); RegisterPropertyHandler(Label.VerticalTextAlignmentProperty, UpdateTextAlignment); RegisterPropertyHandler(Label.FormattedTextProperty, UpdateFormattedText); + RegisterPropertyHandler(Specific.FontWeightProperty, UpdateFontWeight); } protected override void OnElementChanged(ElementChangedEventArgs<Label> e) @@ -117,6 +121,19 @@ namespace Xamarin.Forms.Platform.Tizen Control.LineBreakMode = ConvertToNativeLineBreakMode(Element.LineBreakMode); } + void UpdateFontWeight() + { + var weight = Specific.GetFontWeight(Element); + if (Control.FormattedText != null) + { + foreach (var span in Control.FormattedText.Spans) + { + span.FontWeight = ConvertToNativeFontWeight(weight); + } + } + Control.FontWeight = ConvertToNativeFontWeight(weight); + } + Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode) { switch (mode) @@ -136,5 +153,36 @@ namespace Xamarin.Forms.Platform.Tizen return Native.LineBreakMode.WordWrap; } } + + Native.FontWeight ConvertToNativeFontWeight(FontWeight weight) + { + switch (weight) + { + case FontWeight.Bold: + return Native.FontWeight.Bold; + case FontWeight.SemiBold: + return Native.FontWeight.SemiBold; + case FontWeight.UltraBold: + return Native.FontWeight.UltraBold; + case FontWeight.Black: + return Native.FontWeight.Black; + case FontWeight.ExtraBlack: + return Native.FontWeight.ExtraBlack; + case FontWeight.Book: + return Native.FontWeight.Book; + case FontWeight.Light: + return Native.FontWeight.Light; + case FontWeight.Medium: + return Native.FontWeight.Medium; + case FontWeight.Normal: + return Native.FontWeight.Normal; + case FontWeight.Thin: + return Native.FontWeight.Thin; + case FontWeight.UltraLight: + return Native.FontWeight.UltraLight; + default: + return Native.FontWeight.None; + } + } } } |