Changing FontFamily independently for ComboboxItems
Posted: 06 Feb 2014, 15:40
Hey,
first of all: we are using Noesis for Unity
In our options menu we have a language selection combobox. In this combobox the language are displayed as text in their according languages.
To be able to display the texts properly we need to change the font family via databinding:
<ComboBox x:Name="combobox" width="1024">
<ComboBox.ItemTemplate>
<DataTemplate>
<ComboBoxItem>
<TextBlock Text="{Binding LanguageText}" FontFamily="{Binding FontFamily}"/>
</ComboBoxItem>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Unfortunately if we set the FontFamily data string to a font that we want to use, for example:
element.FontFamily = "../Fonts/#DroidSans";
it will produce an exception while rendering:
Exception: ../Fonts/#DroidSans resource not found
Noesis.Error.Check () (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisError.cs:49)
Noesis.UIRenderer.Noesis_MouseButtonUp (Int32 rendererId, Single x, Single y, Int32 button) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRendererImports.cs:168)
Noesis.UIRenderer.ProcessEvent (UnityEngine.Event ev, Boolean enableKeyboard, Boolean enableMouse) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRenderer.cs:210)
NoesisGUIPanel.OnGUI () (at Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs:136)
However it will work with:
element.FontFamily = "Gui/Core/Roboto.font";
Do we have to use another syntax to access our fonts?
element.FontFamily = "../Fonts/DroidSans.font";
did not work either.
Any help or suggestions how to achieve this kind of font binding is appreciated.
best regards,
Andreas
first of all: we are using Noesis for Unity
In our options menu we have a language selection combobox. In this combobox the language are displayed as text in their according languages.
To be able to display the texts properly we need to change the font family via databinding:
<ComboBox x:Name="combobox" width="1024">
<ComboBox.ItemTemplate>
<DataTemplate>
<ComboBoxItem>
<TextBlock Text="{Binding LanguageText}" FontFamily="{Binding FontFamily}"/>
</ComboBoxItem>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Unfortunately if we set the FontFamily data string to a font that we want to use, for example:
element.FontFamily = "../Fonts/#DroidSans";
it will produce an exception while rendering:
Exception: ../Fonts/#DroidSans resource not found
Noesis.Error.Check () (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisError.cs:49)
Noesis.UIRenderer.Noesis_MouseButtonUp (Int32 rendererId, Single x, Single y, Int32 button) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRendererImports.cs:168)
Noesis.UIRenderer.ProcessEvent (UnityEngine.Event ev, Boolean enableKeyboard, Boolean enableMouse) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRenderer.cs:210)
NoesisGUIPanel.OnGUI () (at Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs:136)
However it will work with:
element.FontFamily = "Gui/Core/Roboto.font";
Do we have to use another syntax to access our fonts?
element.FontFamily = "../Fonts/DroidSans.font";
did not work either.
Any help or suggestions how to achieve this kind of font binding is appreciated.
best regards,
Andreas