diff --git a/ChangeLog b/ChangeLog index 1f7eddc2f..f1073a84f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ ===== 1.6.3 (Oct ??, 2012) ===== * FBReader stores text position after setPageStart API method (useful for TTS plugin, code by Greg Kochaniak) * MSWord doc plugin synchronized with the main branch +* New options: apply/ignore values defined in CSS ===== 1.6.2 (Oct 13, 2012) ===== * Optimized animation speed diff --git a/assets/resources/application/cs.xml b/assets/resources/application/cs.xml index d2f5e6fa2..95f658570 100644 --- a/assets/resources/application/cs.xml +++ b/assets/resources/application/cs.xml @@ -507,6 +507,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/de.xml b/assets/resources/application/de.xml index efccd0b3c..31973b94f 100644 --- a/assets/resources/application/de.xml +++ b/assets/resources/application/de.xml @@ -501,6 +501,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml index 495488e4e..ffd99dd8a 100644 --- a/assets/resources/application/en.xml +++ b/assets/resources/application/en.xml @@ -507,6 +507,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/es.xml b/assets/resources/application/es.xml index 26d109671..23cc61ad3 100644 --- a/assets/resources/application/es.xml +++ b/assets/resources/application/es.xml @@ -500,6 +500,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/fr.xml b/assets/resources/application/fr.xml index 972a69549..61423801a 100644 --- a/assets/resources/application/fr.xml +++ b/assets/resources/application/fr.xml @@ -500,6 +500,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/gl.xml b/assets/resources/application/gl.xml index ec049f956..8b388ed38 100644 --- a/assets/resources/application/gl.xml +++ b/assets/resources/application/gl.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/hu.xml b/assets/resources/application/hu.xml index 1a7796982..fef31b948 100644 --- a/assets/resources/application/hu.xml +++ b/assets/resources/application/hu.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/it.xml b/assets/resources/application/it.xml index e0df6e60d..25a81484c 100644 --- a/assets/resources/application/it.xml +++ b/assets/resources/application/it.xml @@ -498,6 +498,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/nb.xml b/assets/resources/application/nb.xml index 10f0c288e..5bb0e5d17 100644 --- a/assets/resources/application/nb.xml +++ b/assets/resources/application/nb.xml @@ -507,6 +507,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/nl.xml b/assets/resources/application/nl.xml index c51a831b4..c9e07d9b8 100644 --- a/assets/resources/application/nl.xml +++ b/assets/resources/application/nl.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/pl.xml b/assets/resources/application/pl.xml index 21a98ad1c..942600efc 100644 --- a/assets/resources/application/pl.xml +++ b/assets/resources/application/pl.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/pt.xml b/assets/resources/application/pt.xml index 1e03a1511..c55d6f323 100644 --- a/assets/resources/application/pt.xml +++ b/assets/resources/application/pt.xml @@ -509,6 +509,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/ro.xml b/assets/resources/application/ro.xml index b335c4421..8c37ba372 100644 --- a/assets/resources/application/ro.xml +++ b/assets/resources/application/ro.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/ru.xml b/assets/resources/application/ru.xml index 8fe9138e1..3de866660 100644 --- a/assets/resources/application/ru.xml +++ b/assets/resources/application/ru.xml @@ -512,6 +512,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/sr.xml b/assets/resources/application/sr.xml index bcbdb029b..e3dc66d74 100644 --- a/assets/resources/application/sr.xml +++ b/assets/resources/application/sr.xml @@ -507,6 +507,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/th.xml b/assets/resources/application/th.xml index e870f4eee..011e79795 100644 --- a/assets/resources/application/th.xml +++ b/assets/resources/application/th.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/tr.xml b/assets/resources/application/tr.xml index 9f73cc062..5d33e896a 100644 --- a/assets/resources/application/tr.xml +++ b/assets/resources/application/tr.xml @@ -507,6 +507,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/uk.xml b/assets/resources/application/uk.xml index 92f3dfb0b..b6bb7314c 100644 --- a/assets/resources/application/uk.xml +++ b/assets/resources/application/uk.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/vi.xml b/assets/resources/application/vi.xml index 62e8678d9..fb3faa957 100644 --- a/assets/resources/application/vi.xml +++ b/assets/resources/application/vi.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/zh.xml b/assets/resources/application/zh.xml index 1defb3e17..62c80500d 100644 --- a/assets/resources/application/zh.xml +++ b/assets/resources/application/zh.xml @@ -497,6 +497,17 @@ + + + + + + + + + + + diff --git a/assets/resources/application/zh_TW.xml b/assets/resources/application/zh_TW.xml index eb8ae1a99..daeaa48a7 100644 --- a/assets/resources/application/zh_TW.xml +++ b/assets/resources/application/zh_TW.xml @@ -502,6 +502,17 @@ + + + + + + + + + + + diff --git a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp index 9fbab5855..dac85f7c2 100644 --- a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp +++ b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp @@ -148,7 +148,7 @@ const std::vector &StyleSheetTable::values(const AttributeMap &map, } shared_ptr StyleSheetTable::createControl(const AttributeMap &styles) { - shared_ptr entry = new ZLTextStyleEntry(); + shared_ptr entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY); const std::vector &alignment = values(styles, "text-align"); if (!alignment.empty()) { diff --git a/jni/NativeFormats/fbreader/src/formats/doc/DocBookReader.cpp b/jni/NativeFormats/fbreader/src/formats/doc/DocBookReader.cpp index dd1401d4c..faa7a0497 100644 --- a/jni/NativeFormats/fbreader/src/formats/doc/DocBookReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/doc/DocBookReader.cpp @@ -274,7 +274,7 @@ void DocBookReader::handleParagraphStyle(const OleMainStream::Style &styleInfo) if (styleInfo.HasPageBreakBefore) { handlePageBreak(); } - shared_ptr entry = new ZLTextStyleEntry(); + shared_ptr entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_OTHER_ENTRY); switch (styleInfo.Alignment) { default: // in that case, use default alignment type diff --git a/jni/NativeFormats/fbreader/src/formats/rtf/RtfBookReader.cpp b/jni/NativeFormats/fbreader/src/formats/rtf/RtfBookReader.cpp index 69e82926d..38cdc0bd9 100644 --- a/jni/NativeFormats/fbreader/src/formats/rtf/RtfBookReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/rtf/RtfBookReader.cpp @@ -224,7 +224,7 @@ void RtfBookReader::setEncoding(int) { } void RtfBookReader::setAlignment() { - ZLTextStyleEntry entry; + ZLTextStyleEntry entry(ZLTextStyleEntry::STYLE_OTHER_ENTRY); entry.setAlignmentType(myState.Alignment); myBookReader.addStyleEntry(entry); // TODO: call addStyleCloseEntry somewhere (?) diff --git a/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp b/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp index 582c35c1a..bc7180b58 100644 --- a/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp @@ -598,7 +598,7 @@ void XHTMLReader::beginParagraph() { } if (doBlockSpaceBefore) { - ZLTextStyleEntry blockingEntry; + ZLTextStyleEntry blockingEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY); blockingEntry.setLength( ZLTextStyleEntry::LENGTH_SPACE_BEFORE, 0, @@ -616,7 +616,7 @@ void XHTMLReader::endParagraph() { (*it)->isFeatureSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER); } if (doBlockSpaceAfter) { - ZLTextStyleEntry blockingEntry; + ZLTextStyleEntry blockingEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY); blockingEntry.setLength( ZLTextStyleEntry::LENGTH_SPACE_AFTER, 0, diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp b/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp index aabfc627e..98c2bf6cb 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp @@ -270,7 +270,7 @@ void ZLTextModel::addStyleEntry(const ZLTextStyleEntry &entry) { myLastEntryStart = myAllocator->allocate(len); char *address = myLastEntryStart; - *address++ = ZLTextParagraphEntry::STYLE_ENTRY; + *address++ = entry.entryKind(); *address++ = 0; address = ZLCachedMemoryAllocator::writeUInt16(address, entry.myFeatureMask); diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h b/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h index 940b70584..92fc6ba46 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h @@ -41,10 +41,11 @@ public: IMAGE_ENTRY = 2, CONTROL_ENTRY = 3, HYPERLINK_CONTROL_ENTRY = 4, - STYLE_ENTRY = 5, - STYLE_CLOSE_ENTRY = 6, - FIXED_HSPACE_ENTRY = 7, - RESET_BIDI_ENTRY = 8, + STYLE_CSS_ENTRY = 5, + STYLE_OTHER_ENTRY = 6, + STYLE_CLOSE_ENTRY = 7, + FIXED_HSPACE_ENTRY = 8, + RESET_BIDI_ENTRY = 9, }; protected: diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h b/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h index 9728863c9..b3651f41b 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h @@ -77,10 +77,12 @@ private: }; public: - ZLTextStyleEntry(); + ZLTextStyleEntry(unsigned char entryKind); //ZLTextStyleEntry(char *address); ~ZLTextStyleEntry(); + unsigned char entryKind() const; + bool isEmpty() const; bool isFeatureSupported(Feature featureId) const; @@ -97,6 +99,7 @@ public: void setFontFamily(const std::string &fontFamily); private: + unsigned char myEntryKind; unsigned short myFeatureMask; LengthType myLengths[NUMBER_OF_LENGTHS]; @@ -108,9 +111,11 @@ private: friend class ZLTextModel; }; -inline ZLTextStyleEntry::ZLTextStyleEntry() : myFeatureMask(0), myAlignmentType(ALIGN_UNDEFINED), mySupportedFontModifier(0), myFontModifier(0) {} +inline ZLTextStyleEntry::ZLTextStyleEntry(unsigned char entryKind) : myEntryKind(entryKind), myFeatureMask(0), myAlignmentType(ALIGN_UNDEFINED), mySupportedFontModifier(0), myFontModifier(0) {} inline ZLTextStyleEntry::~ZLTextStyleEntry() {} +inline unsigned char ZLTextStyleEntry::entryKind() const { return myEntryKind; } + inline ZLTextStyleEntry::Metrics::Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight) : FontSize(fontSize), FontXHeight(fontXHeight), FullWidth(fullWidth), FullHeight(fullHeight) {} inline bool ZLTextStyleEntry::isEmpty() const { return myFeatureMask == 0; } diff --git a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java index d7b679647..ad72023a8 100644 --- a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java +++ b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java @@ -253,6 +253,10 @@ public class PreferenceActivity extends ZLPreferenceActivity { final ZLPreferenceSet footerPreferences = new ZLPreferenceSet(); final ZLPreferenceSet bgPreferences = new ZLPreferenceSet(); + final Screen cssScreen = createPreferenceScreen("css"); + cssScreen.addOption(collection.UseCSSFontSizeOption, "fontSize"); + cssScreen.addOption(collection.UseCSSTextAlignmentOption, "textAlignment"); + final Screen colorsScreen = createPreferenceScreen("colors"); colorsScreen.addPreference(new WallpaperPreference( this, profile, colorsScreen.Resource, "background" diff --git a/src/org/geometerplus/fbreader/fbreader/ChangeFontSizeAction.java b/src/org/geometerplus/fbreader/fbreader/ChangeFontSizeAction.java index a9eec2e61..889e6f1e5 100644 --- a/src/org/geometerplus/fbreader/fbreader/ChangeFontSizeAction.java +++ b/src/org/geometerplus/fbreader/fbreader/ChangeFontSizeAction.java @@ -32,7 +32,7 @@ class ChangeFontSizeAction extends FBAction { @Override protected void run(Object ... params) { - ZLIntegerRangeOption option = + final ZLIntegerRangeOption option = ZLTextStyleCollection.Instance().getBaseStyle().FontSizeOption; option.setValue(option.getValue() + myDelta); Reader.clearTextCaches(); diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextParagraph.java b/src/org/geometerplus/zlibrary/text/model/ZLTextParagraph.java index e14a7fda8..4ef33df15 100644 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextParagraph.java +++ b/src/org/geometerplus/zlibrary/text/model/ZLTextParagraph.java @@ -25,10 +25,11 @@ public interface ZLTextParagraph { byte IMAGE = 2; byte CONTROL = 3; byte HYPERLINK_CONTROL = 4; - byte STYLE = 5; - byte STYLE_CLOSE = 6; - byte FIXED_HSPACE = 7; - byte RESET_BIDI = 8; + byte STYLE_CSS = 5; + byte STYLE_OTHER = 6; + byte STYLE_CLOSE = 7; + byte FIXED_HSPACE = 8; + byte RESET_BIDI = 9; } interface EntryIterator { diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java b/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java index a44833d74..1ad9b6469 100644 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java +++ b/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java @@ -188,9 +188,13 @@ public class ZLTextPlainModel implements ZLTextModel, ZLTextStyleEntry.Feature { case ZLTextParagraph.Entry.FIXED_HSPACE: myFixedHSpaceLength = (short)data[dataOffset++]; break; - case ZLTextParagraph.Entry.STYLE: + case ZLTextParagraph.Entry.STYLE_CSS: + case ZLTextParagraph.Entry.STYLE_OTHER: { - final ZLTextStyleEntry entry = new ZLTextStyleEntry(); + final ZLTextStyleEntry entry = + type == ZLTextParagraph.Entry.STYLE_CSS + ? new ZLTextCSSStyleEntry() + : new ZLTextOtherStyleEntry(); final short mask = (short)data[dataOffset++]; for (int i = 0; i < NUMBER_OF_LENGTHS; ++i) { diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java b/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java index b6d7e50b8..5419b5a32 100644 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java +++ b/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java @@ -21,7 +21,7 @@ package org.geometerplus.zlibrary.text.model; import org.geometerplus.zlibrary.core.util.ZLBoolean3; -public final class ZLTextStyleEntry { +public abstract class ZLTextStyleEntry { public interface Feature { int LENGTH_LEFT_INDENT = 0; int LENGTH_RIGHT_INDENT = 1; @@ -76,14 +76,14 @@ public final class ZLTextStyleEntry { return (mask & (1 << featureId)) != 0; } - public boolean isFeatureSupported(int featureId) { + protected ZLTextStyleEntry() { + } + + public final boolean isFeatureSupported(int featureId) { return isFeatureSupported(myFeatureMask, featureId); } - public ZLTextStyleEntry() { - } - - void setLength(int featureId, short size, byte unit) { + final void setLength(int featureId, short size, byte unit) { myFeatureMask |= 1 << featureId; myLengths[featureId] = new Length(size, unit); } @@ -103,7 +103,7 @@ public final class ZLTextStyleEntry { } } - public int getLength(int featureId, ZLTextMetrics metrics) { + public final int getLength(int featureId, ZLTextMetrics metrics) { switch (myLengths[featureId].Unit) { default: case SizeUnit.PIXEL: @@ -122,31 +122,31 @@ public final class ZLTextStyleEntry { } } - void setAlignmentType(byte alignmentType) { + final void setAlignmentType(byte alignmentType) { myFeatureMask |= 1 << Feature.ALIGNMENT_TYPE; myAlignmentType = alignmentType; } - public byte getAlignmentType() { + public final byte getAlignmentType() { return myAlignmentType; } - void setFontFamily(String fontFamily) { + final void setFontFamily(String fontFamily) { myFeatureMask |= 1 << Feature.FONT_FAMILY; myFontFamily = fontFamily; } - public String getFontFamily() { + public final String getFontFamily() { return myFontFamily; } - void setFontModifiers(byte supported, byte values) { + final void setFontModifiers(byte supported, byte values) { myFeatureMask |= 1 << Feature.FONT_STYLE_MODIFIER; mySupportedFontModifiers = supported; myFontModifiers = values; } - void setFontModifier(byte modifier, boolean on) { + final void setFontModifier(byte modifier, boolean on) { myFeatureMask |= 1 << Feature.FONT_STYLE_MODIFIER; mySupportedFontModifiers |= modifier; if (on) { @@ -156,7 +156,7 @@ public final class ZLTextStyleEntry { } } - public ZLBoolean3 getFontModifier(byte modifier) { + public final ZLBoolean3 getFontModifier(byte modifier) { if ((mySupportedFontModifiers & modifier) == 0) { return ZLBoolean3.B3_UNDEFINED; } diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextWritablePlainModel.java b/src/org/geometerplus/zlibrary/text/model/ZLTextWritablePlainModel.java index f2b04efb9..96e79e39c 100644 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextWritablePlainModel.java +++ b/src/org/geometerplus/zlibrary/text/model/ZLTextWritablePlainModel.java @@ -140,7 +140,7 @@ public final class ZLTextWritablePlainModel extends ZLTextPlainModel implements } final char[] block = getDataBlock(len); ++myParagraphLengths[myParagraphsNumber - 1]; - block[myBlockOffset++] = (char)ZLTextParagraph.Entry.STYLE; + block[myBlockOffset++] = (char)ZLTextParagraph.Entry.STYLE; // CSS or OTHER block[myBlockOffset++] = (char)entry.getMask(); if (entry.isLeftIndentSupported()) { block[myBlockOffset++] = (char)entry.getLeftIndent(); diff --git a/src/org/geometerplus/zlibrary/text/view/ZLTextParagraphCursor.java b/src/org/geometerplus/zlibrary/text/view/ZLTextParagraphCursor.java index d4d2b961b..464fba8d1 100644 --- a/src/org/geometerplus/zlibrary/text/view/ZLTextParagraphCursor.java +++ b/src/org/geometerplus/zlibrary/text/view/ZLTextParagraphCursor.java @@ -100,7 +100,8 @@ public final class ZLTextParagraphCursor { } } break; - case ZLTextParagraph.Entry.STYLE: + case ZLTextParagraph.Entry.STYLE_CSS: + case ZLTextParagraph.Entry.STYLE_OTHER: elements.add(new ZLTextStyleElement(it.getStyleEntry())); break; case ZLTextParagraph.Entry.STYLE_CLOSE: diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextBaseStyle.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextBaseStyle.java index 92126c36c..38e968eba 100644 --- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextBaseStyle.java +++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextBaseStyle.java @@ -49,12 +49,12 @@ public class ZLTextBaseStyle extends ZLTextStyle { public final ZLStringOption FontFamilyOption; public final ZLIntegerRangeOption FontSizeOption; - + public ZLTextBaseStyle(String fontFamily, int fontSize) { super(null, ZLTextHyperlink.NO_LINK); FontFamilyOption = new ZLStringOption(GROUP, "Base:fontFamily", fontFamily); fontSize = fontSize * ZLibrary.Instance().getDisplayDPI() / 320 * 2; - FontSizeOption = new ZLIntegerRangeOption(GROUP, "Base:fontSize", 5, 72, fontSize); + FontSizeOption = new ZLIntegerRangeOption(GROUP, "Base:fontSize", 5, Math.max(72, fontSize * 2), fontSize); } @Override diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java index e14873135..2fa9e748c 100644 --- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java +++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java @@ -21,9 +21,7 @@ package org.geometerplus.zlibrary.text.view.style; import org.geometerplus.zlibrary.core.util.ZLBoolean3; -import org.geometerplus.zlibrary.text.model.ZLTextMetrics; -import org.geometerplus.zlibrary.text.model.ZLTextStyleEntry; - +import org.geometerplus.zlibrary.text.model.*; import org.geometerplus.zlibrary.text.view.ZLTextStyle; public class ZLTextExplicitlyDecoratedStyle extends ZLTextDecoratedStyle implements ZLTextStyleEntry.Feature, ZLTextStyleEntry.FontModifier { @@ -43,6 +41,10 @@ public class ZLTextExplicitlyDecoratedStyle extends ZLTextDecoratedStyle impleme } @Override protected int getFontSizeInternal(ZLTextMetrics metrics) { + if (myEntry instanceof ZLTextCSSStyleEntry && + !ZLTextStyleCollection.Instance().UseCSSFontSizeOption.getValue()) { + return Base.getFontSize(metrics); + } if (myEntry.isFeatureSupported(FONT_STYLE_MODIFIER)) { if (myEntry.getFontModifier(FONT_MODIFIER_INHERIT) == ZLBoolean3.B3_TRUE) { return Base.Base.getFontSize(metrics); @@ -135,6 +137,10 @@ public class ZLTextExplicitlyDecoratedStyle extends ZLTextDecoratedStyle impleme return Base.getSpaceAfter(); } public byte getAlignment() { + if (myEntry instanceof ZLTextCSSStyleEntry && + !ZLTextStyleCollection.Instance().UseCSSTextAlignmentOption.getValue()) { + return Base.getAlignment(); + } return myEntry.isFeatureSupported(ALIGNMENT_TYPE) ? myEntry.getAlignmentType() diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextStyleCollection.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextStyleCollection.java index 71d50708f..3764e28cf 100644 --- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextStyleCollection.java +++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextStyleCollection.java @@ -19,23 +19,16 @@ package org.geometerplus.zlibrary.text.view.style; +import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile; import org.geometerplus.zlibrary.core.library.ZLibrary; +import org.geometerplus.zlibrary.core.options.ZLBooleanOption; import org.geometerplus.zlibrary.core.util.ZLBoolean3; import org.geometerplus.zlibrary.core.xml.*; import org.geometerplus.zlibrary.text.model.ZLTextAlignmentType; -import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile; public class ZLTextStyleCollection { private static ZLTextStyleCollection ourInstance = null; - private int myDefaultFontSize; - private ZLTextBaseStyle myBaseStyle; - private final ZLTextStyleDecoration[] myDecorationMap = new ZLTextStyleDecoration[256]; - - private ZLTextStyleCollection() { - new TextStyleReader(this).readQuietly(ZLResourceFile.createResourceFile("default/styles.xml")); - } - public static ZLTextStyleCollection Instance() { if (ourInstance == null) { ourInstance = new ZLTextStyleCollection(); @@ -47,6 +40,19 @@ public class ZLTextStyleCollection { ourInstance = null; } + private int myDefaultFontSize; + private ZLTextBaseStyle myBaseStyle; + private final ZLTextStyleDecoration[] myDecorationMap = new ZLTextStyleDecoration[256]; + + public final ZLBooleanOption UseCSSTextAlignmentOption = + new ZLBooleanOption("Style", "css:textAlignment", true); + public final ZLBooleanOption UseCSSFontSizeOption = + new ZLBooleanOption("Style", "css:fontSize", true); + + private ZLTextStyleCollection() { + new TextStyleReader(this).readQuietly(ZLResourceFile.createResourceFile("default/styles.xml")); + } + public int getDefaultFontSize() { return myDefaultFontSize; }