Macro for font convert.
Macro for font convert.
The document to convert uses SuperHebrew, MeadEastern Roman, MidEast Times and Gilboa. The transcriptions in the document is in MeadEastern Roman and MidEast Times. These two should be converted to one unicode font. Every font in the document change when using a font to uc macro. So I need to specify which fonts to convert. What is the code for that?
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Macro for font convert.
You'll want to have a look at the transliteration templates. Basically the macro needs to know exactly how the old pre-Unicode characters map to the Unicode character set. It can then select all text in a specific font and transliterate all these old characters.
Re: Macro for font convert.
Is it possible to write such script remapping two or three different fonts at the same time in that same script? I tried the NSAramian but got remap on all the fonts. I read the groups. They show how to specify result font but I can't find one on how to specify which fonts to remap.
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Macro for font convert.
It is indeed. Let's say you wanted to convert two fonts with the same script. The "Find" command in the macro templates should then be:xlfp wrote:Is it possible to write such script remapping two or three different fonts at the same time in that same script?
Code: Select all
Find '.+|.+', 'Eua'
I would guess this is because you don't have a document that contains the NSAramian font. Is that correct? Try opening the NSAramian macro example and changing the font applied to ".+" to something like Copperplate and then running it in a test document that has both Copperplate and Times applied. You should see just the Copperplate text change.I tried the NSAramian but got remap on all the fonts.
Re: Macro for font convert.
I'm doing it this way:
Find 'MidEastTimes', 'Eua'
and to add another:
Find 'MidEastTimes|MeadEastern Roman', 'Eua'
Is this right?
It doesn't work...

Find 'MidEastTimes', 'Eua'
and to add another:
Find 'MidEastTimes|MeadEastern Roman', 'Eua'
Is this right?
It doesn't work...

Re: Macro for font convert.
No, you'll need to write the find expression exactly as Martin said with '.+' etc., and then you need to apply the actual font to the relevant bits of the expression.
May I however suggest a different approach to this problem? Try going to the macro repository and download Kino's "Select by font" macro. That will make it much easier to select the parts that you want.
May I however suggest a different approach to this problem? Try going to the macro repository and download Kino's "Select by font" macro. That will make it much easier to select the parts that you want.
philip
Re: Macro for font convert.
Thank you, Philip, for recommending my macro but it won’t solve the problem the original poster is having, I think. I have never used MeadEastern Roman and MidEast Times but, xlfp, isn’t it just because none of them has all characters you need that you have been using both of them? If so, you should never do
As Philip said, it is not always easy to do attribute sensitive find/replace in a macro. So try the following macro. Before running it, you have to change the font name in $oldFont = 'TimesTL' to MeadEastern Roman or MidEastTimes and modify the conversion map accordingly.
You should begin with trying it for a single font conversion — or some characters only. It is a bad idea to try to do everything at once when you don’t now exactly how these things work.
If the macro will have worked as expected, then, copy the code from Begin convert TimesTL to End convert TimesTL, paste it at the end of the macro, change the font name in $oldFont = 'TimesTL' to the second font and modify the conversion map accordingly.
because most likely those two fonts assign different glyphs to the same code points. As transliterateInRange command is not attribute sensitive (i.e. it does not distinguish fonts), you will get unexpected results. You may not understand what I mean if you have installed them in your Mac running OS X and I strongly recommend you to delete them. Their existence conceals the nature of your problem and might cause other problems. In OS X, you should never use those fake encoding fonts unless you are totally aware of what you are doing.xlfp wrote:Find 'MidEastTimes|MeadEastern Roman', 'Eua'
As Philip said, it is not always easy to do attribute sensitive find/replace in a macro. So try the following macro. Before running it, you have to change the font name in $oldFont = 'TimesTL' to MeadEastern Roman or MidEastTimes and modify the conversion map accordingly.
You should begin with trying it for a single font conversion — or some characters only. It is a bad idea to try to do everything at once when you don’t now exactly how these things work.
If the macro will have worked as expected, then, copy the code from Begin convert TimesTL to End convert TimesTL, paste it at the end of the macro, change the font name in $oldFont = 'TimesTL' to the second font and modify the conversion map accordingly.
Code: Select all
Require Pro Version 1.3
$doc = Document.active
if $doc == undefined
exit
end
# ======== Begin convert TimesTL ========
$oldFont = 'TimesTL'
$newFont = 'Times New Roman'
$map = Hash.new # initialize the conversion map for TimesTL (MacRoman charmap order)
$map{'¢'} = 'Č' # U+00A2 => U+010C
$map{'£'} = 'č' # U+00A3 => U+010D
$map{'®'} = 'Ş' # U+00AE => U+015E
$map{'©'} = 'ş' # U+00A9 => U+015F
$map{'™'} = 'Š' # U+2122 => U+0160
$map{'´'} = 'š' # U+00B4 => U+0161
$map{'¨'} = 'Ž' # U+00A8 => U+017D
$map{'≠'} = 'ž' # U+2260 => U+017E
$map{'∞'} = 'Ǧ' # U+221E => U+01E6
$map{'±'} = 'ǧ' # U+00B1 => U+01E7
$map{'≤'} = 'Ḍ' # U+2264 => U+1E0C
$map{'≥'} = 'ḍ' # U+2265 => U+1E0D
$map{'¥'} = 'Ḏ' # U+00A5 => U+1E0E
$map{'µ'} = 'ḏ' # U+00B5 => U+1E0F
$map{'∂'} = 'Ḥ' # U+2202 => U+1E24
$map{'∑'} = 'ḥ' # U+2211 => U+1E25
$map{'∏'} = 'Ḫ' # U+220F => U+1E2A
$map{'π'} = 'ḫ' # U+03C0 => U+1E2B
$map{'∫'} = 'Ṣ' # U+222B => U+1E62
$map{'Ω'} = 'ṣ' # U+03A9 => U+1E63
$map{'¬'} = 'Ṭ' # U+00AC => U+1E6C
$map{'√'} = 'ṭ' # U+221A => U+1E6D
$map{'ƒ'} = 'Ṯ' # U+0192 => U+1E6E
$map{'≈'} = 'ṯ' # U+2248 => U+1E6F
$map{'∆'} = 'ʾ' # U+2206 => U+02BE
$map{'÷'} = 'Ẓ' # U+00F7 => U+1E92
$map{'◊'} = 'ẓ' # U+25CA => U+1E93
$map{'⁄'} = 'Ğ' # U+2044 => U+011E
$map{'€'} = 'ğ' # U+20AC => U+011F
$map{'‹'} = 'İ' # U+2039 => U+0130
$map{'›'} = 'ı' # U+203A => U+0131
$map{'‰'} = 'ʿ' # U+2030 => U+02BF
$map{''} = 'ʽ' # U+F8FF => U+02BD
$map{'ı'} = 'ǝ' # U+0131 => U+01DD
$map{'ˆ'} = 'Ā' # U+02C6 => U+0100
$map{'˜'} = 'ā' # U+02DC => U+0101
$map{'¯'} = 'Ē' # U+00AF => U+0112
$map{'˘'} = 'ē' # U+02D8 => U+0113
$map{'˙'} = 'Ī' # U+02D9 => U+012A
$map{'˚'} = 'ī' # U+02DA => U+012B
$map{'¸'} = 'Ō' # U+00B8 => U+014C
$map{'˝'} = 'ō' # U+02DD => U+014D
$map{'˛'} = 'Ū' # U+02DB => U+016A
$map{'ˇ'} = 'ū' # U+02C7 => U+016B
$selections = Array.new
foreach $text in $doc.allTexts # for each text object in the document
if $text.length
$index = 0
while $index < $text.length # check attributes through the text object
$attr = $text.attributesAtIndex $index # get attributes and put them in $attr
$range = $text.rangeOfAttributesAtIndex $index # get the range of the same attributes
if $attr.fontFamilyName == $oldFont # if the font family name is $oldFont
$sel = TextSelection.new $text, $range # create a new text selection object corresponding to the range
$selections.appendValue $sel # add the text selection object to $selections (array)
end
$index = $range.bound # skip to the end of the range
end
end
end
if $selections.count # if there is some text in $oldFont...
Push Target Selection $selections
Set Font Name $newFont # apply $newFont on $selections
Pop Target Selection
foreach $sel in reversed $selections # for each selection (in reverse order)
$sel.text.transliterateInRange $sel.range, $map # transliterate the whole selection according to $map
end
end
# ======== End convert TimesTL ========