ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Left hanging hyphen
@ 2020-03-02 11:22 Tomas Hala
  2020-03-02 16:38 ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Tomas Hala @ 2020-03-02 11:22 UTC (permalink / raw)
  To: Mailing list ConTeXt

Hi all,

in composed words in Czech and Slovak languages, the hyphen must be repeated 
at the beginning of the new line. How can I make it hanging at the left margin?

Tomáš


% for repeating the hyphen
\definebreakpoints[czcompound]
\definebreakpoint[czcompound][-][nleft=3,nright=3,type=4]
\def\mylanguage{cs} \appendtoks \ifx\mylanguage\currentlanguage \setbreakpoints[czcompound] \else \resetbreakpoints \fi \to\everylanguage 
\def\mylanguage{sk} \appendtoks \ifx\mylanguage\currentlanguage \setbreakpoints[czcompound] \else \resetbreakpoints \fi \to\everylanguage

\starttext\showframe
\hsize1dd
modro-zelený  %blue-green
\stoptext

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Left hanging hyphen
  2020-03-02 11:22 Left hanging hyphen Tomas Hala
@ 2020-03-02 16:38 ` Wolfgang Schuster
  2020-03-04 18:28   ` Tomas Hala
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2020-03-02 16:38 UTC (permalink / raw)
  To: ntg-context

On Mon, 2 Mar 2020 12:22:26 +0100
Tomas Hala <tomas.hala@mendelu.cz> wrote:

> Hi all,
> 
> in composed words in Czech and Slovak languages, the hyphen must be repeated 
> at the beginning of the new line. How can I make it hanging at the left margin?

1. You have to enable hanging punctuation which is missing in your example.

2. You have to create your own protrusion vector because the predefined vectors set hanging for hyphens only for the right margin.

The following example uses code shown in the fonts manual (fonts-mkiv.pdf) to create a custom protrusion vector:

%%%% begin example

\startluacode

fonts.protrusions.classes.tomas_hala = {
    vector = 'tomas_hala',
    factor = 1,
}

fonts.protrusions.vectors.tomas_hala = table.merged (
    fonts.protrusions.vectors.quality,
    {
        [0x002D] = { 0.4, 0.7 }, -- hyphen
    }
)

\stopluacode

\definebreakpoints [czcompound]

\definebreakpoint [czcompound] [-] [nleft=3,nright=3,type=4]

\startsetups [czech]
  \setbreakpoints [czcompound]
\stopsetups

\setuplanguage
  [cz]
  [setups=czech]

\definefontfeature [default] [default] [protrusion=tomas_hala]

\setupalign [hanging]

\mainlanguage [cz]

\showframe [text] [text]

\starttext

\hsize=0pt

modro-zelený

\stoptext
%%%% end example

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Left hanging hyphen
  2020-03-02 16:38 ` Wolfgang Schuster
@ 2020-03-04 18:28   ` Tomas Hala
  2020-03-04 18:56     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Tomas Hala @ 2020-03-04 18:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

Mon, Mar 02, 2020 ve 05:38:35PM +0100 Wolfgang Schuster napsal(a):
# On Mon, 2 Mar 2020 12:22:26 +0100
# Tomas Hala <tomas.hala@mendelu.cz> wrote:
# 
# > Hi all,
# > 
# > in composed words in Czech and Slovak languages, the hyphen must be repeated 
# > at the beginning of the new line. How can I make it hanging at the left margin?
# 
# 1. You have to enable hanging punctuation which is missing in your example.

I used it, it was a miscopying... sorry.
 
# 2. You have to create your own protrusion vector because the predefined vectors set hanging for hyphens only for the right margin.

Thanks, it works for Czech language. But what has happened is that the
repeated hyphen appears also with languages which do not use it (or for
which it has not been set).

How can I assign the definition only to the selected language?
(I discovered only to put {\mainlanguage[cz]text} into a group...)

%% only a note:
I tried:
\def\mylanguage{cs} \appendtoks \ifx\mylanguage\currentlanguage \setbreakpoints[czcompound] \else \resetbreakpoints \fi \to\everylanguage

\let\ORIGmainlanguage=\mainlanguage 
\def\mainlanguage[#1]{\def\langpar{#1}
  \def\langpom{cz}\ifx\langpom\langpar\gdef\mylanguage{cs}\else\gdef\mylanguage{\langpar}\fi 
  \ORIGmainlanguage[\langpar]
}

which repeats only the Czech hyphen but with a side effect -- hyphenated words are not broken anymore in other languages.
What am I doing wrong? Or is there any system solution?
%%

Best wishes,

Tomáš


%%%% begin example

\startluacode

fonts.protrusions.classes.tomas_hala = {
    vector = 'tomas_hala',
    factor = 1,
}

fonts.protrusions.vectors.tomas_hala = table.merged (
    fonts.protrusions.vectors.quality,
    {
        [0x002D] = { 0.4, 0.7 }, -- hyphen
    }
)

\stopluacode

\definebreakpoints [czcompound]
\definebreakpoint [czcompound] [-] [nleft=3,nright=3,type=4]

\startsetups [czech]
  \setbreakpoints [czcompound]
\stopsetups

\setuplanguage
  [cz]
  [setups=czech]

\definefontfeature [default] [default] [protrusion=tomas_hala]

%\def\mylanguage{cs} \appendtoks \ifx\mylanguage\currentlanguage \setbreakpoints[czcompound] \else \resetbreakpoints \fi \to\everylanguage
%\def\mylanguage{sk} \appendtoks \ifx\mylanguage\currentlanguage \setbreakpoints[czcompound] \else \resetbreakpoints \fi \to\everylanguage
%
%\let\ORIGmainlanguage=\mainlanguage
%\def\mainlanguage[#1]{\def\langpar{#1}
%
%\def\langpom{cz}\ifx\langpom\langpar\gdef\mylanguage{cs}\else\gdef\mylanguage{\langpar}\fi
%  \ORIGmainlanguage[\langpar]
%}


\setupalign [hanging]

%\mainlanguage [cz]

\showframe [text] [text]

\starttext

\hsize=0pt

\mainlanguage [en]
modro-zelený

\mainlanguage [fr]
modro-zelený

\mainlanguage [cz]
modro-zelený

\mainlanguage [en]
modro-zelený

\mainlanguage [fr]
modro-zelený

\stoptext
%%%% end example
 
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Left hanging hyphen
  2020-03-04 18:28   ` Tomas Hala
@ 2020-03-04 18:56     ` Wolfgang Schuster
  2020-03-05 15:29       ` Tomas Hala
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2020-03-04 18:56 UTC (permalink / raw)
  To: ntg-context

On Wed, 4 Mar 2020 19:28:49 +0100
Tomas Hala <tomas.hala@mendelu.cz> wrote:

> Hi Wolfgang,
> 
> Mon, Mar 02, 2020 ve 05:38:35PM +0100 Wolfgang Schuster napsal(a):
> # On Mon, 2 Mar 2020 12:22:26 +0100
> # Tomas Hala <tomas.hala@mendelu.cz> wrote:
> # 
> # > Hi all,
> # > 
> # > in composed words in Czech and Slovak languages, the hyphen must be repeated 
> # > at the beginning of the new line. How can I make it hanging at the left margin?
> # 
> # 1. You have to enable hanging punctuation which is missing in your example.
> 
> I used it, it was a miscopying... sorry.
>  
> # 2. You have to create your own protrusion vector because the predefined vectors set hanging for hyphens only for the right margin.
> 
> Thanks, it works for Czech language. But what has happened is that the
> repeated hyphen appears also with languages which do not use it (or for
> which it has not been set).
> 
> How can I assign the definition only to the selected language?
> (I discovered only to put {\mainlanguage[cz]text} into a group...)
> 
> %% only a note:
> I tried:
> \def\mylanguage{cs} \appendtoks \ifx\mylanguage\currentlanguage \setbreakpoints[czcompound] \else \resetbreakpoints \fi \to\everylanguage
> 
> \let\ORIGmainlanguage=\mainlanguage 
> \def\mainlanguage[#1]{\def\langpar{#1}
>   \def\langpom{cz}\ifx\langpom\langpar\gdef\mylanguage{cs}\else\gdef\mylanguage{\langpar}\fi 
>   \ORIGmainlanguage[\langpar]
> }
> 
> which repeats only the Czech hyphen but with a side effect -- hyphenated words are not broken anymore in other languages.
> What am I doing wrong? Or is there any system solution?
> %%
> 
> Best wishes,
> 
> Tomáš
> 
> 
> %%%% begin example
> 
> \startluacode
> 
> [...]
> 
> \startsetups [czech]
>   \setbreakpoints [czcompound]
> \stopsetups
> 
> \setuplanguage
>   [cz]
>   [setups=czech]

You can use the default language for the reset:

\startsetups [language:czech]
  \setbreakpoints [czcompound]
\stopsetups

\startsetups [language:other]
  \resetbreakpoints
\stopsetups

\setuplanguage
  [cz]
  [setups=language:czech]

\setuplanguage
  [default]
  [setups=language:other]

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Left hanging hyphen
  2020-03-04 18:56     ` Wolfgang Schuster
@ 2020-03-05 15:29       ` Tomas Hala
  0 siblings, 0 replies; 5+ messages in thread
From: Tomas Hala @ 2020-03-05 15:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

# You can use the default language for the reset:
# 
# \startsetups [language:czech]
#   \setbreakpoints [czcompound]
# \stopsetups
# 
# \startsetups [language:other]
#   \resetbreakpoints
# \stopsetups
# 
# \setuplanguage
#   [cz]
#   [setups=language:czech]
# 
# \setuplanguage
#   [default]
#   [setups=language:other]

I used these definitions and it works really better, the hyphen is not
repeated in other languages anymore, thanks for this setting.
Unfortunately, two side-effects appeared after switching language back to uk:

* after the hyphen, no linebreak seems to be allowed,
* hyphenation patterns have been applied on the composed word, while before switching (default) not.

Tested with TL2019 as well as with the newest.

How can these side-effects be suppressed? 

Tomáš


%%%%%%%%%%%%%%%%%%%%%% MWE
\startluacode
fonts.protrusions.classes.tomas_hala = {
    vector = 'tomas_hala',
    factor = 1,
}

fonts.protrusions.vectors.tomas_hala = table.merged (
    fonts.protrusions.vectors.quality,
    {
        [0x002D] = { 0.4, 0.7 }, -- hyphen
    }
)

\stopluacode

\definebreakpoints [czcompound]
\definebreakpoint [czcompound] [-] [nleft=3,nright=3,type=4]

\startsetups [language:czech]
  \setbreakpoints [czcompound]
\stopsetups
\startsetups [language:other]
  \resetbreakpoints
\stopsetups

\setuplanguage[cz][setups=language:czech]
\setuplanguage[default][setups=language:other]
\definefontfeature [default] [default] [protrusion=tomas_hala]
\setupalign [hz,hanging]

\showframe [text] [text]
\starttext
\hsize=1pt

\mainlanguage [uk] {\bf uk}
	modro-zelený
	\hyphenatedpar{Stratford Stratford-upon-Avon}  

\mainlanguage [cz] {\bf cz}
	modro-zelený
	\hyphenatedpar{Stratford Stratford-upon-Avon}

\mainlanguage [uk] {\bf uk} 
	modro-zelený
	\hyphenatedpar{uk Stratford Stratford-upon-Avon}

\stoptext
%%%%%%%%%%%%%%%%%%%% RESULT
uk
modro-
zelený
Strat-
ford
Stratford-
upon-
Avon
cz
modro-
-ze-
lený
Strat-
ford
Strat-
ford-
-upon-
-Avon
uk
modro-zelený
uk
Strat-
ford
Strat-
ford-upon-Avon
%%%%%%%%%%%%%%%%%% END
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-05 15:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 11:22 Left hanging hyphen Tomas Hala
2020-03-02 16:38 ` Wolfgang Schuster
2020-03-04 18:28   ` Tomas Hala
2020-03-04 18:56     ` Wolfgang Schuster
2020-03-05 15:29       ` Tomas Hala

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).