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

Javascript for Illustrator new feature: Cap Height

New Here ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

Hello,

I'm thinking about making a script that would assign the Cap Height to certain values in millimeters. I understand that there is a new feature to "Set font height preference". But is it possible?

I'm sorry if it's pretty vague, but I'm thinking of creating a dropdown list---say if I choose option "A", then the cap height will be sized to 2mm. If "B", then 3mm, and so on. This will be the purpose of the script.

 

Thank you and I would appreciate your feedback.

 

TOPICS
Scripting , Tools , Type

Views

183

Translate

Translate

Report

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
Adobe
Guide ,
Dec 19, 2020 Dec 19, 2020

Copy link to clipboard

Copied

LATEST

Not what you asked for but...

 

var frames = app.activeDocument.textFrames;
var window1 = new Window("dialog", "Cap height");
var group1 = window1.add("group");
var button1 = group1.add("button", undefined, "↑");
var button2 = group1.add("button", undefined, "↓");
var scale = function (addend) {
  for (var i = 0; i < frames.length; i++) {
    var chars = frames[i].textRange.characters;
    for (var j = 0; j < chars.length; j++) {
      if (/[A-Z]/.test(chars[j].contents)) {
        chars[j].characterAttributes.verticalScale = chars[j].characterAttributes.verticalScale + addend;
        redraw();
      }
    }
  }
}
button1.onClick = function () {scale(10)}
button2.onClick = function () {scale(-10)}
window1.show ();

 

You could try calculating the addend (a percentage) from millimeters, which in turn you calculate from points, but given my ignorance of typeface anatomy I will not attempt this. 

Votes

Translate

Translate

Report

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