Copy link to clipboard
Copied
Hi, using an Opentype Font containing the option for Superscript/Subscripts, the default size in InDesign 3 for both is sized at 58.3% and positioned at 33.3%.
My question is are the Superscripts/Subscripts sized and positioned in related to the prior text by the Typeface Designer as part of the Letterspacing... or is this done by InDesign? I would want to keep things as they are if done by the Designer, but more inclined to play around with them if the size and position is auto-generated by InDesign. The Font is a high quality common Opentype Font by a reputable foundry. Any help on this matter would be gratefully recieved, thank you!
Great question.
Here's my understanding:
~Barb
Copy link to clipboard
Copied
the default size in InDesign 3
InDesign 3 was released in 2007. Are you sure you're on such an old version of InDesign?
My question is are the Superscripts/Subscripts sized and positioned in related to the prior text by the Typeface Designer as part of the Letterspacing... or is this done by InDesign?
It's done by InDesign's Preference settings for Advanced Type (see screen capture below). Although some OpenType fonts do have some smaller designed letters and numbers for superscripts and subscripts, it's not a complete set so these are usually determined and set by InDesign's typesetting controls and not taken from the fonts themselves.
I don't believe there's anything from the font's metrics or other internal programming that affects superscripts/subscripts.
Copy link to clipboard
Copied
Technically, InDesign 3 (original CS) was released in 2003.
Copy link to clipboard
Copied
Great question.
Here's my understanding:
~Barb
Copy link to clipboard
Copied
I'm not sure that InDesign 3 had support for OpenType, though. Maybe the OP means InDesign CS3?
Copy link to clipboard
Copied
Alas: although the font designer writes recommended values for superscript and subscript sizes and offsets into the font file (in the OS/2 table, per the official specifications: OS/2 - OS/2 and Windows metrics table specification - Typography | Microsoft Docs ), InDesign ignores these and always uses the values as set in Preferences.
I can think of a fairly trivial script that would retrieve the values for your current font and writes these into the global preferences, but unfortunately that will never work with mixed fonts! InDesign's preferences are global, and the same values would be applied to all fonts.
You would be able to sort of fake it by creating a character style that scales super/subscripts to their designed size, but ... the other important value, the vertical offset, can only be set through a baseline shift. And that would make the character style heavily dependent on the font size - you need a different character style for each size.
Very annoying. A relative, size-based baseline shift would definitely help (and the same goes for that other inconvenient font style setting: underline & strikethrough thickness and offset), but if you'd like to post a Feature Request for this, you might as well go all the way and request a specific "As Designed" checkbox for the values per font.
(Adobe is co-developer from the OpenType font format, but maybe they really don't want to actively support a setting that was invented by Microsoft...)
Copy link to clipboard
Copied
The following script will copy the settings for a selected font into the active document's settings. Do note that the information can only be retrieved for TrueType/OpenType fonts! It may be possible for other font types as well (Type 1 fonts, for example, may have this information in their – separate – AFM file) but I do not know how to retrieve that.
The TTF tables actually define more than you can use in InDesign: separate X and Y sizes (the script only uses the Y size), and both X and Y offsets (again, only Y is used). Oh - and you can change the values in the boxes before pressing OK.
Full script is below, a compressed zip is on http://www.jongware.com/binaries/subsupersize.zip
//DESCRIPTION:Find Superscript/subscript sizes
// A Jongware Script 10-Jun-2018
font = app.textDefaults.appliedFont;
if (app.documents.length)
font = app.activeDocument.textDefaults.appliedFont;
// Any text selection?
if (app.selection.length && app.selection[0].hasOwnProperty("parentStory"))
font = app.selection[0].parentStory.insertionPoints[0].appliedFont;
if (app.selection.length && app.selection[0].hasOwnProperty("baseline"))
font = app.selection[0].insertionPoints[0].appliedFont;
// is it an OpenType type?
switch (font.fontType)
{
case FontTypes.TRUETYPE:
case FontTypes.OPENTYPE_CFF:
case FontTypes.OPENTYPE_CID:
case FontTypes.OPENTYPE_TT:
subsuper = findSubSuper (font.location);
break;
default:
alert ('Unknown font type; unable to retrieve data for font "'+font.name+'"');
exit();
}
var aDialog = app.dialogs.add({name:"Super/Sub: "+font.name.replace(/\s+/g,' '), canCancel:true});
with (aDialog)
{
with(dialogColumns.add())
{
staticTexts.add({staticLabel:"Superscript"});
with (borderPanels.add())
{
with (dialogColumns.add())
{
with (dialogRows.add())
{
staticTexts.add({staticLabel:"X Size"});
staticTexts.add({staticLabel:String(subsuper.SuperscriptXSize)});
}
with (dialogRows.add())
{
staticTexts.add({staticLabel:"Y Size"});
spysiz = percentEditboxes.add({editValue:subsuper.SuperscriptYSize,minimumValue:-200,maximumValue:200});
}
with (dialogRows.add())
{
staticTexts.add({staticLabel:"Y Offset"});
spyoff = percentEditboxes.add({editValue:subsuper.SuperscriptYOffset,minimumValue:-200,maximumValue:200});
}
}
}
staticTexts.add({staticLabel:"Subscript"});
with (borderPanels.add())
{
with (dialogColumns.add())
{
with (dialogRows.add())
{
staticTexts.add({staticLabel:"X Size"});
staticTexts.add({staticLabel:String(subsuper.SubscriptXSize)});
}
with (dialogRows.add())
{
staticTexts.add({staticLabel:"Y Size"});
sbysiz = percentEditboxes.add({editValue:subsuper.SubscriptYSize,minimumValue:-200,maximumValue:200});
}
with (dialogRows.add())
{
staticTexts.add({staticLabel:"Y Offset"});
sbyoff = percentEditboxes.add({editValue:subsuper.SubscriptYOffset,minimumValue:-200,maximumValue:200});
}
}
}
}
}
if (aDialog.show() == true)
{
app.activeDocument.textPreferences.properties =
{superscriptPosition:spyoff.editValue,
superscriptSize:spysiz.editValue,
subscriptPosition:sbyoff.editValue,
subscriptSize:sbysiz.editValue};
}
function findSubSuper (path)
{
var fontFile, subsuper = {};
fontFile = File (path);
if (!fontFile.exists)
{
alert ('the file "'+path+'" does not exist');
exit();
}
if (!fontFile.open('r'))
{
alert ('the file "'+path+'" could not be opened');
exit();
}
fontFile.encoding = "binary";
hdr = getUlong(fontFile);
if (hdr == 0x74746366) // Truetype collection
{
hdr = getUlong(fontFile);
if (i != 0x00010000 && i != 0x00020000)
{
fontFile.close();
alert ("Not a font type I can use...");
exit(0);
}
} else
{
if (hdr != 65536 // Microsoft Truetype
&& hdr != 1330926671) // Adobe OTF ‘OTTO’
{
fontFile.close();
alert ("Not a font type I can use...");
exit(0);
}
}
numTable = getUshort (fontFile);
fontFile.seek (12);
var os2 = null, head = null;
for (var t=0; t<numTable; t++)
{
tableEntry = fontFile.read(16);
if (tableEntry.substr(0,4) == 'OS/2')
os2 = tableEntry;
if (tableEntry.substr(0,4) == 'head')
head = tableEntry;
}
if (!head || !os2)
{
fontFile.close();
alert ("No proper table entries found--yuck");
exit(0);
}
// find head for em units
offset = (((((head.charCodeAt(8 ) << 8 ) +
head.charCodeAt(9)) << 8 ) +
head.charCodeAt(10)) << 8 ) +
head.charCodeAt(11);
fontFile.seek (offset+9*2);
unitsPerEm = getUshort (fontFile)/100;
// find OS/2 for settings
offset = (((((os2.charCodeAt(8 ) << 8 ) +
os2.charCodeAt(9)) << 8 ) +
os2.charCodeAt(10)) << 8 ) +
os2.charCodeAt(11);
/* the first 5 uint16 entries are not interesting */
fontFile.seek (offset+5*2);
subsuper.SubscriptXSize = getUshort (fontFile)/unitsPerEm;
subsuper.SubscriptYSize = getUshort (fontFile)/unitsPerEm;
subsuper.SubscriptXOffset = getUshort (fontFile)/unitsPerEm;
subsuper.SubscriptYOffset = getUshort (fontFile)/unitsPerEm;
subsuper.SuperscriptXSize = getUshort (fontFile)/unitsPerEm;
subsuper.SuperscriptYSize = getUshort (fontFile)/unitsPerEm;
subsuper.SuperscriptXOffset = getUshort (fontFile)/unitsPerEm;
subsuper.SuperscriptYOffset = getUshort (fontFile)/unitsPerEm;
fontFile.close();
return subsuper;
function getUshort (aFile)
{
var result = aFile.read(2);
return (result.charCodeAt(0)<<8) + result.charCodeAt(1);
}
function getUlong (aFile)
{
var result = aFile.read(4);
return ((((result.charCodeAt(0)<<8 ) + result.charCodeAt(1))<<8 ) + result.charCodeAt(2)<<8 ) + result.charCodeAt(3);
}
}
Copy link to clipboard
Copied
Works like a charm and very useful! Fortunately the two typefaces i require are from the same family and both Superscript values are the same when using the script, (so will be fine for Global preferences). Much appreciated, thanks again.