[NTG-context] Metafun: Finding intersection between characters

Hans Hagen j.hagen at xs4all.nl
Thu Sep 27 10:49:36 CEST 2018


On 9/26/2018 11:38 PM, Jeong Dal wrote:
> Dear Hans,
> 
>> 2018. 9. 26. 오후 9:24, Hans Hagen <j.hagen at xs4all.nl 
>> <mailto:j.hagen at xs4all.nl>> 작성:
>>
>> On 9/26/2018 2:14 PM, Jeong Dal wrote:
>>> Dear Hans,
>>> I tested for more characters and found an interesting fact.
>>> If the first consonant and the vowels are connected in a glyph, then 
>>> the outlining works OK, otherwise, it makes outline of the first 
>>> consonant only.
>>
>> you need to send a file not embedded .. otherwise the mail agent will 
>> apply magic to korean
>>
>>
> 
> I didn’t think of it.
> I attached a sample file.
attached

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
-------------- next part --------------
\definefontfeature
  [korean-base]
  [goodies=hanbatanglvt,
   colorscheme=default,
   mode=node,
   script=hang,
   language=kor]

\definefont[KoreanFont][hanbatanglvt*korean-base]

\starttext

\startMPdefinitions
    string KoreanColors[] ;

    KoreanColors[1] := "darkred" ;
    KoreanColors[2] := "darkgreen" ;
    KoreanColors[3] := "darkblue" ;
    KoreanColors[4] := "darkyellow" ;
    KoreanColors[5] := "darkgray" ;

    newinternal KoreanSplit ; KoreanSplit := -1 ;
    newinternal KoreanCode  ; KoreanCode  := -2 ;
    newinternal KoreanMode  ; KoreanMode  := KoreanSplit ;

    def KoreanOutline(expr txt) =
        picture p ; p := outlinetext.p(txt) ;
        numeric n ; n := 0 ;
        string old, new ; old := "" ;
        for i within p :
            if KoreanMode == KoreanSplit :
                n := n + 1 ;
            elseif KoreanMode == KoreanCode :
              new := prescriptpart i ;
              if new <> old :
                  old := new ;
                  n := n + 1 ;
              fi ;
            else :
                n := KoreanMode ;
            fi ;
            if unknown KoreanColors[n] :
                n := 1 ;
            fi ;
            draw pathpart i
                withpen pencircle scaled 1/10
                withcolor KoreanColors[n] ;
        endfor ;
    enddef ;

    def KoreanTest(expr txt) =
        KoreanMode  := KoreanSplit ; KoreanOutline(txt) ;
        currentpicture := currentpicture shifted (- xpart urcorner currentpicture, 0);
        KoreanMode  := KoreanCode ; KoreanOutline(txt) ;
        currentpicture := currentpicture shifted (- xpart urcorner currentpicture, 0);
        KoreanMode  := 3 ; KoreanOutline(txt) ;
    enddef ;

\stopMPdefinitions

% entered as three characters: ᄅ  ᅡ  ᆺ (mail collapses)

\startMPpage
    KoreanTest("\KoreanFont 랏") ;
\stopMPpage
\startMPpage
    KoreanTest("\KoreanFont 랏") ;
\stopMPpage
\startMPpage
    KoreanTest("\KoreanFont 논") ;
\stopMPpage
\startMPpage
    KoreanTest("\KoreanFont 왕") ;
\stopMPpage
\startMPpage
    KoreanTest("\KoreanFont 닭") ;
\stopMPpage
\startMPpage
    KoreanTest("\KoreanFont 박") ;
\stopMPpage
\startMPpage
    KoreanTest("\KoreanFont 서") ;
\stopMPpage

\stoptext


More information about the ntg-context mailing list