ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: ConTeXt ML <ntg-context@ntg.nl>
Subject: Re: [luatex-plain] loading patterns
Date: Wed, 14 Nov 2012 20:15:16 +0100	[thread overview]
Message-ID: <50A3EDC4.4060707@wxs.nl> (raw)
In-Reply-To: <20121114181243.GA5809@tartaros>

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

On 11/14/2012 7:12 PM, Philipp Gesang wrote:

you need to set some lccodes

assuming that you also use the font loader (i.e. luatex-plain), try the 
attached files ... the next then works ok

\font\test=dejavuserif at 10pt  \test

\hsize 1mm

\noindent Циолковский

\loadpatterns{ru}

\noindent Циолковский

\end

It uses the pattern files that come with context.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: luatex-languages.lua --]
[-- Type: text/plain, Size: 1701 bytes --]

if not modules then modules = { } end modules ['luatex-languages'] = {
    version   = 1.001,
    comment   = "companion to luatex-languages.tex",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- We borrow fron ConTeXt.

languages = languages or { }

local loaded = { }

function languages.loadpatterns(tag)
    if not loaded[tag] then
        loaded[tag] = 0
        local filename = kpse.find_file("lang-" .. tag .. ".lua")
        if filename and filename == "" then
            print("<unknown language file for: " .. tag .. ">")
        else
            local whatever = loadfile(filename)
            if type(whatever) == "function" then
                whatever = whatever()
                if type(whatever) == "table" then
                    local characters = whatever.patterns.characters or ""
                    local patterns = whatever.patterns.data or ""
                    local exceptions = whatever.exceptions.data or ""
                    local language = lang.new()
                    for b in string.utfvalues(characters) do
                        tex.setlccode(b,b)
                    end
                    lang.patterns(language, patterns)
                    lang.hyphenation(language, exceptions)
                    loaded[tag] = lang.id(language)
                else
                    print("<invalid language table: " .. tag .. ">")
                end
            else
                print("<invalid language file: " .. tag .. ">")
            end
        end
    end
    return loaded[tag]
end

[-- Attachment #3: luatex-languages.tex --]
[-- Type: text/plain, Size: 476 bytes --]

%D \module
%D   [       file=luatex-fonts,
%D        version=2009.12.01,
%D          title=\LUATEX\ Support Macros,
%D       subtitle=Generic \OPENTYPE\ Font Handler,
%D         author=Hans Hagen,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]

%D Cf. discussion on \CONTEXT\ list:

\directlua {
    dofile(kpse.find_file("luatex-languages.lua","tex"))
}

\def\loadpatterns#1{\directlua{tex.language = languages.loadpatterns("#1")}}

\endinput

[-- Attachment #4: luatex-plain.tex --]
[-- Type: text/plain, Size: 585 bytes --]

%D \module
%D   [       file=luatex-plain,
%D        version=2009.12.01,
%D          title=\LUATEX\ Macros,
%D       subtitle=Plain Format,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]

\input plain

\directlua {tex.enableprimitives('', tex.extraprimitives())}

\pdfoutput=1

\everyjob \expandafter {%
    \the\everyjob
    \input {luatex-basics}%
    \input {luatex-fonts}%
    \input {luatex-languages}%
    \input {luatex-mplib}%
}

\edef\fmtversion{\fmtversion+luatex}

\dump

[-- Attachment #5: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2012-11-14 19:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-14 18:12 Philipp Gesang
2012-11-14 19:15 ` Hans Hagen [this message]
2012-11-15 13:57   ` Philipp Gesang
2012-11-15 14:51     ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50A3EDC4.4060707@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).