diff --git a/assets/resources/application/ar.xml b/assets/resources/application/ar.xml
index 01d697227..c201d9c77 100644
--- a/assets/resources/application/ar.xml
+++ b/assets/resources/application/ar.xml
@@ -988,5 +988,6 @@
+
diff --git a/assets/resources/application/be.xml b/assets/resources/application/be.xml
index 681b904a2..45fbd951a 100644
--- a/assets/resources/application/be.xml
+++ b/assets/resources/application/be.xml
@@ -996,5 +996,6 @@
+
diff --git a/assets/resources/application/bg.xml b/assets/resources/application/bg.xml
index a92c704ea..cfffe83ae 100644
--- a/assets/resources/application/bg.xml
+++ b/assets/resources/application/bg.xml
@@ -995,5 +995,6 @@
+
diff --git a/assets/resources/application/ca.xml b/assets/resources/application/ca.xml
index ef7cbc896..74978e5fd 100644
--- a/assets/resources/application/ca.xml
+++ b/assets/resources/application/ca.xml
@@ -1016,5 +1016,6 @@
+
diff --git a/assets/resources/application/cs.xml b/assets/resources/application/cs.xml
index 8c321de43..d4a1381a9 100644
--- a/assets/resources/application/cs.xml
+++ b/assets/resources/application/cs.xml
@@ -999,5 +999,6 @@
+
diff --git a/assets/resources/application/da.xml b/assets/resources/application/da.xml
index 436197a3b..d4b3a5485 100644
--- a/assets/resources/application/da.xml
+++ b/assets/resources/application/da.xml
@@ -1010,5 +1010,6 @@
+
diff --git a/assets/resources/application/de.xml b/assets/resources/application/de.xml
index 9bc41a608..6aa0ecaf3 100644
--- a/assets/resources/application/de.xml
+++ b/assets/resources/application/de.xml
@@ -995,5 +995,6 @@
+
diff --git a/assets/resources/application/el.xml b/assets/resources/application/el.xml
index f5e460dcb..751216b72 100644
--- a/assets/resources/application/el.xml
+++ b/assets/resources/application/el.xml
@@ -988,5 +988,6 @@
+
diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml
index d0bdb3a44..dcf9db35a 100644
--- a/assets/resources/application/en.xml
+++ b/assets/resources/application/en.xml
@@ -990,5 +990,6 @@
+
diff --git a/assets/resources/application/es.xml b/assets/resources/application/es.xml
index 24a7131eb..93636c813 100644
--- a/assets/resources/application/es.xml
+++ b/assets/resources/application/es.xml
@@ -995,5 +995,6 @@
+
diff --git a/assets/resources/application/eu.xml b/assets/resources/application/eu.xml
index 4b2243b5f..6f9bcc193 100644
--- a/assets/resources/application/eu.xml
+++ b/assets/resources/application/eu.xml
@@ -1016,5 +1016,6 @@
+
diff --git a/assets/resources/application/fa.xml b/assets/resources/application/fa.xml
index f1541304b..334858aef 100644
--- a/assets/resources/application/fa.xml
+++ b/assets/resources/application/fa.xml
@@ -990,5 +990,6 @@
+
diff --git a/assets/resources/application/fr.xml b/assets/resources/application/fr.xml
index d2d07310a..d01b8d487 100644
--- a/assets/resources/application/fr.xml
+++ b/assets/resources/application/fr.xml
@@ -983,5 +983,6 @@
+
diff --git a/assets/resources/application/gl.xml b/assets/resources/application/gl.xml
index d6d7a3ddb..6e6d811f0 100644
--- a/assets/resources/application/gl.xml
+++ b/assets/resources/application/gl.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/hu.xml b/assets/resources/application/hu.xml
index 701106b25..5eb0eed37 100644
--- a/assets/resources/application/hu.xml
+++ b/assets/resources/application/hu.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/hy.xml b/assets/resources/application/hy.xml
index 361c0e93d..53d7682d1 100644
--- a/assets/resources/application/hy.xml
+++ b/assets/resources/application/hy.xml
@@ -995,5 +995,6 @@
+
diff --git a/assets/resources/application/it.xml b/assets/resources/application/it.xml
index ef24e77a4..efc3d45eb 100644
--- a/assets/resources/application/it.xml
+++ b/assets/resources/application/it.xml
@@ -981,5 +981,6 @@
+
diff --git a/assets/resources/application/ka.xml b/assets/resources/application/ka.xml
index bd88ee225..c94cfc9d3 100644
--- a/assets/resources/application/ka.xml
+++ b/assets/resources/application/ka.xml
@@ -995,5 +995,6 @@
+
diff --git a/assets/resources/application/nb.xml b/assets/resources/application/nb.xml
index 2e2a0fdd6..1c925a7bc 100644
--- a/assets/resources/application/nb.xml
+++ b/assets/resources/application/nb.xml
@@ -990,5 +990,6 @@
+
diff --git a/assets/resources/application/nl.xml b/assets/resources/application/nl.xml
index 0c747fe38..e36a15360 100644
--- a/assets/resources/application/nl.xml
+++ b/assets/resources/application/nl.xml
@@ -990,5 +990,6 @@
+
diff --git a/assets/resources/application/pl.xml b/assets/resources/application/pl.xml
index d77dc3641..490a87166 100644
--- a/assets/resources/application/pl.xml
+++ b/assets/resources/application/pl.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/pt.xml b/assets/resources/application/pt.xml
index 354bb84da..9a1572e86 100644
--- a/assets/resources/application/pt.xml
+++ b/assets/resources/application/pt.xml
@@ -992,5 +992,6 @@
+
diff --git a/assets/resources/application/ro.xml b/assets/resources/application/ro.xml
index b8d4da438..1d50c1eb0 100644
--- a/assets/resources/application/ro.xml
+++ b/assets/resources/application/ro.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/ru.xml b/assets/resources/application/ru.xml
index e0daf410e..ac4e5a30e 100644
--- a/assets/resources/application/ru.xml
+++ b/assets/resources/application/ru.xml
@@ -995,5 +995,6 @@
+
diff --git a/assets/resources/application/sr.xml b/assets/resources/application/sr.xml
index c9aa47123..4bab8fa07 100644
--- a/assets/resources/application/sr.xml
+++ b/assets/resources/application/sr.xml
@@ -990,5 +990,6 @@
+
diff --git a/assets/resources/application/th.xml b/assets/resources/application/th.xml
index be489a667..6e407de86 100644
--- a/assets/resources/application/th.xml
+++ b/assets/resources/application/th.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/tr.xml b/assets/resources/application/tr.xml
index 51cf56279..4d51401ca 100644
--- a/assets/resources/application/tr.xml
+++ b/assets/resources/application/tr.xml
@@ -990,5 +990,6 @@
+
diff --git a/assets/resources/application/uk.xml b/assets/resources/application/uk.xml
index 56481ca8b..6ca74efb9 100644
--- a/assets/resources/application/uk.xml
+++ b/assets/resources/application/uk.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/vi.xml b/assets/resources/application/vi.xml
index 38dacb71b..d29ad41c3 100644
--- a/assets/resources/application/vi.xml
+++ b/assets/resources/application/vi.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/zh.xml b/assets/resources/application/zh.xml
index 473a16dd7..97f3dd578 100644
--- a/assets/resources/application/zh.xml
+++ b/assets/resources/application/zh.xml
@@ -980,5 +980,6 @@
+
diff --git a/assets/resources/application/zh_TW.xml b/assets/resources/application/zh_TW.xml
index 856556192..9b8ec3b9a 100644
--- a/assets/resources/application/zh_TW.xml
+++ b/assets/resources/application/zh_TW.xml
@@ -980,5 +980,6 @@
+
diff --git a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java
index 41a179c6f..a57ab22a2 100644
--- a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java
+++ b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java
@@ -254,24 +254,6 @@ public class PreferenceActivity extends ZLPreferenceActivity {
textScreen.addOption(baseStyle.AutoHyphenationOption, "autoHyphenations");
final Screen moreStylesScreen = textScreen.createPreferenceScreen("more");
-
- /*
- final ZLIntegerOption spacePercentOption = decoration.LineSpacePercentOption;
- final int[] spacingValues = new int[17];
- final String[] spacingKeys = new String[17];
- spacingValues[0] = -1;
- spacingKeys[0] = "unchanged";
- for (int j = 1; j < spacingValues.length; ++j) {
- final int val = 4 + j;
- spacingValues[j] = 10 * val;
- spacingKeys[j] = (char)(val / 10 + '0') + decimalSeparator + (char)(val % 10 + '0');
- }
- formatScreen.addPreference(new ZLIntegerChoicePreference(
- this, textScreen.Resource, "lineSpacing",
- spacePercentOption, spacingValues, spacingKeys
- ));
- */
-
for (ZLTextNGStyleDescription description : collection.getDescriptionList()) {
final Screen ngScreen = moreStylesScreen.createPreferenceScreen(description.Name);
ngScreen.addPreference(new FontPreference(
@@ -308,6 +290,11 @@ public class PreferenceActivity extends ZLPreferenceActivity {
description.AlignmentOption,
new String[] { "inherit", "left", "right", "center", "justify" }
));
+ ngScreen.addPreference(new StringPreference(
+ this, description.LineHeightOption,
+ StringPreference.Constraint.PERCENT,
+ textScreen.Resource, "lineSpacing"
+ ));
ngScreen.addPreference(new StringPreference(
this, description.MarginTopOption,
StringPreference.Constraint.LENGTH,
diff --git a/src/org/geometerplus/android/fbreader/preferences/StringPreference.java b/src/org/geometerplus/android/fbreader/preferences/StringPreference.java
index 54bc8b112..8a0c1ddcc 100644
--- a/src/org/geometerplus/android/fbreader/preferences/StringPreference.java
+++ b/src/org/geometerplus/android/fbreader/preferences/StringPreference.java
@@ -37,13 +37,17 @@ import org.geometerplus.zlibrary.ui.android.R;
public class StringPreference extends DialogPreference {
public static class Constraint {
public static final Constraint LENGTH = new Constraint(
- "(-{0,1}([0-9]*\\.){0,1}[0-9]+(%|em|ex|px|pt)|)",
+ "-{0,1}([0-9]*\\.){0,1}[0-9]+(%|em|ex|px|pt)|",
"length"
);
public static final Constraint POSITIVE_LENGTH = new Constraint(
- "(([0-9]*\\.){0,1}[0-9]+(%|em|ex|px|pt)|)",
+ "([0-9]*\\.){0,1}[0-9]+(%|em|ex|px|pt)|",
"positiveLength"
);
+ public static final Constraint PERCENT = new Constraint(
+ "([1-9][0-9]{1,2}%)|",
+ "percent"
+ );
private final Pattern myPattern;
public final String HintKey;
diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextDecoratedStyle.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextDecoratedStyle.java
index 32a6d7969..2dd7652d9 100644
--- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextDecoratedStyle.java
+++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextDecoratedStyle.java
@@ -35,6 +35,7 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
private boolean myIsBold;
private boolean myIsUnderline;
private boolean myIsStrikeThrough;
+ private int myLineSpacePercent;
private boolean myIsNotCached = true;
@@ -60,6 +61,7 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
myIsBold = isBoldInternal();
myIsUnderline = isUnderlineInternal();
myIsStrikeThrough = isStrikeThroughInternal();
+ myLineSpacePercent = getLineSpacePercentInternal();
myIsNotCached = false;
}
@@ -182,4 +184,13 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
return myFirstLineIndent;
}
protected abstract int getFirstLineIndentInternal(ZLTextMetrics metrics, int fontSize);
+
+ @Override
+ public final int getLineSpacePercent() {
+ if (myIsNotCached) {
+ initCache();
+ }
+ return myLineSpacePercent;
+ }
+ protected abstract int getLineSpacePercentInternal();
}
diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java
index f39db2953..ce238e683 100644
--- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java
+++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java
@@ -158,7 +158,7 @@ public class ZLTextExplicitlyDecoratedStyle extends ZLTextDecoratedStyle impleme
return myEntry.getLength(LENGTH_RIGHT_INDENT, metrics, fontSize);
}
@Override
- public int getFirstLineIndentInternal(ZLTextMetrics metrics, int fontSize) {
+ protected int getFirstLineIndentInternal(ZLTextMetrics metrics, int fontSize) {
if (myEntry instanceof ZLTextCSSStyleEntry && !BaseStyle.UseCSSMarginsOption.getValue()) {
return Parent.getFirstLineIndent(metrics);
}
@@ -168,7 +168,8 @@ public class ZLTextExplicitlyDecoratedStyle extends ZLTextDecoratedStyle impleme
}
return myEntry.getLength(LENGTH_FIRST_LINE_INDENT, metrics, fontSize);
}
- public int getLineSpacePercent() {
+ @Override
+ protected int getLineSpacePercentInternal() {
// TODO: implement
return Parent.getLineSpacePercent();
}
diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyle.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyle.java
index 241a3a6eb..9d614510d 100644
--- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyle.java
+++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyle.java
@@ -105,20 +105,24 @@ public class ZLTextNGStyle extends ZLTextDecoratedStyle {
}
@Override
- public int getLeftIndentInternal(ZLTextMetrics metrics, int fontSize) {
+ protected int getLeftIndentInternal(ZLTextMetrics metrics, int fontSize) {
return myDescription.getLeftIndent(metrics, Parent.getLeftIndent(metrics), fontSize);
}
@Override
- public int getRightIndentInternal(ZLTextMetrics metrics, int fontSize) {
+ protected int getRightIndentInternal(ZLTextMetrics metrics, int fontSize) {
return myDescription.getRightIndent(metrics, Parent.getRightIndent(metrics), fontSize);
}
@Override
- public int getFirstLineIndentInternal(ZLTextMetrics metrics, int fontSize) {
+ protected int getFirstLineIndentInternal(ZLTextMetrics metrics, int fontSize) {
return myDescription.getFirstLineIndent(metrics, Parent.getFirstLineIndent(metrics), fontSize);
}
- public int getLineSpacePercent() {
- // TODO: implement
- return Parent.getLineSpacePercent();
+ @Override
+ protected int getLineSpacePercentInternal() {
+ final String lineHeight = myDescription.LineHeightOption.getValue();
+ if (!lineHeight.matches("[1-9][0-9]*%")) {
+ return Parent.getLineSpacePercent();
+ }
+ return Integer.valueOf(lineHeight.substring(0, lineHeight.length() - 1));
}
@Override
protected int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize) {
diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyleDescription.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyleDescription.java
index 244582769..56a3f60d4 100644
--- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyleDescription.java
+++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextNGStyleDescription.java
@@ -42,6 +42,7 @@ public class ZLTextNGStyleDescription {
public final ZLStringOption TextIndentOption;
public final ZLStringOption AlignmentOption;
public final ZLStringOption VerticalAlignOption;
+ public final ZLStringOption LineHeightOption;
private static ZLStringOption createOption(String selector, String name, Map valueMap) {
return new ZLStringOption("Style", selector + "::" + name, valueMap.get(name));
@@ -63,6 +64,7 @@ public class ZLTextNGStyleDescription {
TextIndentOption = createOption(selector, "text-indent", valueMap);
AlignmentOption = createOption(selector, "text-align", valueMap);
VerticalAlignOption = createOption(selector, "vertical-align", valueMap);
+ LineHeightOption = createOption(selector, "line-height", valueMap);
}
int getFontSize(ZLTextMetrics metrics, int baseFontSize) {