Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect fonts when building on Windows Server Core #714

Closed
Mark-Dunning opened this issue Aug 30, 2019 · 4 comments
Closed

Incorrect fonts when building on Windows Server Core #714

Mark-Dunning opened this issue Aug 30, 2019 · 4 comments

Comments

@Mark-Dunning
Copy link

We've recently switched some build servers to Windows Server Core and this has switched all of the fonts used in 'CustomUI' installers to 'Lucida Console' (which doesn't look particularly good). Note that we aren't using any custom fonts - just the default of "Tahoma".

image

What seems to be happening is that Wix# replaces the configured font with an installed font if the configured font is not available at build time. As Server Core only has Lucida Console installed, that is what it always ends up using.

As a temporary workaround we're using the 'WixSourceGenerated' event to patch the generated XML to reset the font to 'Tahoma'.

@oleg-shilo
Copy link
Owner

Thank you for reporting this. Can you please share your WixSourceGenerated' event to patching solution so I can investigate it?

@Mark-Dunning
Copy link
Author

Sure, this is what I have at the moment:

project.WixSourceGenerated += document =>
{
    if (project.CustomUI == null)
        return;

    var textStyleName = XName.Get("TextStyle", "http://schemas.microsoft.com/wix/2006/wi");
    foreach (var textStyle in document.Descendants(textStyleName))
    {
        var textStyleId = textStyle.Attribute("Id").Value;
        if (project.CustomUI.TextStyles.TryGetValue(textStyleId, out var font))
            textStyle.SetAttribute("FaceName", font.OriginalFontName);
    }
};

The general idea is to use the 'OriginalFontName' of the System.Drawing.Font rather than the translated font name.

@oleg-shilo
Copy link
Owner

oleg-shilo commented Sep 2, 2019

Thank you for the code snippet.
It's an excellent pick, which is very difficult to spot/predict.

Fixed. Will be available in the next release.

A small improvement to your work around... You can use FindAll extension method so you don't need to deal with the namespaces:

if (project.CustomUI == null)
    return;

foreach (var textStyle in document.FindAll("TextStyle"))
{
    . . . 

@Mark-Dunning
Copy link
Author

Thanks very much. And for the tip about FindAll.

oleg-shilo pushed a commit that referenced this issue Sep 13, 2019
* Issue #695: FR - Implement Harvester using wix heat.
* Issue #714: Incorrect fonts when building on Windows Server Core
* Added `XElement.GetAttribute` extension method.
* New class `PublicProperty` to encapsulate a public property which must be uppercase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants