Jump to content

Changing case of special characters?


Stack

Recommended Posts

Hi all,

 

I'm setting up a job that requires author names to be small caps. I created a rule which takes care of that, however, one of the letters is accented. Even though the rule changes everything to small caps, what should be "É" is returning "é". I set up the original file in InDesign, and I've verified that the font (Berkeley Bold) does include special characters in both cases.

 

Here's the rule in JS to convert to small caps:

Var1="Author";

CaseSelection="smallcaps";

 

 

 

if(CaseSelection == "allcaps")

return ToUpper(Field(Var1));

 

if(CaseSelection == "smallcaps")

return "<smallcap>" + Field(Var1) + "</smallcap>";

 

if(CaseSelection == "propercase")

return ToTitleCase(Field(Var1));

 

if(CaseSelection == "lowercase")

return ToLower(Field(Var1));

 

Is it possible that additional coding can be added to this rule?

 

Thanks!

Link to comment
Share on other sites

Sorry, the <smallcap> tag doesn't properly handle extended ASCII characters outside the range of 'a' to 'z'. This is a known issue, case FP-10848.

 

The workaround is to let JavaScript emulate the smallcaps mode, like so:

function SmallCaps(text, ratio)
{
 var factor = Int(ratio) || 80;
 var result = "";
 for (var i in text)
 {
   var c = text[i][i];[/i]
   if (text.charCodeAt(i) == 32)
     result += "&[size=3]#[/size]32;";
   else if (c.toUpperCase() == c)
     result += NormalizeEntities(c);
   else
   {
     result += "<span><magnify type=text factor=" + factor + ">" +
       NormalizeEntities(c.toUpperCase()) + "</magnify></span>";
   }
 }
 return result;
}

You can add this function in your JavaScript Globals, or directly in your rule, and then call it like so:

return SmallCaps(Field(Var1));

Note that you'll need to check "Treat returned strings as tagged text," and also possibly call the NormalizeEntities function for your other returned values.

Link to comment
Share on other sites

  • 3 years later...

Hi Dan,

I have been having issues with the smallcap tag as well. Really a combination of issues, but it seems the issues I am experiencing are due to the bugs in the smallcap function. I have implemented your technique here and it works great except for one major issue. Using this smallcaps function seems to disable control of line leading. Is there anything I can do to alleviate this issue?

 

I am having trouble getting the combination of smallcap features with correct line leading solved. I was using the <smallcap> tag and it worked ok, however I was also using <br /> characters as well and I was noticing that there were different line leadings between the lines and I could not tell why other than attributing it to the smallcap bugs. Any light you can shed on the subject would be great.

 

Thanks!

Indexx Prep

FP v 7.2p1k, Intel Mac OS X 10.6, Adobe CS 5

Link to comment
Share on other sites

Have you messed around with the legacy line leading checkbox in text frames's paragraph/global settings dialog? I have found that disabling/enabling this option has often "fixed" the issues I have when using custom leading.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...