We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Shape Is Not Fitting Text with Certain Fonts

I am using TextAutofitType.Shape to auto-expand the shape to fit the text inside. In most cases, it works as expected. However, it does not when using the font “Meiryo”. The text goes well outside the shape, both on the left and right. I am using version 21.8.

Here is a screenshot of what it looks like: 2021-11-23 09_35_38-aspose-output.pptx - PowerPoint.png

using (var presentation = new Presentation())
	var slide = presentation.Slides[0];
	var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 50, 1, 1);
	var portion = shape.TextFrame.Paragraphs[0].Portions[0];
	var text = "this is my formatted text";
	var fontName = "Meiryo";
	var fontSize = 24;

	shape.FillFormat.FillType = FillType.NoFill;
	shape.TextFrame.TextFrameFormat.WrapText = NullableBool.False;
	shape.TextFrame.TextFrameFormat.AutofitType = TextAutofitType.Shape;

	portion.PortionFormat.LatinFont = new FontData(fontName);
	portion.PortionFormat.FontHeight = fontSize;
	portion.PortionFormat.FillFormat.FillType = FillType.Solid;
	portion.PortionFormat.FontBold = NullableBool.True;
	portion.Text = text;

	var file = @"C:\temp\aspose-output.pptx";
	presentation.Save(file, SaveFormat.Pptx);

Welcome to our community! Thank you for the issue description.

I reproduced the problem with fitting text and logged the issue with ID SLIDESNET-42920 in our tracking system. Our development team will investigate this case. You will be notified when the issue is resolved.