in src/CalcViewModel/Common/LocalizationService.cpp [268:371]
void LocalizationService::UpdateFontFamilyAndSize(DependencyObject ^ target)
{
FontFamily ^ fontFamily;
FontWeight fontWeight;
bool fOverrideFontWeight = false;
double scaleFactor;
auto service = LocalizationService::GetInstance();
auto fontType = LocalizationService::GetFontType(target);
if (service->GetOverrideFontApiValues())
{
fontFamily = ref new FontFamily(service->GetFontFamilyOverride());
scaleFactor = service->GetFontScaleFactorOverride(fontType) / 100.0;
fontWeight = service->GetFontWeightOverride();
fOverrideFontWeight = true;
}
else
{
auto languageFont = service->GetLanguageFont(fontType);
fontFamily = ref new FontFamily(languageFont->FontFamily);
scaleFactor = languageFont->ScaleFactor / 100.0;
}
double sizeToUse = LocalizationService::GetFontSize(target) * scaleFactor;
auto control = dynamic_cast<Control ^>(target);
if (control)
{
control->FontFamily = fontFamily;
if (fOverrideFontWeight)
{
control->FontWeight = fontWeight;
}
if (sizeToUse != 0.0)
{
control->FontSize = sizeToUse;
}
else
{
control->ClearValue(Control::FontSizeProperty);
}
}
else
{
auto textBlock = dynamic_cast<TextBlock ^>(target);
if (textBlock)
{
textBlock->FontFamily = fontFamily;
if (fOverrideFontWeight)
{
textBlock->FontWeight = fontWeight;
}
if (sizeToUse != 0.0)
{
textBlock->FontSize = sizeToUse;
}
else
{
textBlock->ClearValue(TextBlock::FontSizeProperty);
}
}
else
{
RichTextBlock ^ richTextBlock = dynamic_cast<RichTextBlock ^>(target);
if (richTextBlock)
{
richTextBlock->FontFamily = fontFamily;
if (fOverrideFontWeight)
{
richTextBlock->FontWeight = fontWeight;
}
if (sizeToUse != 0.0)
{
richTextBlock->FontSize = sizeToUse;
}
else
{
richTextBlock->ClearValue(RichTextBlock::FontSizeProperty);
}
}
else
{
TextElement ^ textElement = dynamic_cast<TextElement ^>(target);
if (textElement)
{
textElement->FontFamily = fontFamily;
if (fOverrideFontWeight)
{
textElement->FontWeight = fontWeight;
}
if (sizeToUse != 0.0)
{
textElement->FontSize = sizeToUse;
}
else
{
textElement->ClearValue(TextElement::FontSizeProperty);
}
}
}
}
}
}