lib/ttfunk/table/cmap/subtable.rb in ttfunk-1.0.3 vs lib/ttfunk/table/cmap/subtable.rb in ttfunk-1.1.0
- old
+ new
@@ -11,19 +11,22 @@
attr_reader :format
ENCODING_MAPPINGS = {
:mac_roman => { :platform_id => 1, :encoding_id => 0 },
# use microsoft unicode, instead of generic unicode, for optimal windows support
- :unicode => { :platform_id => 3, :encoding_id => 1 }
+ :unicode => { :platform_id => 3, :encoding_id => 1 },
+ :unicode_ucs4 => { :platform_id => 3, :encoding_id => 10 }
}
def self.encode(charmap, encoding)
case encoding
when :mac_roman
result = Format00.encode(charmap)
when :unicode
result = Format04.encode(charmap)
+ when :unicode_ucs4
+ result = Format12.encode(charmap)
else
raise NotImplementedError, "encoding #{encoding.inspect} is not supported"
end
mapping = ENCODING_MAPPINGS[encoding]
@@ -42,21 +45,24 @@
parse_from(@offset) do
@format = read(2, "n").first
case @format
- when 0 then extend(TTFunk::Table::Cmap::Format00)
- when 4 then extend(TTFunk::Table::Cmap::Format04)
+ when 0 then extend(TTFunk::Table::Cmap::Format00)
+ when 4 then extend(TTFunk::Table::Cmap::Format04)
+ when 6 then extend(TTFunk::Table::Cmap::Format06)
+ when 10 then extend(TTFunk::Table::Cmap::Format10)
+ when 12 then extend(TTFunk::Table::Cmap::Format12)
end
parse_cmap!
end
end
def unicode?
- platform_id == 3 && encoding_id == 1 && format == 4 ||
- platform_id == 0 && format == 4
+ platform_id == 3 && (encoding_id == 1 || encoding_id == 10) && format != 0 ||
+ platform_id == 0 && format != 0
end
def supported?
false
end
@@ -75,5 +81,8 @@
end
end
require 'ttfunk/table/cmap/format00'
require 'ttfunk/table/cmap/format04'
+require 'ttfunk/table/cmap/format06'
+require 'ttfunk/table/cmap/format10'
+require 'ttfunk/table/cmap/format12'