diff options
-rw-r--r-- | src/fontloader/misc/fontloader-font-ocl.lua | 60 | ||||
-rw-r--r-- | src/fontloader/runtime/fontloader-basics-gen.lua | 20 | ||||
-rw-r--r-- | src/fontloader/runtime/fontloader-reference.lua | 56 |
3 files changed, 74 insertions, 62 deletions
diff --git a/src/fontloader/misc/fontloader-font-ocl.lua b/src/fontloader/misc/fontloader-font-ocl.lua index 0e415d7..65a1c63 100644 --- a/src/fontloader/misc/fontloader-font-ocl.lua +++ b/src/fontloader/misc/fontloader-font-ocl.lua @@ -14,9 +14,6 @@ local round, max = math.round, math.round local formatters = string.formatters local tounicode = fonts.mappings.tounicode -local graytorgb = attributes.colors.graytorgb -local cmyktorgb = attributes.colors.cmyktorgb - local otf = fonts.handlers.otf local f_color = formatters["pdf:direct:%f %f %f rg"] @@ -50,28 +47,49 @@ end local sharedpalettes = { } -function otf.registerpalette(name,values) - sharedpalettes[name] = values - for i=1,#values do - local v = values[i] - local r, g, b - local s = v.s - if s then - r, g, b = graytorgb(s) - else - local c, m, y, k = v.c, v.m, v.y, v.k - if c or m or y or k then - r, g, b = cmyktorgb(c or 0,m or 0,y or 0,k or 0) +if context then + + local graytorgb = attributes.colors.graytorgb + local cmyktorgb = attributes.colors.cmyktorgb + + function otf.registerpalette(name,values) + sharedpalettes[name] = values + for i=1,#values do + local v = values[i] + local r, g, b + local s = v.s + if s then + r, g, b = graytorgb(s) else - r, g, b = v.r, v.g, v.b + local c, m, y, k = v.c, v.m, v.y, v.k + if c or m or y or k then + r, g, b = cmyktorgb(c or 0,m or 0,y or 0,k or 0) + else + r, g, b = v.r, v.g, v.b + end end + values[i] = { + max(r and round(r*255) or 0,255), + max(g and round(g*255) or 0,255), + max(b and round(b*255) or 0,255) + } end - values[i] = { - max(r and round(r*255) or 0,255), - max(g and round(g*255) or 0,255), - max(b and round(b*255) or 0,255) - } end + +else -- for generic + + function otf.registerpalette(name,values) + sharedpalettes[name] = values + for i=1,#values do + local v = values[i] + values[i] = { + max(round((v.r or 0)*255),255), + max(round((v.g or 0)*255),255), + max(round((v.b or 0)*255),255) + } + end + end + end local function initializecolr(tfmdata,kind,value) -- hm, always value diff --git a/src/fontloader/runtime/fontloader-basics-gen.lua b/src/fontloader/runtime/fontloader-basics-gen.lua index 6aec915..2be55cc 100644 --- a/src/fontloader/runtime/fontloader-basics-gen.lua +++ b/src/fontloader/runtime/fontloader-basics-gen.lua @@ -434,23 +434,3 @@ if arg then end end end - ---- PHG: HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK ---- certain values are missing from attr-col.lua. -local function cmyktorgb(c,m,y,k) - if not c then - return 0, 0, 0, 1 - else - return 1.0 - min(1.0,c+k), 1.0 - min(1.0,m+k), 1.0 - min(1.0,y+k) - end -end - -local function graytorgb(s) -- unweighted - return 1-s, 1-s, 1-s -end - -attributes = attributes or { } -attributes.colors = attributes.colors or { } -attributes.colors.cmyktorgb = cmyktorgb -attributes.colors.graytorgb = graytorgb - diff --git a/src/fontloader/runtime/fontloader-reference.lua b/src/fontloader/runtime/fontloader-reference.lua index c0b4596..c93d2b1 100644 --- a/src/fontloader/runtime/fontloader-reference.lua +++ b/src/fontloader/runtime/fontloader-reference.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 09/23/16 10:13:56 +-- merge date : 09/24/16 12:40:11 do -- begin closure to overcome local limits and interference @@ -23273,8 +23273,6 @@ local tostring,next,format=tostring,next,string.format local round,max=math.round,math.round local formatters=string.formatters local tounicode=fonts.mappings.tounicode -local graytorgb=attributes.colors.graytorgb -local cmyktorgb=attributes.colors.cmyktorgb local otf=fonts.handlers.otf local f_color=formatters["pdf:direct:%f %f %f rg"] local f_gray=formatters["pdf:direct:%f g"] @@ -23298,27 +23296,43 @@ else end end local sharedpalettes={} -function otf.registerpalette(name,values) - sharedpalettes[name]=values - for i=1,#values do - local v=values[i] - local r,g,b - local s=v.s - if s then - r,g,b=graytorgb(s) - else - local c,m,y,k=v.c,v.m,v.y,v.k - if c or m or y or k then - r,g,b=cmyktorgb(c or 0,m or 0,y or 0,k or 0) +if context then + local graytorgb=attributes.colors.graytorgb + local cmyktorgb=attributes.colors.cmyktorgb + function otf.registerpalette(name,values) + sharedpalettes[name]=values + for i=1,#values do + local v=values[i] + local r,g,b + local s=v.s + if s then + r,g,b=graytorgb(s) else - r,g,b=v.r,v.g,v.b + local c,m,y,k=v.c,v.m,v.y,v.k + if c or m or y or k then + r,g,b=cmyktorgb(c or 0,m or 0,y or 0,k or 0) + else + r,g,b=v.r,v.g,v.b + end end + values[i]={ + max(r and round(r*255) or 0,255), + max(g and round(g*255) or 0,255), + max(b and round(b*255) or 0,255) + } + end + end +else + function otf.registerpalette(name,values) + sharedpalettes[name]=values + for i=1,#values do + local v=values[i] + values[i]={ + max(round((v.r or 0)*255),255), + max(round((v.g or 0)*255),255), + max(round((v.b or 0)*255),255) + } end - values[i]={ - max(r and round(r*255) or 0,255), - max(g and round(g*255) or 0,255), - max(b and round(b*255) or 0,255) - } end end local function initializecolr(tfmdata,kind,value) |