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.

Edited by Dan Korn
typo
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...