How do I set FontDirectories in GroupDocs.Conversion .NET 24.2?

In a previous version (22.1) I was setting the FontDirectories of the ConvertSettings object.

Trying to upgrade to 24.2, this now looks like a read-only property and throws an error.

How can I set this so I can use custom fonts?

@agilelaw

Please take a look at this document API reference. Let us know if you still have any query regarding font substitution.

No this is not what I’m looking for at all.

I’m using .NET on Linux so I have to reference 100s of Microsoft fonts, which I have done by setting the FontDirectories to the multiple directories that include my custom fonts.

Please fix this so that this property is no longer read only. All the other settings have both get and set functions. This is a major loss of functionality

1 Like

@agilelaw
Thanks for the clarification. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CONVERSIONNET-6717

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@agilelaw

Yes, the property FontDirectories is read-only, but you still may set folders:

var settings = new ConverterSettings();
settings.FontDirectories.AddRange(new List<string>
{
    ".",
    "/usr/share/fonts"
});

By default, the FontDirectories property contains the current working folder. If you need to clear the default value you can use the following:

settings.FontDirectories.Clear();

Please let us know if this works for you.

Looks like this is working

@agilelaw

Glad to know that the issue is resolved.

I wanted to follow up on this issue as I reported it “working” last year but I believe that only meant the program was able to compile.

I’m finally getting around to upgrading (and now using 25.1) but even though the code “works” it does not actually use the fonts that I have provided. The previous code on version 22.1 that assigns the list of directories to settings.FontDirectories works, but when I upgrade to 25.1 and call FontDirectories.Add (or .AddRange) and then convert the same file, the fonts are wrong so it is not using the directories that I have provided.

@agilelaw

Could you please share following details and we’ll investigate this issue:

  • Sample conversion code
  • Source and the resultant files
  • Font that you are going to use

Here is the code change. The original works but the change does not.

             List<string> fontDirs = new List<string>();
             foreach(var font in fontsArg.Split(":"))
             {
+                Console.Error.WriteLine(font);
                 fontDirs.Add(font);
             }
 
-            settings.FontDirectories = fontDirs;
+            settings.FontDirectories.Clear();
+            settings.FontDirectories.AddRange(fontDirs);

presentation_pptx.zip (47.5 KB)

1 Like

@agilelaw
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CONVERSIONNET-7501

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

I created and attached a minimal program that converts the PPTX as well as the output pdfs. If I change the version from 22.1.0 to 25.1.0 (and provide the correct license key for each version) and rebuild and rerun the same exact program, it produces different outputs. The font is correct in the 22.1.0 version if you inspect the PDF font properties. The font is installed on my system as well as explicitly referenced in the FontDirectories setting.

fc-list | grep "Segoe"
/var/lib/agilelaw/fonts/windows/segoeuisl.ttf: Segoe UI,Segoe UI Semilight:style=Semilight,Regular
/var/lib/agilelaw/fonts/windows/seguisym.ttf: Segoe UI Symbol:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/var/lib/agilelaw/fonts/windows/segoeuil.ttf: Segoe UI,Segoe UI Light:style=Light,Regular
/var/lib/agilelaw/fonts/windows/seguisbi.ttf: Segoe UI,Segoe UI Semibold:style=Semibold Italic,Italic
/var/lib/agilelaw/fonts/windows/segoeui.ttf: Segoe UI:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/var/lib/agilelaw/fonts/windows/segoepr.ttf: Segoe Print:style=Regular
/var/lib/agilelaw/fonts/windows/segoescb.ttf: Segoe Script:style=Bold
/var/lib/agilelaw/fonts/windows/seguihis.ttf: Segoe UI Historic:style=Regular
/var/lib/agilelaw/fonts/windows/segoeprb.ttf: Segoe Print:style=Bold
/var/lib/agilelaw/fonts/windows/seguibli.ttf: Segoe UI,Segoe UI Black:style=Black Italic,Italic
/var/lib/agilelaw/fonts/windows/segoeuii.ttf: Segoe UI:style=Italic,Cursiva,Kurzíva,Kursiv,Πλάγια,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,Nghiêng,Etzana
/var/lib/agilelaw/fonts/windows/segoesc.ttf: Segoe Script:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/var/lib/agilelaw/fonts/windows/seguisli.ttf: Segoe UI,Segoe UI Semilight:style=Semilight Italic,Italic
/var/lib/agilelaw/fonts/windows/segmdl2.ttf: Segoe MDL2 Assets:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta
/var/lib/agilelaw/fonts/windows/seguili.ttf: Segoe UI,Segoe UI Light:style=Light Italic,Italic
/var/lib/agilelaw/fonts/windows/seguiemj.ttf: Segoe UI Emoji:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/var/lib/agilelaw/fonts/windows/seguibl.ttf: Segoe UI,Segoe UI Black:style=Black,Regular
/var/lib/agilelaw/fonts/windows/segoeuiz.ttf: Segoe UI:style=Bold Italic,Negreta Cursiva,Tučné Kurzíva,Fed Kursiv,Fett Kursiv,Έντονα Πλάγια,Negrita Cursiva,Lihavoitu Kursivoi,Gras Italique,Félkövér Dőlt,Grassetto Corsivo,Vet Cursief,Halvfet Kursiv,Pogrubiona Kursywa,Negrito Itálico,Полужирный Курсив,Tučná Kurzíva,Fet Kursiv,Kalın İtalik,Krepko Poševno,Nghiêng Đậm,Lodi Etzana
/var/lib/agilelaw/fonts/windows/seguisb.ttf: Segoe UI,Segoe UI Semibold:style=Semibold,Regular
/var/lib/agilelaw/fonts/windows/segoeuib.ttf: Segoe UI:style=Bold,Negreta,Tučné,Fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Đậm,Lodia

dotnet-converter.zip (48.7 KB)

1 Like

@agilelaw

Thanks for the additional details. We’ll investigate the provided project as well.