diff options
author | Karl Berry <karl@freefriends.org> | 2013-05-13 22:15:54 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-05-13 22:15:54 +0000 |
commit | 1ff28b17fa5479687257ee4525e3a06c8aa0a2c7 (patch) | |
tree | 22d0f15f3680a26ce6a158e96b25bf1908471b9e /Master/texmf-dist/tex/latex/polyglossia/polyglossia.lua | |
parent | e26fdd32ad8dc28823e2f351c31afa0dad690da9 (diff) |
polyglossia (13may13)
git-svn-id: svn://tug.org/texlive/trunk@30442 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/polyglossia/polyglossia.lua')
-rw-r--r-- | Master/texmf-dist/tex/latex/polyglossia/polyglossia.lua | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/polyglossia/polyglossia.lua b/Master/texmf-dist/tex/latex/polyglossia/polyglossia.lua new file mode 100644 index 00000000000..96f2341519a --- /dev/null +++ b/Master/texmf-dist/tex/latex/polyglossia/polyglossia.lua @@ -0,0 +1,77 @@ +require('luatex-hyphen') + +local luatexhyphen = luatexhyphen +local byte = unicode.utf8.byte + +local polyglossia_module = { + name = "polyglossia", + version = 1.3, + date = "2013/05/11", + description = "Polyglossia", + author = "Elie Roux", + copyright = "Elie Roux", + license = "CC0" +} + +local error, warning, info, log = + luatexbase.provides_module(polyglossia_module) + +polyglossia = polyglossia or {} +local polyglossia = polyglossia + +local current_language +local default_language + +local function loadlang(lang, id) + if luatexhyphen.lookupname(lang) then + luatexhyphen.loadlanguage(lang, id) + end +end + +local function select_language(lang, id) + loadlang(lang, id) + polyglossia.current_language = lang +end + +local function set_default_language(lang, id) + polyglossia.default_language = lang +end + +local check_char + +if luaotfload and luaotfload.aux and luaotfload.aux.font_has_glyph then + local font_has_glyph = luaotfload.aux.font_has_glyph + function check_char(chr) + local codepoint = tonumber(chr) + if not codepoint then codepoint = byte(chr) end + if font_has_glyph(font.current(), codepoint) then + tex.sprint('1') + else + tex.sprint('0') + end + end +else + local ids = fonts.identifiers or fonts.ids or fonts.hashes.identifiers + function check_char(chr) -- always in current font + local otfdata = ids[font.current()].characters + local codepoint = tonumber(chr) + if not codepoint then codepoint = byte(chr) end + if otfdata and otfdata[codepoint] then + tex.print('1') + else + tex.print('0') + end + end +end + +local function load_frpt() + require('polyglossia-frpt') +end + +polyglossia.loadlang = loadlang +polyglossia.select_language = select_language +polyglossia.set_default_language = set_default_language +polyglossia.current_language = current_language -- doesn't seem to be working well :-( +polyglossia.default_language = default_language +polyglossia.check_char = check_char +polyglossia.load_frpt = load_frpt |