Scribus > Scripts and Plugins

Request information of the "setFontFeatures" function.

<< < (2/2)

get/setFontFeatures are no longer part of newer Scribus versions (at least not in 1.5.x). Don't know though in which version they disappeared.

hi michaelu

it seems to be there:

but it might not be documented...


As indicated above - this is available in 1.5.x but not fully documented - the API method is there but it's not entirely clear how to use it.

I had the same question - and here's the scriptlet that I used to work out what's going on.
Simply create a new scribus document - open Scripter console - and run a script to interrogate 'features':

--- Code: ---# create a text frame - my dimensions are in mm
textFrame = createText(20, 20, 180, 60 )
setText("set me to smallcaps", textFrame)
# safety first - deselect everything
selectText(0, 0, textFrame)
# this is blank - there are no features set on the frame
print("current features: " + getFontFeatures(textFrame))
# get the position of the text you want to change and select it
smallcapsPosition = getAllText(textFrame).find("me")
selectText(smallcapsPosition, 2 ,textFrame)
print("selected text: " + getText(textFrame))
# this sets features of the frame or currently selected text .. "+smcp" is smallcaps
setFontFeatures("+smcp", textFrame)
# set font features deselects the text! Reselect it so we can see what features were set
selectText(smallcapsPosition, 2,textFrame)
print("features on selection: " + getFontFeatures(textFrame))

--- End code ---

The obvious question is... how do you know what values to use (+smcp)? :)

Simply select text frame manually and set the font features you want in the UI - and have the script spit the feature names out and you get something like this:

--- Quote ---current features: +dlig,+unic,+onum,+pnum,+frac,+ss01,+ss02,+ss03
--- End quote ---

Discovered font feature flags:
Font FeatureFeature settingNotesCommon Ligatures-cligenabled by default, so negative switchDiscretionary Ligatures+dligdepends on the fontDefault Capitals(-smcp, -c2sc)default setting, no explicit flags, assume you have to remove any others if setSmall Capitals+smcpdepends on the fontSmall Capitals from Capitals+c2scdepends on the fontUnicase+unic??Default Numerals(-lnum, -onum)default setting is no flags, assume you have to remove any others if setLining+lnumdepends on the fontOld Style+onumdepends the fontDefault Numeral Width(-pnum, -tnum)default setting is no flags, assume you have to remove any others if setProportional+pnumdepends on the fontTabular+tnumdepends on the fontNo Fractions(-frac)default setting, no flags, do not use fraction representations from the fontDiagonal Fractions+fracuse diagonal fraction representations from the fontStylistic Sets+ss01 .. numbered sets ..


[0] Message Index

[*] Previous page

Go to full version