adityam / filter

ConTeXt module to process contents of a start-stop environment through an external program
45 stars 10 forks source link

t-vim: Problem with hyphens (TeX ligatures present in teletype fonts) #26

Closed Goshik92 closed 5 years ago

Goshik92 commented 5 years ago

When my code contains multiple hyphens in a row, they are replaced with longer dashes. For example, in C code instead of i-- I have i–. Some of my comments also look incorrectly:

/*———————————————————————————-
* File: main.c
* Function: foo
* Description: bar
...

instead of

/*----------------------------------------------------------------------------------
* File: main.c
* Function: foo
* Description: bar
...

Is there a way to control this or is it a bug?

adityam commented 5 years ago

This is most likely due to a font misconfiguration. Can you post a minimal example showing the bug.

Goshik92 commented 5 years ago

You seem to be right about font issues. In the following code if I comment out \definefontfamily [mainface] [tt] [Consolas], I see normal dashes. Is it an issue with Consolas font?

test.tex:

% Choose US paper format
\setuppapersize[letter]

\definefontfamily [mainface] [rm] [Cambria]
\definefontfamily [mainface] [ss] [Calibri]
\definefontfamily [mainface] [tt] [Consolas]
\definefontfamily [mainface] [mm] [Asana Math]
\setupbodyfont[mainface]

\usemodule[vim]

\definevimtyping[C][
    syntax=c,
    numbering=yes]

\starttext
\typeCfile{main.c}
\stoptext

main.c:

/*----------------------------------------------------------------------------------
* File: main.c
* Function: foo
* Description: bar
*----------------------------------------------------------------------------------*/

void main()
{
    int i = 0;
    i--;
    return 0;
}
adityam commented 5 years ago

I cannot test this right now, but try by adding features=none to disable ligatures for teletype fonts.

\definefontfamily [mainface] [tt] [Consolas][features=none]
Goshik92 commented 5 years ago

[features=none] solves the problem. Thank you so much for your help!