7 Replies Latest reply on Apr 2, 2008 1:32 PM by (Tim_Melis)

    [cs2][JS] Search/replace by glyphID

      Hi,

      Does any know to change some special characters by glyphID?

      What I'm trying to do is ...

      app.findPreferences = app.changePreferences = null;
      app.findPreferences.appliedFont = 'ITC Zapf Dingbats\tMedium';
      app.changePreferences.appliedFont = 'ITC Zapf Dingbats Std\tMedium';
      app.activeDocument.search(glyphID=81,undefined,undefined, glyphID=79);

      But it doesn't seem te work

      Tim
        • 1. Re: [cs2][JS] Search/replace by glyphID
          Level 1
          glyphID can't be used for searching in CS2.

          Dave
          • 2. Re: [cs2][JS] Search/replace by glyphID
            Level 1
            Hi Dave

            Is there an other solution? Using unicode for example?

            Thanx

            Tim
            • 3. Re: [cs2][JS] Search/replace by glyphID
              Level 1
              Yes. You can search for unicode values by:

              app.activeDocument.search("\u0020", undefined, undefined, "\u0009");

              That will change all spaces to tabs.

              Dave
              • 4. Re: [cs2][JS] Search/replace by glyphID
                [Jongware] Most Valuable Participant
                You cannot change one glyph on a character mapping position into another on the same position using Unicode.
                For example, the bullet character in the Minion Pro font has a lot of 'variants'; these are only accessable/insertable through the glyph menu. And resetting the paragraph style reverts it back to its bullet shape.

                Replacing one glyph with another this way
                i is
                possible in CS3, although if this is your only 'I-want-it-now', it might not be worth the upgrade :-)

                Fortunately, your Zapf Dingbats example is a regular font, so you can copy the dingbats and paste them right into your script -- it'll look like 'a's being replaced by '$'s or something like that, but it will work.
                • 5. Re: [cs2][JS] Search/replace by glyphID
                  Level 1
                  Hi,

                  Thanx for the response...

                  I'm trying to write some code to change some old fonts to new open type fonts and changing some characters from from one thing to another...

                  Because the fonts only contain special characters like arrows for example, some characters are on a different location...

                  The problem is that I can't locate some special signs on the keyboard ... However, I can see them in the glyphs menu...

                  Tim
                  • 6. Re: [cs2][JS] Search/replace by glyphID
                    [Jongware] Most Valuable Participant
                    I hope you don't ever expect a keyboard big enough for all characters in your font! A typical, usable text font contains about 220 characters; Minion Pro boasts (.. checking .. please wait) 1397 characters, Arial Unicode MS has 50,377 different ones, and Unicode reference font Code2000 weighs in at a hefty 61,684 characters.<br /><br />The thing you should primarily be interested in is the characters' Unicode value. My modus operandi for replacing <br />i mojibake <br />characters by good ones is this. Select the 'bad' character and copy it. Paste into Find; if it has a unique font applied, fill that in in the Find Format box (so you won't accidentaly replace 'good' characters). Now call up the Glyph panel and find the 'good' character. Hover your mouse over it until the popup appears, showing its Unicode. Remember it :-) (you can't copy "out" of the Glyph panel). Type this number in the Replace field, inbetween <brackets>, like this: <0020> (that's a space). If you filled in a font in the Find format, set the font in the Replace format field to the correct one. Now press "Change all" and you're done, for this character at least.<br /><br />The same approach can be used to enter everything into a script. You can either copy-and-paste the Search character into your script, or select it and check the Info panel; it should display the Unicode, and you can enter it into the Search field inbetween <brackets>, the same way as you did in the Replace field.<br /><br />In CS2 (and CS), the only limitation is that you <br />i cannot <br />enter a different <br />i glyph <br />in the Replace field if your font offers more than one. These extra glyphs are recognizable in the Glyph panel by the little triangle (press to popup the variants), or because they do not show a Unicode value, just a CID. (FYI, "CID" stands for "Character ID", and is most likely just the <br />i n<br />-th glyph number from the start in the font; so nothing useful.)
                    • 7. Re: [cs2][JS] Search/replace by glyphID
                      Level 1
                      Jongware,

                      Thanx for your great help.... It works like a charme...

                      Tim