org.ttzero.excel.entity.style.BIFFFont Maven / Gradle / Ivy
/*
* Copyright (c) 2019-2020, [email protected] All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ttzero.excel.entity.style;
import org.ttzero.excel.entity.e3.Option;
/**
* 5.45 FONT
*
* This record contains information about a used font,
* including character formatting. All FONT records
* occur together in a sequential list. Other records
* referencing a FONT record contain an index into this list.
*
* The font with index 4 is omitted in all BIFF versions.
* This means the first four fonts have zero-based indexes,
* and the fifth font and all following fonts are referenced
* with one-based indexes.
*
* @author guanquan.wang at 2019-01-28 18:33
*/
public class BIFFFont {
short height;
Option optionFlag;
short colorIndex;
/**
* BIFFFont weight (100-1000). Standard values are 0190H (400) for normal text and 02BCH
* (700) for bold text
*/
short fontWeight;
/**
* 0x0000 = None
* 0x0001 = Superscript
* 0x0002 = Subscript
*/
short escapementType;
UnderlineType underlineType;
FontFamily fontFamily;
/**
* @see org.ttzero.excel.entity.style.Charset
*/
short charset;
String fontName;
@Override
public String toString() {
return "height: " + height +
", optionFlag: " + optionFlag +
", colorIndex: " + colorIndex +
", fontWeight: " + fontWeight +
", escapementType: " + escapementType +
", underlineType: " + underlineType +
", fontFamily: " + fontFamily +
", charset: " + charset +
", fontName: " + fontName;
}
public enum UnderlineType {
None(0x0),
Single(0x01),
Double(0x02),
SingleAccounting(0x21),
DoubleAccounting(0x22)
;
byte value;
UnderlineType(int value) {
this.value = (byte) (value & 0x7F);
}
public byte getValue() {
return value;
}
public static UnderlineType of(short t) {
for (UnderlineType ut : values()) {
if (ut.value == t) {
return ut;
}
}
return None;
}
}
public enum FontFamily {
/**
* unknown or don't care
*/
None(0x0),
/**
* variable width, serifed
*/
Roman(0x01),
/**
* variable width, sans-serifed
*/
Swiss(0x02),
/**
* fixed width, serifed or sans-serifed
*/
Modern(0x03),
/**
* cursive
*/
Script(0x04),
/**
* specialised, for example Old English, Fraktur
*/
Decorative(0x05)
;
byte value;
FontFamily(int value) {
this.value = (byte) (value & 0x7F);
}
public byte getValue() {
return value;
}
public static FontFamily of(short t) {
for (FontFamily ut : values()) {
if (ut.value == t) {
return ut;
}
}
return None;
}
}
}