mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
more styles in css; vertical-align property
This commit is contained in:
parent
0bb2314e8c
commit
fb574f159a
14 changed files with 126 additions and 105 deletions
|
@ -180,3 +180,27 @@ dd {
|
||||||
fbreader-name: "Definition Description";
|
fbreader-name: "Definition Description";
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footnote {
|
||||||
|
fbreader-id: 16;
|
||||||
|
fbreader-name: "Footnote";
|
||||||
|
font-size: 0.7em;
|
||||||
|
vertical-align: 0.5em;
|
||||||
|
hyphens: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup {
|
||||||
|
fbreader-id: 20;
|
||||||
|
fbreader-name: "Superscript";
|
||||||
|
font-size: 0.7em;
|
||||||
|
vertical-align: 0.5em;
|
||||||
|
hyphens: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub {
|
||||||
|
fbreader-id: 19;
|
||||||
|
fbreader-name: "Subscript";
|
||||||
|
font-size: 0.7em;
|
||||||
|
vertical-align: -0.5em;
|
||||||
|
hyphens: none;
|
||||||
|
}
|
||||||
|
|
|
@ -9,8 +9,4 @@
|
||||||
<style id="13" name="Author" leftIndent="20" allowHyphenations="false"/>
|
<style id="13" name="Author" leftIndent="20" allowHyphenations="false"/>
|
||||||
<style id="14" name="Date" leftIndent="40" allowHyphenations="false"/>
|
<style id="14" name="Date" leftIndent="40" allowHyphenations="false"/>
|
||||||
<style id="8" name="Verse" leftIndent="20" alignment="left" allowHyphenations="false"/>
|
<style id="8" name="Verse" leftIndent="20" alignment="left" allowHyphenations="false"/>
|
||||||
|
|
||||||
<style id="16" partial="true" name="Footnote" fontSizeDelta="-5" vShift="7" allowHyphenations="false"/>
|
|
||||||
<style id="19" partial="true" name="Subscript" fontSizeDelta="-4" vShift="-4" allowHyphenations="false"/>
|
|
||||||
<style id="20" partial="true" name="Superscript" fontSizeDelta="-4" vShift="10" allowHyphenations="false"/>
|
|
||||||
</DefaultStyles>
|
</DefaultStyles>
|
||||||
|
|
|
@ -296,13 +296,10 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ZLTextStyleDecoration decoration = collection.getDecoration(styles[i]);
|
final ZLTextFullStyleDecoration decoration = collection.getDecoration(styles[i]);
|
||||||
if (decoration == null) {
|
if (decoration == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ZLTextFullStyleDecoration fullDecoration =
|
|
||||||
decoration instanceof ZLTextFullStyleDecoration
|
|
||||||
? (ZLTextFullStyleDecoration)decoration : null;
|
|
||||||
|
|
||||||
final Screen formatScreen = moreStylesScreen.createPreferenceScreen(decoration.getName());
|
final Screen formatScreen = moreStylesScreen.createPreferenceScreen(decoration.getName());
|
||||||
formatScreen.addPreference(new FontPreference(
|
formatScreen.addPreference(new FontPreference(
|
||||||
|
@ -329,53 +326,49 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
this, textScreen.Resource, "strikedThrough",
|
this, textScreen.Resource, "strikedThrough",
|
||||||
decoration.StrikeThroughOption
|
decoration.StrikeThroughOption
|
||||||
));
|
));
|
||||||
if (fullDecoration != null) {
|
final String[] allAlignments = { "unchanged", "left", "right", "center", "justify" };
|
||||||
final String[] allAlignments = { "unchanged", "left", "right", "center", "justify" };
|
formatScreen.addPreference(new ZLChoicePreference(
|
||||||
formatScreen.addPreference(new ZLChoicePreference(
|
this, textScreen.Resource, "alignment",
|
||||||
this, textScreen.Resource, "alignment",
|
decoration.AlignmentOption, allAlignments
|
||||||
fullDecoration.AlignmentOption, allAlignments
|
));
|
||||||
));
|
|
||||||
}
|
|
||||||
formatScreen.addPreference(new ZLBoolean3Preference(
|
formatScreen.addPreference(new ZLBoolean3Preference(
|
||||||
this, textScreen.Resource, "allowHyphenations",
|
this, textScreen.Resource, "allowHyphenations",
|
||||||
decoration.AllowHyphenationsOption
|
decoration.AllowHyphenationsOption
|
||||||
));
|
));
|
||||||
if (fullDecoration != null) {
|
formatScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
formatScreen.addPreference(new ZLIntegerRangePreference(
|
this, textScreen.Resource.getResource("spaceBefore"),
|
||||||
this, textScreen.Resource.getResource("spaceBefore"),
|
decoration.SpaceBeforeOption
|
||||||
fullDecoration.SpaceBeforeOption
|
));
|
||||||
));
|
formatScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
formatScreen.addPreference(new ZLIntegerRangePreference(
|
this, textScreen.Resource.getResource("spaceAfter"),
|
||||||
this, textScreen.Resource.getResource("spaceAfter"),
|
decoration.SpaceAfterOption
|
||||||
fullDecoration.SpaceAfterOption
|
));
|
||||||
));
|
formatScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
formatScreen.addPreference(new ZLIntegerRangePreference(
|
this, textScreen.Resource.getResource("leftIndent"),
|
||||||
this, textScreen.Resource.getResource("leftIndent"),
|
decoration.LeftIndentOption
|
||||||
fullDecoration.LeftIndentOption
|
));
|
||||||
));
|
formatScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
formatScreen.addPreference(new ZLIntegerRangePreference(
|
this, textScreen.Resource.getResource("rightIndent"),
|
||||||
this, textScreen.Resource.getResource("rightIndent"),
|
decoration.RightIndentOption
|
||||||
fullDecoration.RightIndentOption
|
));
|
||||||
));
|
formatScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
formatScreen.addPreference(new ZLIntegerRangePreference(
|
this, textScreen.Resource.getResource("firstLineIndent"),
|
||||||
this, textScreen.Resource.getResource("firstLineIndent"),
|
decoration.FirstLineIndentDeltaOption
|
||||||
fullDecoration.FirstLineIndentDeltaOption
|
));
|
||||||
));
|
final ZLIntegerOption spacePercentOption = decoration.LineSpacePercentOption;
|
||||||
final ZLIntegerOption spacePercentOption = fullDecoration.LineSpacePercentOption;
|
final int[] spacingValues = new int[17];
|
||||||
final int[] spacingValues = new int[17];
|
final String[] spacingKeys = new String[17];
|
||||||
final String[] spacingKeys = new String[17];
|
spacingValues[0] = -1;
|
||||||
spacingValues[0] = -1;
|
spacingKeys[0] = "unchanged";
|
||||||
spacingKeys[0] = "unchanged";
|
for (int j = 1; j < spacingValues.length; ++j) {
|
||||||
for (int j = 1; j < spacingValues.length; ++j) {
|
final int val = 4 + j;
|
||||||
final int val = 4 + j;
|
spacingValues[j] = 10 * val;
|
||||||
spacingValues[j] = 10 * val;
|
spacingKeys[j] = (char)(val / 10 + '0') + decimalSeparator + (char)(val % 10 + '0');
|
||||||
spacingKeys[j] = (char)(val / 10 + '0') + decimalSeparator + (char)(val % 10 + '0');
|
|
||||||
}
|
|
||||||
formatScreen.addPreference(new ZLIntegerChoicePreference(
|
|
||||||
this, textScreen.Resource, "lineSpacing",
|
|
||||||
spacePercentOption, spacingValues, spacingKeys
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
formatScreen.addPreference(new ZLIntegerChoicePreference(
|
||||||
|
this, textScreen.Resource, "lineSpacing",
|
||||||
|
spacePercentOption, spacingValues, spacingKeys
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PreferenceSet footerPreferences = new PreferenceSet.Enabler() {
|
final PreferenceSet footerPreferences = new PreferenceSet.Enabler() {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public abstract class ZLTextStyle {
|
||||||
public abstract int getRightIndent();
|
public abstract int getRightIndent();
|
||||||
public abstract int getFirstLineIndentDelta();
|
public abstract int getFirstLineIndentDelta();
|
||||||
public abstract int getLineSpacePercent();
|
public abstract int getLineSpacePercent();
|
||||||
public abstract int getVerticalShift();
|
public abstract int getVerticalAlign(ZLTextMetrics metrics);
|
||||||
public abstract int getSpaceBefore(ZLTextMetrics metrics);
|
public abstract int getSpaceBefore(ZLTextMetrics metrics);
|
||||||
public abstract int getSpaceAfter(ZLTextMetrics metrics);
|
public abstract int getSpaceAfter(ZLTextMetrics metrics);
|
||||||
public abstract byte getAlignment();
|
public abstract byte getAlignment();
|
||||||
|
|
|
@ -892,7 +892,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
setTextStyle(area.Style);
|
setTextStyle(area.Style);
|
||||||
}
|
}
|
||||||
final int areaX = area.XStart;
|
final int areaX = area.XStart;
|
||||||
final int areaY = area.YEnd - getElementDescent(element) - getTextStyle().getVerticalShift();
|
final int areaY = area.YEnd - getElementDescent(element) - getTextStyle().getVerticalAlign(metrics());
|
||||||
if (element instanceof ZLTextWord) {
|
if (element instanceof ZLTextWord) {
|
||||||
drawWord(
|
drawWord(
|
||||||
areaX, areaY, (ZLTextWord)element, charIndex, -1, false,
|
areaX, areaY, (ZLTextWord)element, charIndex, -1, false,
|
||||||
|
@ -953,7 +953,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
final int len = info.EndCharIndex - start;
|
final int len = info.EndCharIndex - start;
|
||||||
final ZLTextWord word = (ZLTextWord)paragraph.getElement(info.EndElementIndex);
|
final ZLTextWord word = (ZLTextWord)paragraph.getElement(info.EndElementIndex);
|
||||||
drawWord(
|
drawWord(
|
||||||
area.XStart, area.YEnd - context.getDescent() - getTextStyle().getVerticalShift(),
|
area.XStart, area.YEnd - context.getDescent() - getTextStyle().getVerticalAlign(metrics()),
|
||||||
word, start, len, area.AddHyphenationSign,
|
word, start, len, area.AddHyphenationSign,
|
||||||
mySelection.isAreaSelected(area)
|
mySelection.isAreaSelected(area)
|
||||||
? getSelectionForegroundColor() : getTextColor(getTextStyle().Hyperlink)
|
? getSelectionForegroundColor() : getTextColor(getTextStyle().Hyperlink)
|
||||||
|
|
|
@ -68,7 +68,7 @@ abstract class ZLTextViewBase extends ZLView {
|
||||||
final int getWordHeight() {
|
final int getWordHeight() {
|
||||||
if (myWordHeight == -1) {
|
if (myWordHeight == -1) {
|
||||||
final ZLTextStyle textStyle = myTextStyle;
|
final ZLTextStyle textStyle = myTextStyle;
|
||||||
myWordHeight = getContext().getStringHeight() * textStyle.getLineSpacePercent() / 100 + textStyle.getVerticalShift();
|
myWordHeight = getContext().getStringHeight() * textStyle.getLineSpacePercent() / 100 + textStyle.getVerticalAlign(metrics());
|
||||||
}
|
}
|
||||||
return myWordHeight;
|
return myWordHeight;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,11 @@ abstract class ZLTextViewBase extends ZLView {
|
||||||
final ZLTextNGStyleDescription description =
|
final ZLTextNGStyleDescription description =
|
||||||
getTextStyleCollection().getDescription(control.Kind);
|
getTextStyleCollection().getDescription(control.Kind);
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
setTextStyle(new ZLTextNGStyle(myTextStyle, description));
|
if (control instanceof ZLTextHyperlinkControlElement) {
|
||||||
|
setTextStyle(new ZLTextNGStyle(myTextStyle, description, ((ZLTextHyperlinkControlElement)control).Hyperlink));
|
||||||
|
} else {
|
||||||
|
setTextStyle(new ZLTextNGStyle(myTextStyle, description, null));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final ZLTextStyleDecoration decoration =
|
final ZLTextStyleDecoration decoration =
|
||||||
getTextStyleCollection().getDecoration(control.Kind);
|
getTextStyleCollection().getDecoration(control.Kind);
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class ZLTextBaseStyle extends ZLTextStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVerticalShift() {
|
public int getVerticalAlign(ZLTextMetrics metrics) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
|
||||||
private boolean myIsBold;
|
private boolean myIsBold;
|
||||||
private boolean myIsUnderline;
|
private boolean myIsUnderline;
|
||||||
private boolean myIsStrikeThrough;
|
private boolean myIsStrikeThrough;
|
||||||
private int myVerticalShift;
|
|
||||||
|
|
||||||
private boolean myIsNotCached = true;
|
private boolean myIsNotCached = true;
|
||||||
|
|
||||||
private int myFontSize;
|
private int myFontSize;
|
||||||
private int mySpaceBefore;
|
private int mySpaceBefore;
|
||||||
private int mySpaceAfter;
|
private int mySpaceAfter;
|
||||||
|
private int myVerticalAlign;
|
||||||
private ZLTextMetrics myMetrics;
|
private ZLTextMetrics myMetrics;
|
||||||
|
|
||||||
protected ZLTextDecoratedStyle(ZLTextStyle base, ZLTextHyperlink hyperlink) {
|
protected ZLTextDecoratedStyle(ZLTextStyle base, ZLTextHyperlink hyperlink) {
|
||||||
|
@ -57,7 +57,6 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
|
||||||
myIsBold = isBoldInternal();
|
myIsBold = isBoldInternal();
|
||||||
myIsUnderline = isUnderlineInternal();
|
myIsUnderline = isUnderlineInternal();
|
||||||
myIsStrikeThrough = isStrikeThroughInternal();
|
myIsStrikeThrough = isStrikeThroughInternal();
|
||||||
myVerticalShift = getVerticalShiftInternal();
|
|
||||||
|
|
||||||
myIsNotCached = false;
|
myIsNotCached = false;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +66,7 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
|
||||||
myFontSize = getFontSizeInternal(metrics);
|
myFontSize = getFontSizeInternal(metrics);
|
||||||
mySpaceBefore = getSpaceBeforeInternal(metrics, myFontSize);
|
mySpaceBefore = getSpaceBeforeInternal(metrics, myFontSize);
|
||||||
mySpaceAfter = getSpaceAfterInternal(metrics, myFontSize);
|
mySpaceAfter = getSpaceAfterInternal(metrics, myFontSize);
|
||||||
|
myVerticalAlign = getVerticalAlignInternal(metrics, myFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,11 +142,11 @@ public abstract class ZLTextDecoratedStyle extends ZLTextStyle {
|
||||||
protected abstract boolean isStrikeThroughInternal();
|
protected abstract boolean isStrikeThroughInternal();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int getVerticalShift() {
|
public final int getVerticalAlign(ZLTextMetrics metrics) {
|
||||||
if (myIsNotCached) {
|
if (!metrics.equals(myMetrics)) {
|
||||||
initCache();
|
initMetricsCache(metrics);
|
||||||
}
|
}
|
||||||
return myVerticalShift;
|
return myVerticalAlign;
|
||||||
}
|
}
|
||||||
protected abstract int getVerticalShiftInternal();
|
protected abstract int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,9 +151,9 @@ public class ZLTextExplicitlyDecoratedStyle extends ZLTextDecoratedStyle impleme
|
||||||
return Parent.getLineSpacePercent();
|
return Parent.getLineSpacePercent();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected int getVerticalShiftInternal() {
|
protected int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
return Parent.getVerticalShift();
|
return Parent.getVerticalAlign(metrics);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
|
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
|
||||||
|
|
|
@ -26,13 +26,14 @@ import org.geometerplus.zlibrary.core.fonts.FontEntry;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLBoolean3;
|
import org.geometerplus.zlibrary.core.util.ZLBoolean3;
|
||||||
import org.geometerplus.zlibrary.text.model.ZLTextAlignmentType;
|
import org.geometerplus.zlibrary.text.model.ZLTextAlignmentType;
|
||||||
import org.geometerplus.zlibrary.text.model.ZLTextMetrics;
|
import org.geometerplus.zlibrary.text.model.ZLTextMetrics;
|
||||||
|
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
|
||||||
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
|
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
|
||||||
|
|
||||||
public class ZLTextNGStyle extends ZLTextDecoratedStyle {
|
public class ZLTextNGStyle extends ZLTextDecoratedStyle {
|
||||||
private final ZLTextNGStyleDescription myDescription;
|
private final ZLTextNGStyleDescription myDescription;
|
||||||
|
|
||||||
public ZLTextNGStyle(ZLTextStyle parent, ZLTextNGStyleDescription description) {
|
public ZLTextNGStyle(ZLTextStyle parent, ZLTextNGStyleDescription description, ZLTextHyperlink hyperlink) {
|
||||||
super(parent, parent.Hyperlink);
|
super(parent, hyperlink);
|
||||||
myDescription = description;
|
myDescription = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +121,8 @@ public class ZLTextNGStyle extends ZLTextDecoratedStyle {
|
||||||
return Parent.getLineSpacePercent();
|
return Parent.getLineSpacePercent();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected int getVerticalShiftInternal() {
|
protected int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize) {
|
||||||
// TODO: implement
|
return myDescription.getVerticalAlign(metrics, Parent.getVerticalAlign(metrics), fontSize);
|
||||||
return Parent.getVerticalShift();
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
|
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class ZLTextNGStyleDescription {
|
||||||
public final ZLStringOption MarginTopOption;
|
public final ZLStringOption MarginTopOption;
|
||||||
public final ZLStringOption MarginBottomOption;
|
public final ZLStringOption MarginBottomOption;
|
||||||
public final ZLStringOption AlignmentOption;
|
public final ZLStringOption AlignmentOption;
|
||||||
|
public final ZLStringOption VerticalAlignOption;
|
||||||
|
|
||||||
private static ZLStringOption createOption(String selector, String name, Map<String,String> valueMap) {
|
private static ZLStringOption createOption(String selector, String name, Map<String,String> valueMap) {
|
||||||
return new ZLStringOption("Style", selector + "::" + name, valueMap.get(name));
|
return new ZLStringOption("Style", selector + "::" + name, valueMap.get(name));
|
||||||
|
@ -55,6 +56,7 @@ public class ZLTextNGStyleDescription {
|
||||||
MarginTopOption = createOption(selector, "margin-top", valueMap);
|
MarginTopOption = createOption(selector, "margin-top", valueMap);
|
||||||
MarginBottomOption = createOption(selector, "margin-bottom", valueMap);
|
MarginBottomOption = createOption(selector, "margin-bottom", valueMap);
|
||||||
AlignmentOption = createOption(selector, "text-align", valueMap);
|
AlignmentOption = createOption(selector, "text-align", valueMap);
|
||||||
|
VerticalAlignOption = createOption(selector, "vertical-align", valueMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFontSize(ZLTextMetrics metrics, int baseFontSize) {
|
int getFontSize(ZLTextMetrics metrics, int baseFontSize) {
|
||||||
|
@ -67,6 +69,17 @@ public class ZLTextNGStyleDescription {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getVerticalAlign(ZLTextMetrics metrics, int base, int fontSize) {
|
||||||
|
final ZLTextStyleEntry.Length length = parseLength(VerticalAlignOption.getValue());
|
||||||
|
if (length == null) {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
return ZLTextStyleEntry.compute(
|
||||||
|
// TODO: add new length for vertical alignment
|
||||||
|
length, metrics, fontSize, ZLTextStyleEntry.Feature.LENGTH_FONT_SIZE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
int getSpaceBefore(ZLTextMetrics metrics, int base, int fontSize) {
|
int getSpaceBefore(ZLTextMetrics metrics, int base, int fontSize) {
|
||||||
final ZLTextStyleEntry.Length length = parseLength(MarginTopOption.getValue());
|
final ZLTextStyleEntry.Length length = parseLength(MarginTopOption.getValue());
|
||||||
if (length == null) {
|
if (length == null) {
|
||||||
|
|
|
@ -126,8 +126,8 @@ class ZLTextPartiallyDecoratedStyle extends ZLTextDecoratedStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getVerticalShiftInternal() {
|
protected int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize) {
|
||||||
return Parent.getVerticalShift() + myDecoration.VerticalShiftOption.getValue();
|
return Parent.getVerticalAlign(metrics) + myDecoration.VerticalAlignOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ZLTextStyleCollection {
|
||||||
private int myDefaultFontSize;
|
private int myDefaultFontSize;
|
||||||
private ZLTextBaseStyle myBaseStyle;
|
private ZLTextBaseStyle myBaseStyle;
|
||||||
private final ZLTextNGStyleDescription[] myDescriptionMap = new ZLTextNGStyleDescription[256];
|
private final ZLTextNGStyleDescription[] myDescriptionMap = new ZLTextNGStyleDescription[256];
|
||||||
private final ZLTextStyleDecoration[] myDecorationMap = new ZLTextStyleDecoration[256];
|
private final ZLTextFullStyleDecoration[] myDecorationMap = new ZLTextFullStyleDecoration[256];
|
||||||
|
|
||||||
public ZLTextStyleCollection(String screen) {
|
public ZLTextStyleCollection(String screen) {
|
||||||
Screen = screen;
|
Screen = screen;
|
||||||
|
@ -56,7 +56,7 @@ public class ZLTextStyleCollection {
|
||||||
return myDescriptionMap[kind & 0xFF];
|
return myDescriptionMap[kind & 0xFF];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextStyleDecoration getDecoration(byte kind) {
|
public ZLTextFullStyleDecoration getDecoration(byte kind) {
|
||||||
return myDecorationMap[kind & 0xFF];
|
return myDecorationMap[kind & 0xFF];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,45 +109,36 @@ public class ZLTextStyleCollection {
|
||||||
} else if (STYLE.equals(tag)) {
|
} else if (STYLE.equals(tag)) {
|
||||||
String idString = attributes.getValue("id");
|
String idString = attributes.getValue("id");
|
||||||
String name = attributes.getValue("name");
|
String name = attributes.getValue("name");
|
||||||
if ((idString != null) && (name != null)) {
|
if (idString != null && name != null) {
|
||||||
byte id = Byte.parseByte(idString);
|
byte id = Byte.parseByte(idString);
|
||||||
ZLTextStyleDecoration decoration;
|
|
||||||
|
|
||||||
final String fontFamily = attributes.getValue("family");
|
|
||||||
final int fontSizeDelta = intValue(attributes, "fontSizeDelta", 0);
|
final int fontSizeDelta = intValue(attributes, "fontSizeDelta", 0);
|
||||||
final ZLBoolean3 bold = b3Value(attributes, "bold");
|
final ZLBoolean3 bold = b3Value(attributes, "bold");
|
||||||
final ZLBoolean3 italic = b3Value(attributes, "italic");
|
final ZLBoolean3 italic = b3Value(attributes, "italic");
|
||||||
final int verticalShift = intValue(attributes, "vShift", 0);
|
|
||||||
final ZLBoolean3 allowHyphenations = b3Value(attributes, "allowHyphenations");
|
final ZLBoolean3 allowHyphenations = b3Value(attributes, "allowHyphenations");
|
||||||
|
|
||||||
if (booleanValue(attributes, "partial")) {
|
int spaceBefore = intValue(attributes, "spaceBefore", 0);
|
||||||
decoration = new ZLTextStyleDecoration(name, fontFamily, fontSizeDelta, bold, italic, ZLBoolean3.B3_UNDEFINED, ZLBoolean3.B3_UNDEFINED, verticalShift, allowHyphenations);
|
int spaceAfter = intValue(attributes, "spaceAfter", 0);
|
||||||
} else {
|
int leftIndent = intValue(attributes, "leftIndent", 0);
|
||||||
int spaceBefore = intValue(attributes, "spaceBefore", 0);
|
int rightIndent = intValue(attributes, "rightIndent", 0);
|
||||||
int spaceAfter = intValue(attributes, "spaceAfter", 0);
|
int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta", 0);
|
||||||
int leftIndent = intValue(attributes, "leftIndent", 0);
|
|
||||||
int rightIndent = intValue(attributes, "rightIndent", 0);
|
|
||||||
int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta", 0);
|
|
||||||
|
|
||||||
byte alignment = ZLTextAlignmentType.ALIGN_UNDEFINED;
|
byte alignment = ZLTextAlignmentType.ALIGN_UNDEFINED;
|
||||||
String alignmentString = attributes.getValue("alignment");
|
String alignmentString = attributes.getValue("alignment");
|
||||||
if (alignmentString != null) {
|
if (alignmentString != null) {
|
||||||
if (alignmentString.equals("left")) {
|
if (alignmentString.equals("left")) {
|
||||||
alignment = ZLTextAlignmentType.ALIGN_LEFT;
|
alignment = ZLTextAlignmentType.ALIGN_LEFT;
|
||||||
} else if (alignmentString.equals("right")) {
|
} else if (alignmentString.equals("right")) {
|
||||||
alignment = ZLTextAlignmentType.ALIGN_RIGHT;
|
alignment = ZLTextAlignmentType.ALIGN_RIGHT;
|
||||||
} else if (alignmentString.equals("center")) {
|
} else if (alignmentString.equals("center")) {
|
||||||
alignment = ZLTextAlignmentType.ALIGN_CENTER;
|
alignment = ZLTextAlignmentType.ALIGN_CENTER;
|
||||||
} else if (alignmentString.equals("justify")) {
|
} else if (alignmentString.equals("justify")) {
|
||||||
alignment = ZLTextAlignmentType.ALIGN_JUSTIFY;
|
alignment = ZLTextAlignmentType.ALIGN_JUSTIFY;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final int lineSpacePercent = intValue(attributes, "lineSpacingPercent", -1);
|
|
||||||
|
|
||||||
decoration = new ZLTextFullStyleDecoration(name, fontFamily, fontSizeDelta, bold, italic, ZLBoolean3.B3_UNDEFINED, ZLBoolean3.B3_UNDEFINED, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, verticalShift, alignment, lineSpacePercent, allowHyphenations);
|
|
||||||
}
|
}
|
||||||
|
final int lineSpacePercent = intValue(attributes, "lineSpacingPercent", -1);
|
||||||
|
|
||||||
myDecorationMap[id & 0xFF] = decoration;
|
myDecorationMap[id & 0xFF] = new ZLTextFullStyleDecoration(name, null, fontSizeDelta, bold, italic, ZLBoolean3.B3_UNDEFINED, ZLBoolean3.B3_UNDEFINED, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, 0, alignment, lineSpacePercent, allowHyphenations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -34,12 +34,12 @@ public class ZLTextStyleDecoration {
|
||||||
public final ZLBoolean3Option ItalicOption;
|
public final ZLBoolean3Option ItalicOption;
|
||||||
public final ZLBoolean3Option UnderlineOption;
|
public final ZLBoolean3Option UnderlineOption;
|
||||||
public final ZLBoolean3Option StrikeThroughOption;
|
public final ZLBoolean3Option StrikeThroughOption;
|
||||||
public final ZLIntegerOption VerticalShiftOption;
|
public final ZLIntegerOption VerticalAlignOption;
|
||||||
public final ZLBoolean3Option AllowHyphenationsOption;
|
public final ZLBoolean3Option AllowHyphenationsOption;
|
||||||
|
|
||||||
private final String myName;
|
private final String myName;
|
||||||
|
|
||||||
public ZLTextStyleDecoration(String name, String fontFamily, int fontSizeDelta, ZLBoolean3 bold, ZLBoolean3 italic, ZLBoolean3 underline, ZLBoolean3 strikeThrough, int verticalShift, ZLBoolean3 allowHyphenations) {
|
public ZLTextStyleDecoration(String name, String fontFamily, int fontSizeDelta, ZLBoolean3 bold, ZLBoolean3 italic, ZLBoolean3 underline, ZLBoolean3 strikeThrough, int verticalAlign, ZLBoolean3 allowHyphenations) {
|
||||||
myName = name;
|
myName = name;
|
||||||
FontFamilyOption = new ZLStringOption(STYLE, name + ":fontFamily", fontFamily);
|
FontFamilyOption = new ZLStringOption(STYLE, name + ":fontFamily", fontFamily);
|
||||||
FontSizeDeltaOption = new ZLIntegerRangeOption(STYLE, name + ":fontSize", -16, 16, fontSizeDelta);
|
FontSizeDeltaOption = new ZLIntegerRangeOption(STYLE, name + ":fontSize", -16, 16, fontSizeDelta);
|
||||||
|
@ -47,7 +47,7 @@ public class ZLTextStyleDecoration {
|
||||||
ItalicOption = new ZLBoolean3Option(STYLE, name + ":italic", italic);
|
ItalicOption = new ZLBoolean3Option(STYLE, name + ":italic", italic);
|
||||||
UnderlineOption = new ZLBoolean3Option(STYLE, name + ":underline", underline);
|
UnderlineOption = new ZLBoolean3Option(STYLE, name + ":underline", underline);
|
||||||
StrikeThroughOption = new ZLBoolean3Option(STYLE, name + ":strikeThrough", strikeThrough);
|
StrikeThroughOption = new ZLBoolean3Option(STYLE, name + ":strikeThrough", strikeThrough);
|
||||||
VerticalShiftOption = new ZLIntegerOption(STYLE, name + ":vShift", verticalShift);
|
VerticalAlignOption = new ZLIntegerOption(STYLE, name + ":vShift", verticalAlign);
|
||||||
AllowHyphenationsOption = new ZLBoolean3Option(STYLE, name + ":allowHyphenations", allowHyphenations);
|
AllowHyphenationsOption = new ZLBoolean3Option(STYLE, name + ":allowHyphenations", allowHyphenations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue