View Issue Details

IDProjectCategoryView StatusLast Update
0000931luatexluatex bugpublic2015-09-11 22:07
ReporterDohyun Kim Assigned ToHans Hagen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0000931: wrong glyph mapping upon using some CID-Keyed OpenType fonts
DescriptionFor instance, with this CID-Keyed font:
  https://github.com/adobe-fonts/source-han-sans/raw/release/SubsetOTF/KR/SourceHanSansKR-Light.otf

the input string "鹿" (U+9E7F) is currently reprensented as "丱" (U+4E31) in the resulting PDF file. The following file was tested with luatex-plain:
%%%%%
\font\shskr=SourceHanSansKR-Light.otf
\shskr 鹿
\end
%%%%%%

Steps To ReproduceA simple lua code (run with texlua):
-----
local shskr
local font = fontloader.open("./SourceHanSansKR-Light.otf")
if font then
  shskr = fontloader.to_table(font)
  fontloader.close(font)
end

local utfchar = unicode.utf8.char
local deer_uni = 0x9E7F
print("deer unicode:", deer_uni, utfchar(deer_uni))

local deer_gid = shskr.map.map[deer_uni]
print("deer glyph id:", deer_gid)
for i,v in ipairs(shskr.subfonts) do
  local deer = v.glyphs[deer_gid]
  if deer then
    local deer_uni = deer.unicode
    print("deer glyph unicode:",deer_uni, utfchar(deer_uni))
  end
end
-----
will print out the followings:

deer unicode: 40575 鹿
deer glyph id: 9900
deer glyph unicode: 20017 丱
Additional InformationThe font data returned by luatex engine has a glyph table apparently arranged by CID numbers, which is wrong. The index of glyph table should be an array of GID, where no vacancies in-between is allowed.

In most CID-Keyed OpenType fonts, CIDs are indentical to GIDs. So no problem with current behaviour of luatex. The font used above, however, has many glyphs of which the GID is not identical to its CID, raising the issue to the surface.
TagsNo tags attached.

Activities

Hans Hagen

2015-04-18 14:23

manager   ~0001355

ok, so this is why context sees them as duplicates (i always wondered how that could happen)

Hans

luigi scarso

2015-05-19 09:02

developer   ~0001376

We have a patch now in experimental, rev. 5249.

Hans Hagen

2015-05-19 12:09

manager   ~0001377

also need an adaption in the fontloader so best wait with testing till we're ready (also fixing some other issues)

Hans Hagen

2015-05-21 13:44

manager   ~0001382

this is what has been done:

- we have enabled the orig_pos field to get the orginal index
- we introduced a minglyph field in the subfonts
- maxglyph now indicates the upper index, so one should loop over glyphmin upto glyphmax
- glyphcnt reflexts the number of glyphs (for testing as min and max can be both zero)
- the table format has been bumped to 0.4

- the context fontloader code knows how to deal with this

Hans Hagen

2015-09-11 22:07

manager   ~0001398

implemented

Issue History

Date Modified Username Field Change
2015-04-18 07:21 Dohyun Kim New Issue
2015-04-18 14:23 Hans Hagen Note Added: 0001355
2015-05-14 13:27 Hans Hagen Assigned To => Hans Hagen
2015-05-14 13:27 Hans Hagen Status new => assigned
2015-05-19 09:02 luigi scarso Note Added: 0001376
2015-05-19 12:09 Hans Hagen Note Added: 0001377
2015-05-21 13:44 Hans Hagen Note Added: 0001382
2015-09-11 22:07 Hans Hagen Note Added: 0001398
2015-09-11 22:07 Hans Hagen Status assigned => closed
2015-09-11 22:07 Hans Hagen Resolution open => fixed