Re: [NTG-context] Dotted characters

2016-08-20 Thread Wolfgang Schuster

Lukáš Procházka 
20. August 2016 um 14:03
Hello again,

the dotted font works perfectly.

I'm using Lua to generate sheets from a database which contains 
word-picture-picture2 records (see attached single page sample; I had 
to convert the image to .jpg to reduce file size).


One more question - is there a ConTeXt/Lua function which would assign 
a non-diacritical-character to that with diacritics, like:


Á => A
Š => S
Ý => Y etc.?

I'm asking as the "Trace Font for Kids" doesn't contain characters 
with diacritics...


Simple Lua table would do the job, like


remove_dia_czech =
{ ["é"] = "e",
  ["š"] = "s",
  ...
}


But string pattern in Lua with cp1250/UTF-8 might not be so easy as 
Lua pattern "." matches single char (or - better - one byte - I 
guess), so with UTF-8, chars with diacritics need more bytes; so the code



str = ("Řetězec with diacritics"):gsub(".", remove_dia_czech)


probably won't work.

And Ctx Lua could have a mechanism already...
You can use the “characters.shaped” function which is described in 
cld-mkiv.pdf at page 87 and 119.


\starttext
Řetězec = \cldcontext{characters.shaped("Řetězec")}
\stoptext

Wolfgang
___
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
___

Re: [NTG-context] Dotted characters

2016-08-20 Thread Lukáš Procházka

Hello again,

the dotted font works perfectly.

I'm using Lua to generate sheets from a database which contains 
word-picture-picture2 records (see attached single page sample; I had to 
convert the image to .jpg to reduce file size).

One more question - is there a ConTeXt/Lua function which would assign a 
non-diacritical-character to that with diacritics, like:

Á => A
Š => S
Ý => Y etc.?

I'm asking as the "Trace Font for Kids" doesn't contain characters with 
diacritics...

Simple Lua table would do the job, like


remove_dia_czech =
{ ["é"] = "e",
  ["š"] = "s",
  ...
}


But string pattern in Lua with cp1250/UTF-8 might not be so easy as Lua pattern 
"." matches single char (or - better - one byte - I guess), so with UTF-8, 
chars with diacritics need more bytes; so the code


str = ("Řetězec with diacritics"):gsub(".", remove_dia_czech)


probably won't work.

And Ctx Lua could have a mechanism already...

Best regards,

Lukas

On Tue, 16 Aug 2016 09:43:12 +0200, Taco Hoekwater  wrote:


there is no easy way to convert that into a dotted line that matches the ‘black 
parts’ of the glyph shape. Perhaps you could use two regular fonts: one 
sans-serif and one with dotted lines? There are some free fonts with dotted 
lines that can be found on the web, e.g. here: 
http://www.fontspace.com/category/dotted-line

Best wishes,
Taco



--
Ing. Lukáš Procházka | mailto:l...@pontex.cz
Pontex s. r. o.  | mailto:pon...@pontex.cz | http://www.pontex.cz | 
IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751 (+420 720 951 172)
Fax: +420 244 461 038___
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
___

Re: [NTG-context] \getscaledglyph for width-only

2016-08-20 Thread Hans Hagen

On 8/18/2016 6:30 PM, Brian R. Landy wrote:



On Thu, 18 Aug 2016, Hans Hagen wrote:


On 8/18/2016 1:12 AM, Brian R. Landy wrote:



On Aug 17, 2016, at 5:45 PM, Hans Hagen  wrote:

On 8/17/2016 9:56 PM, Brian R. Landy wrote:

Hi, I was wondering if there is a way to call \getscaledglyph to
scale a
glyph only horizontally, leaving the height untouched?  Or maybe an
alternate command?

I can sort of accomplish this with (for example)
\scale[sx=0.75,sy=1.0]{}{A}, but that encloses the glyph in an \hbox,
which can be problematic.  \getscaledglyph doesn't cause me any
problems, except that it scales the height too.


\starttext

\definefontfeature[whatever][default][extend=2.5]

\definedfont[Serif*whatever at 12pt]

whatever

\stoptext



Thank you.  One thing that \getscaledglyph does it works agnostic to
the currently selected font.  For example:


scaling glyphs in one direction is kind of bad anyway so if you want
just one glyph you can do

\inframed{\scale[width=3em,height=1ex]{...}}

or whatever suits the purpose


Agreed.  Here's a little more background, so it makes some sense why I
want to scale horizontally, and then I describe my final solution.  I
have a specific case where I use a minus, a hyphen-minus, and a plus
close to each other, and it's always bugged me that most fonts don't
vertically align the hyphen-minus with the other two glyphs. An example is:

  {\normalUchar"2212}100-00+

I was thinking that math fonts did align these symbols, hence my
question on Monday on how to get the hyphen-minus in math mode (and
thanks for the quick answer on that) but unfortunately was wrong.  So
that got me searching for a way to horizontally shrink a minus, so it
would retain the same height and line thickness as the minus.
Horizontal-only scaling of a hyphen/dash/minus isn't so bad.

\scaled[] worked perfectly, but it breaks inside a natural table with
character alignment enabled.  I have a commented example of this below.
\getscaledglyph works in the table, but the vertical shrink is a
non-starter.

Here's an example:

\edef\mathminus{\normalUchar"2212}
\edef\smallminus{\getscaledglyph{0.33}{}{\normalUchar"2212}}
\starttext

This is my starting point:

\bTABLE[aligncharacter=yes,alignmentcharacter={text->-}]
\bTR \bTD \mathminus100-00+ \eTD \eTR
\bTR \bTD   100-00  \eTD \eTR
\bTR \bTD \mathminus 99-00+ \eTD \eTR
\bTR \bTD \mathminus 99-00  \eTD \eTR
\eTABLE

% This table won't typeset:
%
% \bTABLE[aligncharacter=yes,alignmentcharacter={text->:}]
% \bTR \bTD \mathminus100\scaled[sx=0.5,sy=1.0]{\mathminus}00:+ \eTD \eTR
% \bTR \bTD   100\scaled[sx=0.5,sy=1.0]{\mathminus}00:  \eTD \eTR
% \bTR \bTD \mathminus 99\scaled[sx=0.5,sy=1.0]{\mathminus}00:+ \eTD \eTR
% \bTR \bTD \mathminus 99\scaled[sx=0.5,sy=1.0]{\mathminus}00:  \eTD \eTR
% \eTABLE

\stoptext

But I came up with a solution that works.  Rather than attempt to shrink
the minus glyph, I define a new glyph that corrects the height of the
hyphen-minus:

\startluacode
 local function addsmallminus(tfmdata)
 local hchar= tfmdata.characters[0x002D]
 local mchar= tfmdata.characters[0x2212]
 tfmdata.characters[0xFE000]   = {
 width= hchar.width,
 height   = mchar.height,
 commands = {
 { "down", hchar.height-mchar.height },
 { "char", 0x002D },
 }
 }
 end

 fonts.constructors.newfeatures("otf").register {
 name= "smallminus",
 description = "small minus",
 manipulators = {
 base = addsmallminus,
 node = addsmallminus,
 }
 }

\stopluacode

\definefontfeature[default][default][smallminus=yes]
\edef\smallminus{\normalUchar"FE000}

\starttext

\bTABLE[aligncharacter=yes,alignmentcharacter={text->\smallminus}]
\bTR \bTD \mathminus100\smallminus00+ \eTD \eTR
\bTR \bTD   100\smallminus00  \eTD \eTR
\bTR \bTD \mathminus 99\smallminus00+ \eTD \eTR
\bTR \bTD \mathminus 99\smallminus00  \eTD \eTR
\eTABLE

\stoptext

So this looks good and works with any font.  The only issue is fonts
that use a different line thickness for the minus and hyphen-minus; this
top-aligns the glyphs.

Is there a way to make this glyph available in math-mode?  I get a "?"
when I try:

\math{\smallminus}
\math{\mathchar"FE000}

Thanks for all your help!


One problem with your approach is that you can never know if that 
private slot isn't already used. This can be avoided with


\startluacode
local function addsmallminus(tfmdata)
local hchar = tfmdata.characters[0x002D]
local mchar = tfmdata.characters[0x2212]
if hchar and mchar then
fonts.helpers.addprivate(tfmdata, "smallminus", {
width= hchar.width,
height   = mchar.height,
commands = {
{ "down", hchar.height - mchar.height },
{ "char", 0x002D },
}

Re: [NTG-context] columnset and placefigure

2016-08-20 Thread Wolfgang Schuster

Hans Hagen 
19. August 2016 um 23:51


best do your experiments with the new column sets (put this on top of 
your file for now:


\input page-cst.mkiv

The new code can also be loaded as a module with

\usemodule[newcolumnsets]

Wolfgang
___
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
___

Re: [NTG-context] Windows 10, TeXLive 2016, and grep

2016-08-20 Thread Hans Hagen

On 8/20/2016 3:08 AM, Br. Samuel Springuel wrote:

I'm looking particularly for the `-m #` (return only first # matches)
and `-o` (return only the portion of the line which matches), with the
latter being more important than the former.

I have a line in a Unix script (where I can expect standard grep to be
available) which looks like this:

grep -m 1 'GREGORIO_VERSION' $loc | grep -o
'[0-9]*\.[0-9]*\.[0-9]*-*[betarc]*[0-9]*' >> $OUTPUT 2>&1

Basically the script is supposed to identify which version of a file in
our package is a person has.  To do this it looks for the first line in
a file ($loc) which is marked as containing the version number (by
looking for the text of the comment which we use to mark those lines for
scripting purposes) and then extract the version number from that line
(by looking for the pattern which the version number follows).

In Windows, I can do the first part of this command with `findstr` (a
native command which has similar, but not identical, functionality to
grep, but cannot do the second at all.  My current work around is to use
the characters which precede and follow the version number to trim the
string, but this requires me to have repetitive code because not all the
files in our package use the same delimiting characters.  What I
accomplish in one `for` loop in the Unix version (looping over a list of
the files in our package), I need three loops to do in Windows (breaking
the list up by the delimiting characters).  Having `mtxrun -script grep`
support the `-o` option would enable me to consolidate and simplify the
code.


I'll add -n=1 (--first) and --match

>rgrep --pattern="modules.-%['(.-)'%]" char-*.lua --first --match

which returns (on my machine)

char-act
char-cjk
char-def
char-enc
char-ent
char-fio
char-ini
char-map
char-rep
char-tex
char-utf

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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
___

Re: [NTG-context] Windows 10, TeXLive 2016, and grep

2016-08-20 Thread Br. Samuel Springuel
I'm looking particularly for the `-m #` (return only first # matches) 
and `-o` (return only the portion of the line which matches), with the 
latter being more important than the former.


I have a line in a Unix script (where I can expect standard grep to be 
available) which looks like this:


grep -m 1 'GREGORIO_VERSION' $loc | grep -o 
'[0-9]*\.[0-9]*\.[0-9]*-*[betarc]*[0-9]*' >> $OUTPUT 2>&1


Basically the script is supposed to identify which version of a file in 
our package is a person has.  To do this it looks for the first line in 
a file ($loc) which is marked as containing the version number (by 
looking for the text of the comment which we use to mark those lines for 
scripting purposes) and then extract the version number from that line 
(by looking for the pattern which the version number follows).


In Windows, I can do the first part of this command with `findstr` (a 
native command which has similar, but not identical, functionality to 
grep, but cannot do the second at all.  My current work around is to use 
the characters which precede and follow the version number to trim the 
string, but this requires me to have repetitive code because not all the 
files in our package use the same delimiting characters.  What I 
accomplish in one `for` loop in the Unix version (looping over a list of 
the files in our package), I need three loops to do in Windows (breaking 
the list up by the delimiting characters).  Having `mtxrun -script grep` 
support the `-o` option would enable me to consolidate and simplify the 
code.

--
✝
Br. Samuel, OSB
St. Anselm’s Abbey
Washington, DC
(R. Padraic Springuel)

PAX ☧ ΧΡΙΣΤΟΣ
___
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
___