Method: Spreadsheet::Excel::Reader#read_font
- Defined in:
- lib/spreadsheet/excel/reader.rb
#read_font(work, pos, len) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/spreadsheet/excel/reader.rb', line 233 def read_font work, pos, len # Offset Size Contents # 0 2 Height of the font (in twips = 1/20 of a point) # 2 2 Option flags: # Bit Mask Contents # 0 0x0001 1 = Characters are bold (redundant, see below) # 1 0x0002 1 = Characters are italic # 2 0x0004 1 = Characters are underlined # (redundant, see below) # 3 0x0008 1 = Characters are struck out # 4 0x0010 1 = Characters are outlined (djberger) # 5 0x0020 1 = Characters are shadowed (djberger) # 4 2 Colour index (➜ 6.70) # 6 2 Font weight (100-1000). Standard values are # 0x0190 (400) for normal text and # 0x02bc (700) for bold text. # 8 2 Escapement type: 0x0000 = None # 0x0001 = Superscript # 0x0002 = Subscript # 10 1 Underline type: 0x00 = None # 0x01 = Single # 0x02 = Double # 0x21 = Single accounting # 0x22 = Double accounting # 11 1 Font family: # 0x00 = None (unknown or don't care) # 0x01 = Roman (variable width, serifed) # 0x02 = Swiss (variable width, sans-serifed) # 0x03 = Modern (fixed width, serifed or sans-serifed) # 0x04 = Script (cursive) # 0x05 = Decorative (specialised, # for example Old English, Fraktur) # 12 1 Character set: 0x00 = 0 = ANSI Latin # 0x01 = 1 = System default # 0x02 = 2 = Symbol # 0x4d = 77 = Apple Roman # 0x80 = 128 = ANSI Japanese Shift-JIS # 0x81 = 129 = ANSI Korean (Hangul) # 0x82 = 130 = ANSI Korean (Johab) # 0x86 = 134 = ANSI Chinese Simplified GBK # 0x88 = 136 = ANSI Chinese Traditional BIG5 # 0xa1 = 161 = ANSI Greek # 0xa2 = 162 = ANSI Turkish # 0xa3 = 163 = ANSI Vietnamese # 0xb1 = 177 = ANSI Hebrew # 0xb2 = 178 = ANSI Arabic # 0xba = 186 = ANSI Baltic # 0xcc = 204 = ANSI Cyrillic # 0xde = 222 = ANSI Thai # 0xee = 238 = ANSI Latin II (Central European) # 0xff = 255 = OEM Latin I # 13 1 Not used # 14 var. Font name: # BIFF5/BIFF7: Byte string, 8-bit string length (➜ 3.3) # BIFF8: Unicode string, 8-bit string length (➜ 3.4) name = client read_string(work[14..-1]), @workbook.encoding font = Font.new name size, opts, color, font.weight, escapement, underline, family, encoding = work.unpack binfmt(:font) font.size = size / TWIPS font.italic = opts & 0x0002 font.strikeout = opts & 0x0008 font.outline = opts & 0x0010 font.shadow = opts & 0x0020 font.color = COLOR_CODES[color] || :text font.escapement = ESCAPEMENT_TYPES[escapement] font.underline = UNDERLINE_TYPES[underline] font.family = FONT_FAMILIES[family] font.encoding = FONT_ENCODINGS[encoding] @workbook.add_font font end |