TextFontInfo.Style
Contents
[
Hide
]TextFontInfo.Style property
Gets font style parsed from subfamily name
public FontStyle Style { get; }
Property Value
Font style parsed from subfamily name
Examples
The following code demonstrates how Aspose.PSD gets properties of inline formatting of Text Layer.
[C#]
string sourceFile = "inline_formatting.psd";
List<ITextPortion> regularText = new List<ITextPortion>();
List<ITextPortion> boldText = new List<ITextPortion>();
List<ITextPortion> italicText = new List<ITextPortion>();
// Load an existing image into an instance of PsdImage class
using (var psdImage = (PsdImage)Image.Load(sourceFile))
{
var layers = psdImage.Layers;
for (int index = 0; index < layers.Length; index++)
{
var layer = layers[index];
if (!(layer is TextLayer))
{
continue;
}
var textLayer = (TextLayer)layer;
// gets fonts that contains in text layer
var fonts = textLayer.GetFonts();
var textPortions = textLayer.TextData.Items;
foreach (var textPortion in textPortions)
{
TextFontInfo font = fonts[textPortion.Style.FontIndex];
if (font != null)
{
switch (font.Style)
{
case FontStyle.Regular:
regularText.Add(textPortion);
break;
case FontStyle.Bold:
boldText.Add(textPortion);
break;
case FontStyle.Italic:
italicText.Add(textPortion);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
}
See Also
- enum FontStyle
- class TextFontInfo
- namespace Aspose.PSD.FileFormats.Psd.Layers.Text
- assembly Aspose.PSD