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
xlfp wrote:Find 'MidEastTimes|MeadEastern Roman', 'Eua'
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.
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 ========