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

Applying Metric or Optical Kerning

Engaged ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Hello,

My plugin is able to apply kerning of a specific value to text, but I cannot see how to apply Metric or Optical kerning.

I did find the code below for optical kerning, but it contains a lot of magic numbers and I am unable to find any info about it in the SDK.

ClassID kernmethod = 79875;
InterfacePtr<IAttrReport> attr12(SnpTextAttrHelper::CreateTextAttribute<ITextAttrClassID, ITextAttrClassID::ValueType>(kTextAttrPairKernMethodBoss,kernmethod));
charAttributeBossList->ApplyAttribute(attr12);
SnpTextModelHelper	textCmdHelper;
status = textCmdHelper.ApplyOverrides(textModel, position, length, charAttributeBossList, kCharAttrStrandBoss);

 Does anyone know how to apply Metric or Optical kerning to text ?

Very best regards,

Olivier

TOPICS
How to , SDK

Views

399

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

correct answers 1 Correct answer

Guide , Nov 04, 2021 Nov 04, 2021

Sorry, too much editing too late in the evening. "Metric".

 

You're dealing with two attributes, kTextAttrPairKernBoss and kTextAttrPairKernMethodBoss

 

Attribute kTextAttrPairKernBoss stores the numeric value in its IID_ITEXTATTRREALNUMBER; limits are -2.000000..10.000000 for regular values, otherwise it also takes kAutoKernMagicNumber(100000000.000000)

 

With kAutoKernMagicNumber the other Attribute kTextAttrPairKernMethodBoss as of your original posting appears* to get considered.

* = I have not loo

...

Votes

Translate

Translate
Community Expert ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Hi Olivier,

you should be able to do it very easily using ExtendScript.

That is not the answer you had hoped for, I know, but give that a chance.

 

If you want optical kerning, first apply metrical kerning and as a final step apply optical kerning.

// ExtendScript code
// Given selected text by the user:

app.selection[0].kerningMethod = "$ID/Metrics";
app.selection[0].kerningMethod = "$ID/Optical";

 

Regards,
Uwe Laubender

( ACP )

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
Engaged ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Hi Uwe,

Thank you very much for your post.

Can I call ExtendScript from within the SDK ?

Very best regards,

Olivier

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
Community Expert ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Well, yes.

But don't ask me how…

 

Regards,
Uwe Laubender

( ACP )

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
Guide ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

the ClassID value should be kDefaultPairKerningBoss for Automatic

 

The numeric value is stored in a kTextAttrPairKernBoss / IID_ITEXTATTRREALNUMBER.

A display value of 280 is a number of 0.280 ...

 

Optical uses kKFPairKerningBoss as ClassID and a number of kAutoKernMagicNumber

 

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
Engaged ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Hi Dirk,

Thank you very much for your post.

By "automatic" do you mean "metric" ?

And in that case is the value of IID_ITEXTATTRREALNUMBER irrelevant ?

Very best regards,

Olivier

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
Engaged ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Hello again,

I am almost there.

I am able to specify a specific kerning with:

PMReal UnitsBase1000 = atof(p) / 1000.0;
InterfacePtr<IAttrReport> attrKernValue(SnpTextAttrHelper::CreateTextAttribute<ITextAttrRealNumber, PMReal>(kTextAttrPairKernBoss, UnitsBase1000));
charAttributeBossList->ApplyAttribute(attrKernValue);

I am also able to apply Metric kerning with:

InterfacePtr<IAttrReport> attrMetric(SnpTextAttrHelper::CreateTextAttribute<ITextAttrRealNumber, PMReal>(kTextAttrPairKernBoss, kAutoKernMagicNumber));
charAttributeBossList->ApplyAttribute(attrMetric);

But CreateTextAttribute() returns a null pointer when I try to set the Optical kerning as below:

InterfacePtr<IAttrReport> attrOptical(SnpTextAttrHelper::CreateTextAttribute<ITextAttrRealNumber, PMReal>(kKFPairKerningBoss, kAutoKernMagicNumber));
charAttributeBossList->ApplyAttribute(attrOptical);

I assume that I am just using one wrong parameter for the ClassID, but I cannot figure out which one to use.

Very best regards,

Olivier

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
Guide ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

Sorry, too much editing too late in the evening. "Metric".

 

You're dealing with two attributes, kTextAttrPairKernBoss and kTextAttrPairKernMethodBoss

 

Attribute kTextAttrPairKernBoss stores the numeric value in its IID_ITEXTATTRREALNUMBER; limits are -2.000000..10.000000 for regular values, otherwise it also takes kAutoKernMagicNumber(100000000.000000)

 

With kAutoKernMagicNumber the other Attribute kTextAttrPairKernMethodBoss as of your original posting appears* to get considered.

* = I have not looked at the docs, just digging thru some debug output while I flip the setting.

 

Attribute kTextAttrPairKernMethodBoss stores a ClassID value in its IID_ITEXTATTRCLASSID, the values for "kernmethod" are
- kDefaultPairKerningBoss // Metrics
- kKFPairKerningBoss // Optical

These "kernmethod" values are boss classes for a service provider, when you use them as class parameter in CreateTextAttribute you get your NULL.

 

Actually having a look at kPairKerningService there are more values:

kKFPairKerningBoss(0x13803)
kRomanOnlyPairKerningBoss(0x3E65)
kDefaultPairKerningBoss(0x3E64)
kPairKerningOffBoss(0x221)

 

I don't know how to reach the others via the UI, might be leftover from 20 years ago or CJK specific. So if you cover CJK, happy testing.

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
Engaged ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

LATEST
quote

You're dealing with two attributes, kTextAttrPairKernBoss and kTextAttrPairKernMethodBoss

 

This was my problem; I wasn't setting both systematically.

It now works like a charm.

Thank you very much for all your help.

Olivier

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