Article View: adobe.photoshop.scripting
Article #1989Textitem.Size in CS
From: johnbeardy
Date: Sun, 04 Jul 2004 07:42
Date: Sun, 04 Jul 2004 07:42
38 lines
2029 bytes
2029 bytes
I'm trying to add some text to an image using either JavaScript or VB6 and find that I can't reliably set the text size. I first noticed the problem using JS but have repeated it in VB6. I know I am calculating the required size OK, and hard coding makes no difference. Maybe the issue is related to another post earlier this year? Mick Murphy "Bug with TextItem.Position in PS CS scripting?" 3/31/04 11:27pm </cgi-bin/webx?13@@.2ccea5b0/10>
I'll post the code below with comments showing the font size value at key points. The image is 3503 wide by 2368 high.
Any thoughts?
John
'photoshop declarations
Dim appRef As New Photoshop.Application
Dim docRef As Photoshop.Document
Dim artLayerRef As Photoshop.ArtLayer
Dim textItemRef As Photoshop.TextItem
Dim FontSize As Variant
Sub Copyright()
appRef.Visible = True
Set docRef = appRef.ActiveDocument
strTypeUnits = appRef.Preferences.TypeUnits
appRef.Preferences.TypeUnits = Photoshop.PsTypeUnits.psTypePixels
If docRef.Height > docRef.Width Then
FontSize = docRef.Height / 100
Else
FontSize = docRef.Width / 100 'calculated 35
End If
Set artLayerRef = docRef.ArtLayers.Add
artLayerRef.Kind = psTextLayer
Set textItemRef = artLayerRef.TextItem
textItemRef.Size = FontSize 'Size = 1313.625!!!
textItemRef.Contents = "�john"
textItemRef.Size = 30 ' this doesn't work
End Sub
Technical Details
Message-ID:
<3bb4e604.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Thread: f5839,7c744877183e1e4d,start X-Google-Attributes: gidf5839,public X-Google-Language: ENGLISH,ASCII From: johnbeardy@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.photoshop.scripting Subject: Textitem.Size in CS Message-ID: <3bb4e604.-1@webx.la2eafNXanI> Date: Sun, 4 Jul 2004 00:42:09 -0700 Lines: 45 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit