Hi,
I'm listing all fonts installed on a pc in a dropdown.
If a user chooses a font, I want to apply that to a dw column.
To do so, I need to set the "font.face" and the "font.family" (values 0 - 6, "Modern", "DontCare", "Roman", "Swiss", etc.) with a Modify() statement. (not sure if pb handles the "DontCare" value).
I'm getting the list of font names (for the "font.face" attribute), using C#, but I haven't figured out how to determine the font.family, given the name of a font.face.
So in short:
How do I get the font.family value for let's say "Arial" ?
Is there an API or do I oversee something in C#?
In C# I do something like this (see code below), but the fontFamilies[j].Name corresponds to what we need for font.facename that we need in PB. I don't see how to get the other value I need:
Anyone?
public void GetFontList()
{
//string fontName = "", fontFamily = "";
//string fontList = "";
//for each(fontName in fonts.)
//foreach (FontFamily font_family in fonts.Families)
//{
// // lstFonts.Items.Add(font_family.Name);
// fontFamily = font_family.Name;
// fontName = font_family.
// //fontList +=
//}
//return fontList;
FontFamily fontFamily = new FontFamily("Arial");
Font font = new Font(
fontFamily,
8,
FontStyle.Regular,
GraphicsUnit.Point);
string familyName;
string familyList = "";
FontFamily[] fontFamilies;
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
// Get the array of FontFamily objects.
fontFamilies = installedFontCollection.Families;
// The loop below creates a large string that is a comma-separated
// list of all font family names.
int count = fontFamilies.Length;
int familyFamily;
// string sFamilyFamily = "";
for (int j = 0; j < count; ++j)
{
familyName = fontFamilies[j].Name;
//switch (familyFamily)
//{
// case 0:
// sFamilyFamily = "";
// break;
// case 1:
// sFamilyFamily = "";
// break;
// case 2:
// sFamilyFamily = "";
// break;
// case 3:
// sFamilyFamily = "";
// break;
// case 4:
// sFamilyFamily = "";
// break;
// case 5:
// sFamilyFamily = "";
// break;
// default:
// sFamilyFamily = "[Unknown]";
// break;
//}
//familyList += (familyName + " [@@] " + sFamilyFamily + "\r\n" );
}
}