fix(text-base): letter spacing for textfield (#8627)

closes https://github.com/NativeScript/NativeScript/pull/8626
closes https://github.com/NativeScript/NativeScript/issues/4892
This commit is contained in:
Nathan Walker
2020-06-09 22:44:16 -07:00
committed by GitHub
parent ae06202af5
commit eb4c61fc41
3 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,8 @@
<TextField text="left" style="text-align: left" /> <TextField text="left" style="text-align: left" />
<TextField text="center" style="text-align: center" /> <TextField text="center" style="text-align: center" />
<TextField text="right" style="text-align: right" /> <TextField text="right" style="text-align: right" />
<!-- Text must not be predefined in the letter spacing test -->
<TextField style="letter-spacing: 0.9em;" />
<WrapLayout> <WrapLayout>
<TextField text="normal" /> <TextField text="normal" />

View File

@ -35,6 +35,7 @@
"gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4", "gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4",
"readme": "NativeScript Application", "readme": "NativeScript Application",
"scripts": { "scripts": {
"clean": "npx rimraf hooks node_modules platforms package-lock.json",
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json", "e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
"e2e-debug": "./node_modules/.bin/ns-dev-appium --startSession", "e2e-debug": "./node_modules/.bin/ns-dev-appium --startSession",
"e2e-watch": "tsc -p e2e --watch", "e2e-watch": "tsc -p e2e --watch",

View File

@ -288,6 +288,9 @@ export class TextBase extends TextBaseCommon {
if (style.letterSpacing !== 0 && this.nativeTextViewProtected.font) { if (style.letterSpacing !== 0 && this.nativeTextViewProtected.font) {
const kern = style.letterSpacing * this.nativeTextViewProtected.font.pointSize; const kern = style.letterSpacing * this.nativeTextViewProtected.font.pointSize;
dict.set(NSKernAttributeName, kern); dict.set(NSKernAttributeName, kern);
if (this.nativeTextViewProtected instanceof UITextField) {
this.nativeTextViewProtected.defaultTextAttributes.setValueForKey(kern, NSKernAttributeName);
}
} }
if (style.color) { if (style.color) {