tex

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2025 License: BSD-3-Clause Imports: 9 Imported by: 10

README

star-tex

Build status GoDoc

star-tex (or *TeX) is a TeX engine in Go.

cmd/star-tex

star-tex provides a TeX to PDF typesetter.

$> star-tex -h
Usage: star-tex [options] FILE.tex [FILE.pdf]

ex:
 $> star-tex ./testdata/hello.tex
 $> star-tex ./testdata/hello.tex ./out.pdf

options:
  -texmf string
    	path to TexMF root

$> star-tex ./testdata/hello.tex out.pdf
$> pdf out.pdf

cmd/dvi-cnv

dvi-cnv converts a DVI file into a (set of) PNG or PDF file(s).

$> dvi-cnv -help
Usage of dvi-cnv:
  -o string
    	path to output file name
  -texmf string
    	path to TexMF root
  -v	enable verbose mode

$> dvi-cnv -o foo.png ./testdata/hello_golden.dvi
$> open ./foo_1.png

$> dvi-cnv -o foo.pdf ./testdata/hello_golden.dvi
$> open ./foo.pdf

cmd/dvi-dump

dvi-dump displays the content of a DVI file in a human readable format or JSON.

The human readable format should be exactly the same than the official dvitype command from TeX Live.

$> dvi-dump -help
Usage of dvi-dump:
  -json
    	enable JSON output
  -texmf string
    	path to TexMF root

$> dvi-dump ./testdata/hello_golden.dvi
numerator/denominator=25400000/473628672
magnification=1000;       0.00006334 pixels per DVI unit
' TeX output 1776.07.04:1200'
Postamble starts at byte 1290.
maxv=43725786, maxh=30785863, maxstackdepth=2, totalpages=1
Font 36: cmti10---loaded at size 655360 DVI units 
Font 23: cmbx10---loaded at size 655360 DVI units 
Font 12: cmsy10---loaded at size 655360 DVI units 
Font 6: cmmi10---loaded at size 655360 DVI units 
Font 0: cmr10---loaded at size 655360 DVI units 
 
42: beginning of page 1 
87: push 
level 0:(h=0,v=0,w=0,x=0,y=0,z=0,hh=0,vv=0) 
88: down3 -917504 v:=0-917504=-917504, vv:=-58 
92: pop 
[...]

cmd/kpath-find

kpath-find is a new command that finds files in a TeX directory structure:

$> kpath-find -help
Usage of kpath-find:
  -all
    	display all matches
  -texmf string
    	path to TEXMF distribution

$> kpath-find -texmf /usr/share/texmf-dist cmr10.pk
/usr/share/texmf-dist/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk

$> kpath-find -all -texmf /usr/share/texmf-dist latex
/usr/share/texmf-dist/makeindex/latex
/usr/share/texmf-dist/tex/latex
/usr/share/texmf-dist/tex4ht/ht-fonts/alias/latex
/usr/share/texmf-dist/tex4ht/ht-fonts/unicode/latex

cmd/pk2bm

pk2bm display the content of a pk font file.

$> pk2bm -help
Usage of pk2bm:
  -H int
    	height of bitmap
  -W int
    	width of bitmap
  -b	generate a bitmap
  -c string
    	character to display
  -h	generate a hexmap

$> pk2bm -b -c a ./internal/tds/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk 

character : 97 (a)
   height : 39
    width : 38
     xoff : -3
     yoff : 37

  ...........********...................
  ........**************................
  ......*****.......******..............
  .....***............*****.............
  ....*****............******...........
  ...*******............******..........
  ...********...........******..........
  ...********............******.........
  ...********............******.........
  ...********.............******........
  ....******..............******........
  .....****...............******........
  ........................******........
  ........................******........
  ........................******........
  ........................******........
  .................*************........
  .............*****************........
  ..........*********.....******........
  ........*******.........******........
  ......*******...........******........
  ....********............******........
  ...*******..............******........
  ..********..............******........
  .********...............******........
  .*******................******........
  .*******................******......**
  *******.................******......**
  *******.................******......**
  *******.................******......**
  *******................*******......**
  *******................*******......**
  ********..............********......**
  .*******.............***.*****......**
  .********............**...*****....**.
  ..********.........****...*****....**.
  ....*******......****......*********..
  ......**************........*******...
  .........********............*****....

cmd/tfm2pl

tfm2pl converts a TFM file to human-readable property list file or standard output. tfm2pl is a Go-based reimplementation of TFtoPL, distributed with TeX-live.

$> tfm2pl -help
Usage: tfm2pl [options] file.tfm [file.pl]

tfm2pl converts a TFM file to human-readable property list file or standard output.

ex:
 $> tfm2pl testdata/simple.tfm
 $> tfm2pl testdata/simple.tfm out.pl

options:

$> tfm2pl /usr/share/texmf-dist/fonts/tfm/public/cm/cmr10.tfm
(FAMILY CMR)
(FACE O 352)
(CODINGSCHEME TEX TEXT)
(DESIGNSIZE R 10.0)
(COMMENT DESIGNSIZE IS IN POINTS)
(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)
(CHECKSUM O 11374260171)
(FONTDIMEN
   (SLANT R 0.0)
   (SPACE R 0.333334)
   (STRETCH R 0.166667)
   (SHRINK R 0.111112)
   (XHEIGHT R 0.430555)
   (QUAD R 1.000003)
   (EXTRASPACE R 0.111112)
   )
(LIGTABLE
   (LABEL O 40)
   (KRN C l R -0.277779)
   (KRN C L R -0.319446)
[...]

The output of tfm2pl should be exactly the same than the one from the official tftopl binary from TeX Live.

Documentation

Overview

Package tex provides tools to typeset TeX documents.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToDVI added in v0.7.0

func ToDVI(w io.Writer, r io.Reader) error

ToDVI reads the provided TeX document from r and compiles it to the provided writer as a ToDVI document.

func ToPDF added in v0.7.0

func ToPDF(ctx kpath.Context, w io.Writer, r io.Reader) error

ToPDF reads the provided TeX document from r and compiles it to the provided writer as a PDF document.

Example
package main

import (
	"bytes"
	"fmt"
	"log"
	"strings"

	"star-tex.org/x/tex"
	"star-tex.org/x/tex/kpath"
)

func main() {
	const src = `%% A simple TeX document.

Hello, world !
\hrule
Bye.
\bye
`

	ktx := kpath.New()
	pdf := new(bytes.Buffer)

	err := tex.ToPDF(ktx, pdf, strings.NewReader(src))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%s\n", pdf.Bytes()[:8])
}
Output:
%PDF-1.4

Types

type Engine

type Engine struct {
	// Stdin specifies the TeX engine's standard input.
	//
	// If Stdin is nil, the engine reads from the null device (os.DevNull).
	Stdin io.Reader

	// Stdout and Stderr specify the TeX engine's standard output and error.
	//
	// If either is nil, Process connects the corresponding file descriptor
	// to the null device (os.DevNull).
	Stdout io.Writer
	Stderr io.Writer

	// Jobname used for TeX output.
	// Default is "output".
	Jobname string

	// Stdlog collects TeX logging messages.
	//
	// If Stdlog is nil, Process connects Stdlog to the null device (os.DevNull).
	Stdlog io.Writer
}

Engine is a TeX engine.

func New added in v0.6.0

func New() *Engine

New creates a new TeX engine.

func (*Engine) Process

func (engine *Engine) Process(w io.Writer, r io.Reader) error

Process reads the provided TeX document and compiles it to the provided writer.

type Processor

type Processor interface {
	Process(w io.Writer, r io.Reader) error
}

Processor is the interface that wraps the Process method.

Directories

Path Synopsis
cmd
afm-dump command
dvi-cnv command
Command dvi-cnv converts a DVI document into a (set of) PNG or PDF file(s).
Command dvi-cnv converts a DVI document into a (set of) PNG or PDF file(s).
dvi-dump command
Command dvi-dump displays the content of a DVI file in a human readable format or JSON.
Command dvi-dump displays the content of a DVI file in a human readable format or JSON.
kpath-find command
Command kpath-find finds files in a TeX Directory Structure.
Command kpath-find finds files in a TeX Directory Structure.
pk2bm command
star-tex command
Command star-tex compiles TeX documents to PDFs.
Command star-tex compiles TeX documents to PDFs.
tfm2pl command
tfm2pl converts a TFM file to human-readable property list file or standard output.
tfm2pl converts a TFM file to human-readable property list file or standard output.
dvi
Package dvi implements encoding and decoding DVI documents.
Package dvi implements encoding and decoding DVI documents.
dvimg
Package dvimg provides a DVI renderer that renders to an image.
Package dvimg provides a DVI renderer that renders to an image.
dvipdf
Package dvipdf prodivdes a DVI renderer that renders to a PDF document.
Package dvipdf prodivdes a DVI renderer that renders to a PDF document.
font
afm
Package afm implements a decoder for AFM (Adobe Font Metrics) files.
Package afm implements a decoder for AFM (Adobe Font Metrics) files.
fixed
Package fixed provides types to work with fixed-point numbers.
Package fixed provides types to work with fixed-point numbers.
pkf
Package pkf implements a decoder for the Packed (PK) Font file format.
Package pkf implements a decoder for the Packed (PK) Font file format.
tfm
Package tfm implements a decoder for TFM (TeX Font Metrics) files.
Package tfm implements a decoder for TFM (TeX Font Metrics) files.
internal
iobuf
Package iobuf provides buffered I/O tailored for TeX and DVI semantics.
Package iobuf provides buffered I/O tailored for TeX and DVI semantics.
tds
Package tds provides a minimal TeX Directory Structure for star-tex.
Package tds provides a minimal TeX Directory Structure for star-tex.
Package kpath provides tools to locate TeX related files.
Package kpath provides tools to locate TeX related files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL