class HexaPDF::Font::CMap::Parser

def parse_bf_range(tokenizer, cmap)

++
"endCode" have to be the same. So it seems that this is a mistake in the PDF reference.
Additionally, #5411 mentions in section 1.4.1 that the first byte of "startCode" and

this.
of 255. However #5411 has the range "<1379> <137B> <90FE>" as example which contradicts
PDF2.0 mentions that the last byte of "codePoint" should be incremented, up to a maximum

operators of the form "startCode endCode codePoint" should be handled.
PDF2.0 s9.10.3 and Adobe Technical Note #5411 have different views as to how "bfrange"
--

Parses the "bfrange" operator at the current position.
def parse_bf_range(tokenizer, cmap)
  until (code1 = tokenizer.next_token).kind_of?(HexaPDF::Tokenizer::Token)
    code1 = bytes_to_int(code1)
    code2 = bytes_to_int(tokenizer.next_token)
    dest = tokenizer.next_object
    if dest.kind_of?(String)
      codepoint = dest.force_encoding(::Encoding::UTF_16BE).ord
      code1.upto(code2) do |code|
        cmap.add_unicode_mapping(code, +'' << codepoint)
        codepoint += 1
      end
    elsif dest.kind_of?(Array)
      code1.upto(code2) do |code|
        str = dest[code - code1].encode!(::Encoding::UTF_8, ::Encoding::UTF_16BE)
        cmap.add_unicode_mapping(code, str)
      end
    else
      raise HexaPDF::Error, "Invalid bfrange operator in CMap"
    end
  end
end