Skip to content

Commit cb7321d

Browse files
committed
Fix when a char is not found in CMap
1 parent 1979381 commit cb7321d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/PDFonts.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ function get_encoded_string(s::CosString, fum::FontUnicodeMapping)
118118
carr = NativeEncodingToUnicode(Vector{UInt8}(s), fum.encoding)
119119
return String(carr)
120120
end
121-
# {UInt8, CosObject}
122121

123122
function get_unicode_chars(b::UInt8, itv::IntervalValue)
124123
f = first(itv)
@@ -194,8 +193,12 @@ function get_encoded_string(s::CosString, cmap::CMap)
194193
else
195194
b2 = barr[i+=1]
196195
itree1 = value(collect(intersect(rm, (b1,b1)))[1])
197-
itv = collect(intersect(itree1, (b2,b2)))[1]
198-
carr = get_unicode_chars(b2, itv)
196+
itv = collect(intersect(itree1, (b2,b2)))
197+
if length(itv) > 0
198+
carr = get_unicode_chars(b2, itv[1])
199+
else
200+
push!(carr, Char(0))
201+
end
199202
end
200203
append!(retarr, carr)
201204
end

0 commit comments

Comments
 (0)