Scripting Support

Got a request? Post it here. Please do not post bug reports here.
Post Reply
icxn
Posts: 1
Joined: Sun Sep 19, 2004 7:14 pm

Scripting Support

Post by icxn » Sun Sep 19, 2004 7:35 pm

Is it possible to add scripting support for operations like:

for i := 3 to Glyph.count-1 do
Glyph.mappings['Microsoft Unicode'].Add($1D+i);

The above code assigns mappings to all the Glyphs excluding the first 3 starting from char $21 (Exclamation mark).

I 'm sure there are more things that can be done with scripting, such as appending glyphs to other glyphs (useful for combining diacritical marks) applying transformation to existing glyphs... importing glyphs from vector files, databases... even drawing glyphs programmatically... the possibilities are endless :)

For example to add a diacritical mark (say glyph $7) to glyphs $20-$30 you could write something like the following:

var
dm: TGlyph; // temporary glyph to hold diacritical mark
i: integer;
begin
dm := TGlyph.Create;
dm.Assign(Glyph[$7]);
for i := $20 to $30 do
Glyph.Merge(dm); // Merge copies the dm glyph without deleting the existing one
dm.free;
end;


What do you think?

Yours,
+Gregory

PS. If you are using Delphi to develop FCP (I think I 've read that somewhere) you probably know about TMS Scripting Components and the freeware Pascal Script, which should make the development of this feature very easy. I also use Delphi and I 'll be glad to help if that's possible.

Erwin Denissen
Moderator
Moderator
Posts: 7754
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Post by Erwin Denissen » Mon Sep 20, 2004 6:23 am

This could be a very useful feature, so I'm going to add it to the todo list.

I do use Delphi and I'm aware of some scripting engines, but I've never used them.
Erwin Denissen
High-Logic
Proven Font Technology

Dick Pape
Top Typographer
Top Typographer
Posts: 1360
Joined: Wed Oct 01, 2003 1:19 pm
Location: North Dallas, Texas

Post by Dick Pape » Wed Sep 22, 2004 7:01 am

Well now:

1. Can you give us Visual Basic support instead? I'm a Microsoft user!!

2. I cannot envision many uses for a scripting option as much as a macro option could provide. I don't know if there is a difference. But I like the word "macro" better than "script"! Nicely they'd be constructed using keyboard actions, not programming! You're a programmer, I'm a user! You can do it with keyboards I bet, and I can't do it with programming I bet!

3. We need help in assigning maps. I would like to see a screen where the Macintosh and Microsoft and whatever maps can be assigned at the same time. It would be nice to have a table of "equals" where there is a glyph number, character name and then the mapping values for all selected platforms. A simple Select glyph (using the Unicode ranges) and Add would map all platforms. Now we have to look up every glyph twice.

I believe you have to look at the glyph to determine what the character is from which the Map is derived. Hard to make that decision in a script. Maybe we should be given a blank font which is properly scripted and then delete down to what we need. We already have this however.

3. I don't see how a script or macro adding diacritical marks would work since both the base character and diacritical mark change so frequently (in Latin fonts). There may be a, c, e, i, n, o, u composites which use acute, grave, circumflex, dieresis, tilde, ring and cedilla in some combination to arrive at 25 composites at the rate of 6-a, 1-c, 4-e, 4-i, 1-n, 5-0, 4-u... Would appear to be a rather complicated problem to program? How often would we use that -- once per new font.

Alternatively for building composites, if we had two windows, one for the base letter and one for the diacritical mark, it might be easier to put composites together. If we could just group all diacritical marks together that would help a whole lot right now.

This leads to: I type `A and you figure it out to be À, LATIN CAPITAL LETTER A WITH GRAVE, Maps 192/0203 and show me a Grave and an A in an edit window. At best I move them into proper position. (Missing parts is an edit error, like duplicate mapping is now).

Even better - font design then becomes 0-9, a-z, A-Z, 10-30 diacriticals, and some 10-20 specials. Then you do all the rest. AHHHH, WITH A SCRIPT!!

Every font is fully specified when I design one. Gonna take all the tedium out of unicode fonts....

Now about Validates ... (oops very different thread.)

Dick

LucBloom

Post by LucBloom » Mon Nov 22, 2004 12:14 pm

Hi, i'm a programmer that uses FCP to modify existing fonts. I often get fonts from Americans where the accented characters are missing. To use these fonts in Europe, I have to add about 60 extra characters. In FCP's interface, this is a very tedious task:

-Add 60 glyph
-Format -Mappings

60x
-Select next empty glyph
-Paste value + 1
-Push add

A scripting language would certainly solve this, but in the short run it would also be nice to accomplish this task in another way.

Also, I often copy the 'A', 'E', 'I' etc a number of times for all possible accents, but then I can't see the Glyph that it's supposed to be in the character's Caption. Is there an easy way to put the character that is in the glyph when it's empty in the Caption? ('Postscript name' maybe)

Also, a lot of basic characters have the same kerning as their counterparts with accents. Could that piece of interface be redesigned too, so that you can copy character kerning lists or something?

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7863
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala » Mon Nov 22, 2004 5:56 pm

Is there an easy way to put the character that is in the glyph when it's empty in the Caption? ('Postscript name' maybe)
Yes. Start a new font. This uses the WGL4.TTF template, which contains images of all the glyphs, and all the mappings and postscript names. Just copy the glyphs that you need to the font you are working on. Instead of just pasting the glyphs, use Paste Special and check the boxes to copy postscript names and mappings (and over-ride existing mappings if you wish to do that).

Accents are best added by using composites. From what Erwin says in this post, I think you will soon see a feature to automatically complete composites from the mappings, so scripting probably won't be necessary. All that one will need to do is make fine adjustments to the position of diacritics, which one would have to do after using a scripting language anyway.
My FontsReviews: MainTypeFont CreatorHelpFC11.5 Pro + MT8.0 @ Win10 1809 build 17763.379

LucBloom

Post by LucBloom » Wed Nov 24, 2004 11:37 am

Thank you for that explanation. Creating a new font gives me the character mappings i want, but i'm not sure if there's any additional information that i might lose if i only copy the characters and their properties.

I'm currently looking at www.fontlab.com and it has a much better way of creating new mappings:
show all default characters glyphs in a char set that you chose, and double click to create the mapping. Maybe something for high-logic?

The use of composites + offsets is indeed a good way to define a font. (Altough i'm currently working on a handwrite font, which can use some randomness)

Again, thanks.

sevry7
Posts: 32
Joined: Mon Jan 31, 2005 4:50 pm

Post by sevry7 » Fri Feb 11, 2005 11:08 pm

LucBloom wrote: A scripting language would certainly solve this, but in the short run it would also be nice to accomplish this task in another way.
Scripting is a vital improvement for any program, of course. The question might be, what sort of problems need to be addressed? Then they could consider most likely API calls into their engine. Adding blank characters might be one. Say you want a new range $390-$421, or whatever, and you want a composite copy of your missing character glyph, wherever you have that, in each cell. A script could be written for that, rather than try to include that, and so much else, as a new feature.

sevry7
Posts: 32
Joined: Mon Jan 31, 2005 4:50 pm

What kind of scripting?

Post by sevry7 » Fri Feb 11, 2005 11:25 pm

Various programming languages seem to be coming together in the control structures so that perhaps we're approaching a single dominant language, sort of a mix of basic and C, I don't know. But the alternative to that is the recursive or declarative languages like that used in XSLT, and of course, python. I don't know if it would be easier to manage implementing python, or cheaper? But there are some limitations, in my opinion, to recursive languages. And I think people find a BASIC language much more intuitive and so less prone to mistake. I don't know what package you were considering. But just for myself, I would recommend a procedural language, if possible.

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7863
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala » Sat Feb 12, 2005 8:24 am

This is no longer necessary. Font Creator 5 Professional Edition includes two new features to do what you suggest very efficiently.

:arrow: Insert Characters. Select the first character in the range you wish to add, e.g. Latin Capital A macron Ā (256), by double-clicking. Then hold down shift while double clicking on the last character in the range, e.g. Latin small letter long s (383). This will add "256-383" to the add characters field. OK will then insert all these characters into your font, with the correct mappings and postscript names (unless they already exist).

:arrow: Select this range of new characters, right-click and select "Complete Composites" or click on the Complete Composites icon on the toolbar. This will automatically compose these characters as long as the glyph members exist. That is Ā and ā will be composed provided A,a, and modifier letter macron ˉ exist in your font. All you need to do then is adjust the vertical position of the macron for lowercase letters, and adjust the horizontal position for individual composites, and vertical position for capital letters.
My FontsReviews: MainTypeFont CreatorHelpFC11.5 Pro + MT8.0 @ Win10 1809 build 17763.379

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7863
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala » Sat Feb 12, 2005 8:42 am

A scripting language could certainly enhance Font Creator, and make it even more powerful than it is. I used to use Perfect Keyboard Pro to automate repetitive tasks, but no longer bother. A macro language built in to Font Creator would make it possible for users to share useful scripts. However, the new features in FC5 make this a much lower priority for me than it once was.

I used to spend a lot of time writing macros in WordPerfect 6.1 for Windows, and found the BASIC like language fairly easy to learn, but all that knowledge of syntax and commands is useless now. I wrote a macro for creating drop caps, for example, but now the feature is built in to the program. Of course, the programmed feature is far more powerful, faster, and more reliable than my macro ever was.
My FontsReviews: MainTypeFont CreatorHelpFC11.5 Pro + MT8.0 @ Win10 1809 build 17763.379

sevry7
Posts: 32
Joined: Mon Jan 31, 2005 4:50 pm

Post by sevry7 » Sat Feb 12, 2005 8:13 pm

Bhikkhu Pesala wrote:This is no longer necessary. Font Creator 5 Professional Edition includes two new features to do what you suggest very efficiently.
But what if, as in the example, it's the same composite for each cell? Let's say you create a character, a box say, to indicate that you have no glyph at that position. And you create the 'character' range. How do you populate each character not with a contour, but with composites of that missing char glyph? When I try it, using paste, it simply uses the original contour in every place, forcing me to manually add the composite to each by editing each cell in turn. Maybe it was a bad example of the need for scripting. Again, I don't know. I did sort of plead that if it were possible to avoid python, which apparently is inexpensive, I think it would be great. A procedural language would be far more welcome, as I believe was incorporated in the latest version of Adobe's Photoshop (I haven't seen these, someone correct me if I'm wrong).

sevry7
Posts: 32
Joined: Mon Jan 31, 2005 4:50 pm

Post by sevry7 » Sat Feb 12, 2005 8:17 pm

Bhikkhu Pesala wrote: Of course, the programmed feature is far more powerful, faster, and more reliable than my macro ever was.
I would just say, again, that macro programming is one of the thngs that really can bring a program alive. You should have seen the things I did with macros back on the old AmiPro, which had almost C-like programming capabilities (until Lotus bought it and killed the product). I'm new to creating typefaces. It's something I hadn't expected I'd be doing for this project. Perhaps I can't think of a good example, then, at this point.

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7863
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala » Sat Feb 12, 2005 8:47 pm

I'm not sure why you would want to define glyphs to mimic the function of the notdef glyph, since if you didn't define them in the first place, those characters would show up with the notdef glyph in applications anyway.

It is not difficult to define your own new composites and add them to CompositeData.xml, but the notdef glyph cannot be referenced AFAIK. You would have to copy it once to glyph 390, then insert composites of that glyph.

You could add definitions or replace existing ones by carefully copying and pasting definitions with the xml file. (Backup first, of course)

Code: Select all

<Composite> <!-- My glyph 1-->
<GlyphMapping>391</GlyphMapping>
	<Member>
	<GlyphMapping>390</GlyphMapping>
		<UseMetrics>TRUE</UseMetrics>
	</Member>
	</Composite>
<Composite> <!-- My glyph 2-->
<GlyphMapping>392</GlyphMapping>
	<Member>
	<GlyphMapping>390</GlyphMapping>
		<UseMetrics>TRUE</UseMetrics>
	</Member>
	</Composite>
My FontsReviews: MainTypeFont CreatorHelpFC11.5 Pro + MT8.0 @ Win10 1809 build 17763.379

Post Reply