Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How-To Display Proper Unicode text via ExtendScript

Explorer ,
Oct 20, 2024 Oct 20, 2024

Is there a way to properly display UNICODE text when adding it via script. I was able to get Illustrator to display UNICODE by enabling "Show Indic Options" under Type Preferences but it still fails via script.

 

Type Preferencesexpand imagetextFrames.add() UNICODE exampleexpand image

TOPICS
Scripting
624
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Oct 21, 2024 Oct 21, 2024

That’s a font issue, not a Unicode issue. The empty box symbol means the current font doesn’t contain the required glyph.

 

Set the text in a font that contains the “⅛” glyph (e.g. try Arial) and it appears correctly.

Translate
Adobe
Enthusiast ,
Oct 20, 2024 Oct 20, 2024

Would it help to use the Unicode character for insertion?

var tf = app.activeDocument.textFrames.add();
tf.contents = '\u215B" Diameter';
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 21, 2024 Oct 21, 2024

That’s a font issue, not a Unicode issue. The empty box symbol means the current font doesn’t contain the required glyph.

 

Set the text in a font that contains the “⅛” glyph (e.g. try Arial) and it appears correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 21, 2024 Oct 21, 2024

I used this script to cycle thru my fonts and obtain proper names for scripting and as you said Arial is one the fonts that contain all necessary glyphs to display the Unicode fractions. Thanks for the help.

Screenshot 2024-10-21 at 9.32.38 AM.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 20, 2024 Nov 20, 2024
LATEST

Great script! For advanced text manipulation or working with hidden text, you can also explore Text Invisible—a handy tool for such tasks. Let me know if you'd like details!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 21, 2024 Oct 21, 2024

Salut!

Petit script en réponse...

// JavaScript Document
// diametre.js
var police1 = "SymbolMT";

var doc = activeDocument;

 var Phi = String.fromCharCode(8709); // Phi = "\u2205";

      alert(Phi+" 1254");

      police1 = getFont(police1);
      var pointText = doc.textFrames.pointText([20,-20]);
          pointText.contents = Phi+" 1254";
          if (police1 != undefined) pointText.textRanges[0].textFont = police1;
// -------
function getFont(nomPolice) {
     try {
       var police = textFonts.getByName(nomPolice);
     }   catch (e) {
        alert( "The specified font doesn’t exist" );
        return undefined;
        }
     return police;
}
// -------

si ensuite vous modifez la police, dans de nombreux cas le symbole ∅ subsiste.

René

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines