PL 20.40b12 x64
I have an AddIn, compiled as an executable (.EXE), that creates a text layer. When PL is first started, and the AddIn is run, the lines of text are distorted when the image is viewed at 100%: If I change the View to another percentage, or export the image, the text lines look correct: If I select the Text tool, and change the font, then after running the AddIn again the text looks correct at 100%.
The AddIn has a GUI form that contains one textbox (textBox1) and one button (OKbutton). In case the problem is with the AddIn code, here's the complete content of the Form1.cs (C#) file that creates the text layer:
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HelloWorld {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
// Initialize a ResourceManager to retrieve localized strings.
ResourceManager locRM = new ResourceManager("HelloWorld.Resource1", typeof(Form1).Assembly);
// Populate the text box with either the default text or the saved user's text.
if (Properties.Settings.Default.UserText == null || Properties.Settings.Default.UserText == "") {
textBox1.Text = locRM.GetString("DefaultText");
} else {
textBox1.Text = Properties.Settings.Default.UserText;
}
}
/// <summary>
/// Create a text layer with the specified content and formatting.
/// </summary>
/// <param name="doc">The active document/image.</param>
/// <param name="selectedlayer">The selected layer.</param>
public void CreateTextLayer(PhotoLine.document doc, PhotoLine.layer selectedlayer) {
// Initialize the arrays and variables that will be needed.
int[] charrange = new int[] { 0, 1 };
int[] RGBvalue = new int[] { 255, 255, 255 };
string testtext;
// Initialize the new text layer.
PhotoLine.Text targetlayer = new PhotoLine.Text();
// Get the text in the textbox.
testtext = textBox1.Text;
// Create the font attributes object.
PhotoLine.Dictionary fontAttribute = new PhotoLine.Dictionary();
fontAttribute.Add("FamilyName", "Arial");
fontAttribute.Add("Size", 72);
fontAttribute.Add("Weight", 700);
// Create the paragraph attributes object.
PhotoLine.Dictionary paragraphObject = new PhotoLine.Dictionary();
paragraphObject.Add("Alignment", PhotoLine.ParagraphAlignment.PACenter);
paragraphObject.Add("FixLine", true);
paragraphObject.Add("Line", 50);
// Set text of the new layer and the range of text characters that will be affected.
targetlayer.Text = testtext;
charrange[1] = targetlayer.TextLength;
// Apply the paragraph and font attributes to the affected text characters.
targetlayer.SetAttribute(charrange, "Paragraph", paragraphObject);
targetlayer.SetAttribute(charrange, "Color", RGBvalue);
targetlayer.SetAttribute(charrange, "Font", fontAttribute);
// Set the vertical alignment of the text layer's content.
targetlayer.VerticalAlignment = PhotoLine.TextVerticalAlignment.TVACenter;
// Name the new text layer, size it to the document size and create the text layer.
targetlayer.Name = "C# Add-In";
targetlayer.Size = doc.Size;
selectedlayer.Parent.Insert(targetlayer, selectedlayer);
}
/// <summary>
/// Close the AddIn.
/// </summary>
public static void CloseAddIn() {
Form1.ActiveForm.Dispose();
}
private void OKbutton_Click(object sender, EventArgs e) {
PhotoLine.Application app = new PhotoLine.Application();
if (app != null) {
PhotoLine.document doc = app.ActiveDocument;
if (doc != null) {
PhotoLine.layer selectedlayer = (PhotoLine.layer)doc.ActivePage.ActiveLayer;
if (selectedlayer != null) {
try {
CreateTextLayer(doc, selectedlayer);
} catch (Exception appe) {
MessageBox.Show(appe.InnerException.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
throw;
} finally {
// Save the user's text and close the AddIn.
Properties.Settings.Default.UserText = textBox1.Text;
Properties.Settings.Default.Save();
CloseAddIn();
}
}
}
}
}
}
}