mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
CSS support (in progress)
This commit is contained in:
parent
74cb4cf7be
commit
9017ad8ea4
4 changed files with 49 additions and 7 deletions
|
@ -189,8 +189,15 @@ void StyleSheetParser::processWordWithoutComments(const std::string &word) {
|
|||
myMap[myAttributeName].clear();
|
||||
break;
|
||||
case ATTRIBUTE_VALUE:
|
||||
{
|
||||
const size_t l = word.length();
|
||||
if (l >= 2 && (word[0] == '"' || word[0] == '\'') && word[0] == word[l - 1]) {
|
||||
myMap[myAttributeName].push_back(word.substr(1, l - 2));
|
||||
} else {
|
||||
myMap[myAttributeName].push_back(word);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BROKEN:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <cstdlib>
|
||||
|
||||
#include <ZLStringUtil.h>
|
||||
#include <ZLLogger.h>
|
||||
|
||||
#include "StyleSheetTable.h"
|
||||
|
||||
|
@ -185,6 +186,7 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
|||
const std::vector<std::string> &fontFamily = values(styles, "font-family");
|
||||
if (!fontFamily.empty() && !fontFamily[0].empty()) {
|
||||
entry->setFontFamily(fontFamily[0]);
|
||||
ZLLogger::Instance().println(ZLLogger::DEFAULT_CLASS, "font family: " + fontFamily[0]);
|
||||
}
|
||||
|
||||
const std::vector<std::string> &fontSize = values(styles, "font-size");
|
||||
|
|
|
@ -195,12 +195,17 @@ public class ZLTextPlainModel implements ZLTextModel, ZLTextStyleEntry.Feature {
|
|||
}
|
||||
if (ZLTextStyleEntry.isFeatureSupported(mask, ALIGNMENT_TYPE) ||
|
||||
ZLTextStyleEntry.isFeatureSupported(mask, FONT_SIZE_MAGNIFICATION)) {
|
||||
// TODO: read alignment type and/or font size magnification
|
||||
dataOffset += 1;
|
||||
final short value = (short)data[dataOffset++];
|
||||
if (ZLTextStyleEntry.isFeatureSupported(mask, ALIGNMENT_TYPE)) {
|
||||
entry.setAlignmentType((byte)(value & 0xFF));
|
||||
}
|
||||
if (ZLTextStyleEntry.isFeatureSupported(mask, FONT_SIZE_MAGNIFICATION)) {
|
||||
entry.setFontSizeMagnification((byte)((value >> 8) & 0xFF));
|
||||
}
|
||||
}
|
||||
if (ZLTextStyleEntry.isFeatureSupported(mask, FONT_FAMILY)) {
|
||||
final short familyLength = (short)data[dataOffset++];
|
||||
// TODO: read font family
|
||||
entry.setFontFamily(new String(data, dataOffset, familyLength));
|
||||
dataOffset += familyLength;
|
||||
}
|
||||
if (ZLTextStyleEntry.isFeatureSupported(mask, FONT_STYLE_MODIFIER)) {
|
||||
|
|
|
@ -34,6 +34,9 @@ public final class ZLTextStyleEntry {
|
|||
}
|
||||
|
||||
private short myFeatureMask;
|
||||
private byte myAlignmentType;
|
||||
private byte myFontSizeMagnification;
|
||||
private String myFontFamily;
|
||||
|
||||
static boolean isFeatureSupported(short mask, int featureId) {
|
||||
return (mask & (1 << featureId)) != 0;
|
||||
|
@ -45,7 +48,6 @@ public final class ZLTextStyleEntry {
|
|||
|
||||
//private short myLeftIndent;
|
||||
//private short myRightIndent;
|
||||
//private byte myAlignmentType;
|
||||
|
||||
public ZLTextStyleEntry() {
|
||||
}
|
||||
|
@ -58,9 +60,35 @@ public final class ZLTextStyleEntry {
|
|||
public short getRightIndent() {
|
||||
return myRightIndent;
|
||||
}
|
||||
*/
|
||||
|
||||
void setAlignmentType(byte alignmentType) {
|
||||
myFeatureMask |= 1 << Feature.ALIGNMENT_TYPE;
|
||||
System.err.println("setting alignment to " + alignmentType);
|
||||
myAlignmentType = alignmentType;
|
||||
}
|
||||
|
||||
public byte getAlignmentType() {
|
||||
return myAlignmentType;
|
||||
}
|
||||
*/
|
||||
|
||||
void setFontSizeMagnification(byte fontSizeMagnification) {
|
||||
myFeatureMask |= 1 << Feature.FONT_SIZE_MAGNIFICATION;
|
||||
System.err.println("setting font size magnification to " + fontSizeMagnification);
|
||||
myFontSizeMagnification = fontSizeMagnification;
|
||||
}
|
||||
|
||||
public byte getFontSizeMagnification() {
|
||||
return myFontSizeMagnification;
|
||||
}
|
||||
|
||||
void setFontFamily(String fontFamily) {
|
||||
myFeatureMask |= 1 << Feature.FONT_FAMILY;
|
||||
System.err.println("setting font family to " + fontFamily);
|
||||
myFontFamily = fontFamily;
|
||||
}
|
||||
|
||||
public String getFontFamily() {
|
||||
return myFontFamily;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue