Spaces:
Running
Running
Jacobo
commited on
Commit
•
1dcf491
1
Parent(s):
8ddcfd7
Migrate from replicate to together.ai
Browse files- .gitignore +21 -0
- app.py +26 -74
- pyvenv.cfg +5 -0
- requirements.txt +2 -1
- share/man/man1/isympy.1 +188 -0
- share/man/man1/ttx.1 +225 -0
.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.venv/
|
2 |
+
.env
|
3 |
+
|
4 |
+
var/
|
5 |
+
lib/
|
6 |
+
Scripts/
|
7 |
+
include/
|
8 |
+
|
9 |
+
*.pyc
|
10 |
+
__pycache__/
|
11 |
+
|
12 |
+
instance/
|
13 |
+
|
14 |
+
.pytest_cache/
|
15 |
+
.coverage
|
16 |
+
htmlcov/
|
17 |
+
|
18 |
+
dist/
|
19 |
+
build/
|
20 |
+
*.egg-info/
|
21 |
+
test.py
|
app.py
CHANGED
@@ -1,16 +1,11 @@
|
|
1 |
-
from supabase import create_client
|
2 |
-
from supabase.lib.client_options import ClientOptions
|
3 |
from sentence_transformers import SentenceTransformer
|
4 |
-
import
|
|
|
5 |
import vecs
|
6 |
import os
|
7 |
import gradio as gr
|
8 |
|
9 |
-
|
10 |
-
key = os.getenv("Key")
|
11 |
-
url = os.getenv("url")
|
12 |
-
opts = ClientOptions().replace(schema="vecs")
|
13 |
-
client = create_client(url, key, options=opts)
|
14 |
|
15 |
user = os.getenv("user")
|
16 |
password = os.getenv("password")
|
@@ -20,55 +15,15 @@ db_name = "postgres"
|
|
20 |
DB_CONNECTION = f"postgresql://{user}:{password}@{host}:{port}/{db_name}"
|
21 |
vx = vecs.create_client(DB_CONNECTION)
|
22 |
model = SentenceTransformer('Snowflake/snowflake-arctic-embed-xs')
|
|
|
23 |
|
24 |
-
def
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
id = ""
|
32 |
-
for item in prediction_list:
|
33 |
-
temp_dict = dict(item)
|
34 |
-
if temp_dict.get("input").get("prompt") == inp:
|
35 |
-
id = temp_dict.get("id")
|
36 |
-
break
|
37 |
-
else:
|
38 |
-
pass
|
39 |
-
return id
|
40 |
-
|
41 |
-
def live_inference(prompt, max_new_tokens = 1024, top_k = 50, top_p = 0.9, temperature = 0.6, presence_penalty=1.15):
|
42 |
-
output = replicate.run(
|
43 |
-
"meta/meta-llama-3-8b-instruct",
|
44 |
-
input={
|
45 |
-
"top_k": top_k,
|
46 |
-
"top_p": top_p,
|
47 |
-
"prompt": prompt,
|
48 |
-
"temperature": temperature,
|
49 |
-
"max_new_tokens": max_new_tokens,
|
50 |
-
"prompt_template": "{prompt}",
|
51 |
-
"frequency_penalty": presence_penalty,
|
52 |
-
"seed": 61001
|
53 |
-
})
|
54 |
-
|
55 |
-
id = find_id(replicate.predictions.list(), prompt)
|
56 |
-
generating = True
|
57 |
-
out = ""
|
58 |
-
while generating:
|
59 |
-
prediction_list = replicate.predictions.list()
|
60 |
-
prediction = find_prediction(prediction_list, id)
|
61 |
-
try:
|
62 |
-
if prediction.get("status") != "succeeded":
|
63 |
-
pass
|
64 |
-
else:
|
65 |
-
for item in prediction.get("output"):
|
66 |
-
out += item
|
67 |
-
generating = False
|
68 |
-
except:
|
69 |
-
pass
|
70 |
-
return out
|
71 |
-
|
72 |
|
73 |
def query_db(query, limit = 5, filters = {}, measure = "cosine_distance", include_value = False, include_metadata=False, table = "2023"):
|
74 |
query_embeds = vx.get_or_create_collection(name= table, dimension=384)
|
@@ -105,27 +60,24 @@ def referencias(results):
|
|
105 |
return references
|
106 |
|
107 |
def inference(prompt):
|
108 |
-
|
109 |
-
years = range(
|
110 |
results = []
|
111 |
for year in years:
|
112 |
-
results.extend(query_db(
|
113 |
results.sort(key=sort_by_score, reverse=True)
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
<|start_header_id|>assistant<|end_header_id|>
|
127 |
-
"""
|
128 |
-
return live_inference(context, max_new_tokens=512) + '\n' + referencias(results)
|
129 |
|
130 |
theme = gr.themes.Base(
|
131 |
primary_hue="red",
|
|
|
|
|
|
|
1 |
from sentence_transformers import SentenceTransformer
|
2 |
+
from together import Together
|
3 |
+
from dotenv import load_dotenv
|
4 |
import vecs
|
5 |
import os
|
6 |
import gradio as gr
|
7 |
|
8 |
+
load_dotenv()
|
|
|
|
|
|
|
|
|
9 |
|
10 |
user = os.getenv("user")
|
11 |
password = os.getenv("password")
|
|
|
15 |
DB_CONNECTION = f"postgresql://{user}:{password}@{host}:{port}/{db_name}"
|
16 |
vx = vecs.create_client(DB_CONNECTION)
|
17 |
model = SentenceTransformer('Snowflake/snowflake-arctic-embed-xs')
|
18 |
+
client = Together(api_key=os.getenv('TOGETHER_API_KEY'))
|
19 |
|
20 |
+
def live_inference(messages, max_new_tokens = 512):
|
21 |
+
response = client.chat.completions.create(
|
22 |
+
model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
|
23 |
+
messages = messages,
|
24 |
+
max_tokens = max_new_tokens
|
25 |
+
)
|
26 |
+
return response.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def query_db(query, limit = 5, filters = {}, measure = "cosine_distance", include_value = False, include_metadata=False, table = "2023"):
|
29 |
query_embeds = vx.get_or_create_collection(name= table, dimension=384)
|
|
|
60 |
return references
|
61 |
|
62 |
def inference(prompt):
|
63 |
+
encoded_prompt1 = model.encode(prompt)
|
64 |
+
years = range(2019, 2025)
|
65 |
results = []
|
66 |
for year in years:
|
67 |
+
results.extend(query_db(encoded_prompt1, include_metadata = True, table = str(year), include_value=True, limit = 5))
|
68 |
results.sort(key=sort_by_score, reverse=True)
|
69 |
+
researchAI=[
|
70 |
+
{"role": "system", "content": f"""
|
71 |
+
Eres Ticio, un asistente de investigación jurídica. Tu deber es organizar el contenido de las sentencias de la jurisprudencia de acuerdo
|
72 |
+
a las necesidades del usuario. Debes responder solo en español. Debes responder solo en base a la información del contexto a continuación.
|
73 |
+
Siempre debes mencionar la fuente en tu escrito, debe tener un estilo formal y juridico.
|
74 |
+
Contexto:
|
75 |
+
{construct_result(results)}
|
76 |
+
"""
|
77 |
+
},
|
78 |
+
{"role": "user", "content": prompt},
|
79 |
+
]
|
80 |
+
return live_inference(researchAI, max_new_tokens=1024) + '\n' + referencias(results)
|
|
|
|
|
|
|
81 |
|
82 |
theme = gr.themes.Base(
|
83 |
primary_hue="red",
|
pyvenv.cfg
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
home = C:\Users\jacob\AppData\Local\Programs\Python\Python312
|
2 |
+
include-system-site-packages = false
|
3 |
+
version = 3.12.3
|
4 |
+
executable = C:\Users\jacob\AppData\Local\Programs\Python\Python312\python.exe
|
5 |
+
command = C:\Users\jacob\AppData\Local\Programs\Python\Python312\python.exe -m venv C:\Users\jacob\CorteConstitucional
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
vecs
|
2 |
-
|
3 |
supabase
|
4 |
sentence-transformers
|
|
|
|
1 |
vecs
|
2 |
+
together
|
3 |
supabase
|
4 |
sentence-transformers
|
5 |
+
python-dotenv
|
share/man/man1/isympy.1
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'\" -*- coding: us-ascii -*-
|
2 |
+
.if \n(.g .ds T< \\FC
|
3 |
+
.if \n(.g .ds T> \\F[\n[.fam]]
|
4 |
+
.de URL
|
5 |
+
\\$2 \(la\\$1\(ra\\$3
|
6 |
+
..
|
7 |
+
.if \n(.g .mso www.tmac
|
8 |
+
.TH isympy 1 2007-10-8 "" ""
|
9 |
+
.SH NAME
|
10 |
+
isympy \- interactive shell for SymPy
|
11 |
+
.SH SYNOPSIS
|
12 |
+
'nh
|
13 |
+
.fi
|
14 |
+
.ad l
|
15 |
+
\fBisympy\fR \kx
|
16 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
17 |
+
'in \n(.iu+\nxu
|
18 |
+
[\fB-c\fR | \fB--console\fR] [\fB-p\fR ENCODING | \fB--pretty\fR ENCODING] [\fB-t\fR TYPE | \fB--types\fR TYPE] [\fB-o\fR ORDER | \fB--order\fR ORDER] [\fB-q\fR | \fB--quiet\fR] [\fB-d\fR | \fB--doctest\fR] [\fB-C\fR | \fB--no-cache\fR] [\fB-a\fR | \fB--auto\fR] [\fB-D\fR | \fB--debug\fR] [
|
19 |
+
-- | PYTHONOPTIONS]
|
20 |
+
'in \n(.iu-\nxu
|
21 |
+
.ad b
|
22 |
+
'hy
|
23 |
+
'nh
|
24 |
+
.fi
|
25 |
+
.ad l
|
26 |
+
\fBisympy\fR \kx
|
27 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
28 |
+
'in \n(.iu+\nxu
|
29 |
+
[
|
30 |
+
{\fB-h\fR | \fB--help\fR}
|
31 |
+
|
|
32 |
+
{\fB-v\fR | \fB--version\fR}
|
33 |
+
]
|
34 |
+
'in \n(.iu-\nxu
|
35 |
+
.ad b
|
36 |
+
'hy
|
37 |
+
.SH DESCRIPTION
|
38 |
+
isympy is a Python shell for SymPy. It is just a normal python shell
|
39 |
+
(ipython shell if you have the ipython package installed) that executes
|
40 |
+
the following commands so that you don't have to:
|
41 |
+
.PP
|
42 |
+
.nf
|
43 |
+
\*(T<
|
44 |
+
>>> from __future__ import division
|
45 |
+
>>> from sympy import *
|
46 |
+
>>> x, y, z = symbols("x,y,z")
|
47 |
+
>>> k, m, n = symbols("k,m,n", integer=True)
|
48 |
+
\*(T>
|
49 |
+
.fi
|
50 |
+
.PP
|
51 |
+
So starting isympy is equivalent to starting python (or ipython) and
|
52 |
+
executing the above commands by hand. It is intended for easy and quick
|
53 |
+
experimentation with SymPy. For more complicated programs, it is recommended
|
54 |
+
to write a script and import things explicitly (using the "from sympy
|
55 |
+
import sin, log, Symbol, ..." idiom).
|
56 |
+
.SH OPTIONS
|
57 |
+
.TP
|
58 |
+
\*(T<\fB\-c \fR\*(T>\fISHELL\fR, \*(T<\fB\-\-console=\fR\*(T>\fISHELL\fR
|
59 |
+
Use the specified shell (python or ipython) as
|
60 |
+
console backend instead of the default one (ipython
|
61 |
+
if present or python otherwise).
|
62 |
+
|
63 |
+
Example: isympy -c python
|
64 |
+
|
65 |
+
\fISHELL\fR could be either
|
66 |
+
\&'ipython' or 'python'
|
67 |
+
.TP
|
68 |
+
\*(T<\fB\-p \fR\*(T>\fIENCODING\fR, \*(T<\fB\-\-pretty=\fR\*(T>\fIENCODING\fR
|
69 |
+
Setup pretty printing in SymPy. By default, the most pretty, unicode
|
70 |
+
printing is enabled (if the terminal supports it). You can use less
|
71 |
+
pretty ASCII printing instead or no pretty printing at all.
|
72 |
+
|
73 |
+
Example: isympy -p no
|
74 |
+
|
75 |
+
\fIENCODING\fR must be one of 'unicode',
|
76 |
+
\&'ascii' or 'no'.
|
77 |
+
.TP
|
78 |
+
\*(T<\fB\-t \fR\*(T>\fITYPE\fR, \*(T<\fB\-\-types=\fR\*(T>\fITYPE\fR
|
79 |
+
Setup the ground types for the polys. By default, gmpy ground types
|
80 |
+
are used if gmpy2 or gmpy is installed, otherwise it falls back to python
|
81 |
+
ground types, which are a little bit slower. You can manually
|
82 |
+
choose python ground types even if gmpy is installed (e.g., for testing purposes).
|
83 |
+
|
84 |
+
Note that sympy ground types are not supported, and should be used
|
85 |
+
only for experimental purposes.
|
86 |
+
|
87 |
+
Note that the gmpy1 ground type is primarily intended for testing; it the
|
88 |
+
use of gmpy even if gmpy2 is available.
|
89 |
+
|
90 |
+
This is the same as setting the environment variable
|
91 |
+
SYMPY_GROUND_TYPES to the given ground type (e.g.,
|
92 |
+
SYMPY_GROUND_TYPES='gmpy')
|
93 |
+
|
94 |
+
The ground types can be determined interactively from the variable
|
95 |
+
sympy.polys.domains.GROUND_TYPES inside the isympy shell itself.
|
96 |
+
|
97 |
+
Example: isympy -t python
|
98 |
+
|
99 |
+
\fITYPE\fR must be one of 'gmpy',
|
100 |
+
\&'gmpy1' or 'python'.
|
101 |
+
.TP
|
102 |
+
\*(T<\fB\-o \fR\*(T>\fIORDER\fR, \*(T<\fB\-\-order=\fR\*(T>\fIORDER\fR
|
103 |
+
Setup the ordering of terms for printing. The default is lex, which
|
104 |
+
orders terms lexicographically (e.g., x**2 + x + 1). You can choose
|
105 |
+
other orderings, such as rev-lex, which will use reverse
|
106 |
+
lexicographic ordering (e.g., 1 + x + x**2).
|
107 |
+
|
108 |
+
Note that for very large expressions, ORDER='none' may speed up
|
109 |
+
printing considerably, with the tradeoff that the order of the terms
|
110 |
+
in the printed expression will have no canonical order
|
111 |
+
|
112 |
+
Example: isympy -o rev-lax
|
113 |
+
|
114 |
+
\fIORDER\fR must be one of 'lex', 'rev-lex', 'grlex',
|
115 |
+
\&'rev-grlex', 'grevlex', 'rev-grevlex', 'old', or 'none'.
|
116 |
+
.TP
|
117 |
+
\*(T<\fB\-q\fR\*(T>, \*(T<\fB\-\-quiet\fR\*(T>
|
118 |
+
Print only Python's and SymPy's versions to stdout at startup, and nothing else.
|
119 |
+
.TP
|
120 |
+
\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-\-doctest\fR\*(T>
|
121 |
+
Use the same format that should be used for doctests. This is
|
122 |
+
equivalent to '\fIisympy -c python -p no\fR'.
|
123 |
+
.TP
|
124 |
+
\*(T<\fB\-C\fR\*(T>, \*(T<\fB\-\-no\-cache\fR\*(T>
|
125 |
+
Disable the caching mechanism. Disabling the cache may slow certain
|
126 |
+
operations down considerably. This is useful for testing the cache,
|
127 |
+
or for benchmarking, as the cache can result in deceptive benchmark timings.
|
128 |
+
|
129 |
+
This is the same as setting the environment variable SYMPY_USE_CACHE
|
130 |
+
to 'no'.
|
131 |
+
.TP
|
132 |
+
\*(T<\fB\-a\fR\*(T>, \*(T<\fB\-\-auto\fR\*(T>
|
133 |
+
Automatically create missing symbols. Normally, typing a name of a
|
134 |
+
Symbol that has not been instantiated first would raise NameError,
|
135 |
+
but with this option enabled, any undefined name will be
|
136 |
+
automatically created as a Symbol. This only works in IPython 0.11.
|
137 |
+
|
138 |
+
Note that this is intended only for interactive, calculator style
|
139 |
+
usage. In a script that uses SymPy, Symbols should be instantiated
|
140 |
+
at the top, so that it's clear what they are.
|
141 |
+
|
142 |
+
This will not override any names that are already defined, which
|
143 |
+
includes the single character letters represented by the mnemonic
|
144 |
+
QCOSINE (see the "Gotchas and Pitfalls" document in the
|
145 |
+
documentation). You can delete existing names by executing "del
|
146 |
+
name" in the shell itself. You can see if a name is defined by typing
|
147 |
+
"'name' in globals()".
|
148 |
+
|
149 |
+
The Symbols that are created using this have default assumptions.
|
150 |
+
If you want to place assumptions on symbols, you should create them
|
151 |
+
using symbols() or var().
|
152 |
+
|
153 |
+
Finally, this only works in the top level namespace. So, for
|
154 |
+
example, if you define a function in isympy with an undefined
|
155 |
+
Symbol, it will not work.
|
156 |
+
.TP
|
157 |
+
\*(T<\fB\-D\fR\*(T>, \*(T<\fB\-\-debug\fR\*(T>
|
158 |
+
Enable debugging output. This is the same as setting the
|
159 |
+
environment variable SYMPY_DEBUG to 'True'. The debug status is set
|
160 |
+
in the variable SYMPY_DEBUG within isympy.
|
161 |
+
.TP
|
162 |
+
-- \fIPYTHONOPTIONS\fR
|
163 |
+
These options will be passed on to \fIipython (1)\fR shell.
|
164 |
+
Only supported when ipython is being used (standard python shell not supported).
|
165 |
+
|
166 |
+
Two dashes (--) are required to separate \fIPYTHONOPTIONS\fR
|
167 |
+
from the other isympy options.
|
168 |
+
|
169 |
+
For example, to run iSymPy without startup banner and colors:
|
170 |
+
|
171 |
+
isympy -q -c ipython -- --colors=NoColor
|
172 |
+
.TP
|
173 |
+
\*(T<\fB\-h\fR\*(T>, \*(T<\fB\-\-help\fR\*(T>
|
174 |
+
Print help output and exit.
|
175 |
+
.TP
|
176 |
+
\*(T<\fB\-v\fR\*(T>, \*(T<\fB\-\-version\fR\*(T>
|
177 |
+
Print isympy version information and exit.
|
178 |
+
.SH FILES
|
179 |
+
.TP
|
180 |
+
\*(T<\fI${HOME}/.sympy\-history\fR\*(T>
|
181 |
+
Saves the history of commands when using the python
|
182 |
+
shell as backend.
|
183 |
+
.SH BUGS
|
184 |
+
The upstreams BTS can be found at \(lahttps://github.com/sympy/sympy/issues\(ra
|
185 |
+
Please report all bugs that you find in there, this will help improve
|
186 |
+
the overall quality of SymPy.
|
187 |
+
.SH "SEE ALSO"
|
188 |
+
\fBipython\fR(1), \fBpython\fR(1)
|
share/man/man1/ttx.1
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.Dd May 18, 2004
|
2 |
+
.\" ttx is not specific to any OS, but contrary to what groff_mdoc(7)
|
3 |
+
.\" seems to imply, entirely omitting the .Os macro causes 'BSD' to
|
4 |
+
.\" be used, so I give a zero-width space as its argument.
|
5 |
+
.Os \&
|
6 |
+
.\" The "FontTools Manual" argument apparently has no effect in
|
7 |
+
.\" groff 1.18.1. I think it is a bug in the -mdoc groff package.
|
8 |
+
.Dt TTX 1 "FontTools Manual"
|
9 |
+
.Sh NAME
|
10 |
+
.Nm ttx
|
11 |
+
.Nd tool for manipulating TrueType and OpenType fonts
|
12 |
+
.Sh SYNOPSIS
|
13 |
+
.Nm
|
14 |
+
.Bk
|
15 |
+
.Op Ar option ...
|
16 |
+
.Ek
|
17 |
+
.Bk
|
18 |
+
.Ar file ...
|
19 |
+
.Ek
|
20 |
+
.Sh DESCRIPTION
|
21 |
+
.Nm
|
22 |
+
is a tool for manipulating TrueType and OpenType fonts. It can convert
|
23 |
+
TrueType and OpenType fonts to and from an
|
24 |
+
.Tn XML Ns -based format called
|
25 |
+
.Tn TTX .
|
26 |
+
.Tn TTX
|
27 |
+
files have a
|
28 |
+
.Ql .ttx
|
29 |
+
extension.
|
30 |
+
.Pp
|
31 |
+
For each
|
32 |
+
.Ar file
|
33 |
+
argument it is given,
|
34 |
+
.Nm
|
35 |
+
detects whether it is a
|
36 |
+
.Ql .ttf ,
|
37 |
+
.Ql .otf
|
38 |
+
or
|
39 |
+
.Ql .ttx
|
40 |
+
file and acts accordingly: if it is a
|
41 |
+
.Ql .ttf
|
42 |
+
or
|
43 |
+
.Ql .otf
|
44 |
+
file, it generates a
|
45 |
+
.Ql .ttx
|
46 |
+
file; if it is a
|
47 |
+
.Ql .ttx
|
48 |
+
file, it generates a
|
49 |
+
.Ql .ttf
|
50 |
+
or
|
51 |
+
.Ql .otf
|
52 |
+
file.
|
53 |
+
.Pp
|
54 |
+
By default, every output file is created in the same directory as the
|
55 |
+
corresponding input file and with the same name except for the
|
56 |
+
extension, which is substituted appropriately.
|
57 |
+
.Nm
|
58 |
+
never overwrites existing files; if necessary, it appends a suffix to
|
59 |
+
the output file name before the extension, as in
|
60 |
+
.Pa Arial#1.ttf .
|
61 |
+
.Ss "General options"
|
62 |
+
.Bl -tag -width ".Fl t Ar table"
|
63 |
+
.It Fl h
|
64 |
+
Display usage information.
|
65 |
+
.It Fl d Ar dir
|
66 |
+
Write the output files to directory
|
67 |
+
.Ar dir
|
68 |
+
instead of writing every output file to the same directory as the
|
69 |
+
corresponding input file.
|
70 |
+
.It Fl o Ar file
|
71 |
+
Write the output to
|
72 |
+
.Ar file
|
73 |
+
instead of writing it to the same directory as the
|
74 |
+
corresponding input file.
|
75 |
+
.It Fl v
|
76 |
+
Be verbose. Write more messages to the standard output describing what
|
77 |
+
is being done.
|
78 |
+
.It Fl a
|
79 |
+
Allow virtual glyphs ID's on compile or decompile.
|
80 |
+
.El
|
81 |
+
.Ss "Dump options"
|
82 |
+
The following options control the process of dumping font files
|
83 |
+
(TrueType or OpenType) to
|
84 |
+
.Tn TTX
|
85 |
+
files.
|
86 |
+
.Bl -tag -width ".Fl t Ar table"
|
87 |
+
.It Fl l
|
88 |
+
List table information. Instead of dumping the font to a
|
89 |
+
.Tn TTX
|
90 |
+
file, display minimal information about each table.
|
91 |
+
.It Fl t Ar table
|
92 |
+
Dump table
|
93 |
+
.Ar table .
|
94 |
+
This option may be given multiple times to dump several tables at
|
95 |
+
once. When not specified, all tables are dumped.
|
96 |
+
.It Fl x Ar table
|
97 |
+
Exclude table
|
98 |
+
.Ar table
|
99 |
+
from the list of tables to dump. This option may be given multiple
|
100 |
+
times to exclude several tables from the dump. The
|
101 |
+
.Fl t
|
102 |
+
and
|
103 |
+
.Fl x
|
104 |
+
options are mutually exclusive.
|
105 |
+
.It Fl s
|
106 |
+
Split tables. Dump each table to a separate
|
107 |
+
.Tn TTX
|
108 |
+
file and write (under the name that would have been used for the output
|
109 |
+
file if the
|
110 |
+
.Fl s
|
111 |
+
option had not been given) one small
|
112 |
+
.Tn TTX
|
113 |
+
file containing references to the individual table dump files. This
|
114 |
+
file can be used as input to
|
115 |
+
.Nm
|
116 |
+
as long as the referenced files can be found in the same directory.
|
117 |
+
.It Fl i
|
118 |
+
.\" XXX: I suppose OpenType programs (exist and) are also affected.
|
119 |
+
Don't disassemble TrueType instructions. When this option is specified,
|
120 |
+
all TrueType programs (glyph programs, the font program and the
|
121 |
+
pre-program) are written to the
|
122 |
+
.Tn TTX
|
123 |
+
file as hexadecimal data instead of
|
124 |
+
assembly. This saves some time and results in smaller
|
125 |
+
.Tn TTX
|
126 |
+
files.
|
127 |
+
.It Fl y Ar n
|
128 |
+
When decompiling a TrueType Collection (TTC) file,
|
129 |
+
decompile font number
|
130 |
+
.Ar n ,
|
131 |
+
starting from 0.
|
132 |
+
.El
|
133 |
+
.Ss "Compilation options"
|
134 |
+
The following options control the process of compiling
|
135 |
+
.Tn TTX
|
136 |
+
files into font files (TrueType or OpenType):
|
137 |
+
.Bl -tag -width ".Fl t Ar table"
|
138 |
+
.It Fl m Ar fontfile
|
139 |
+
Merge the input
|
140 |
+
.Tn TTX
|
141 |
+
file
|
142 |
+
.Ar file
|
143 |
+
with
|
144 |
+
.Ar fontfile .
|
145 |
+
No more than one
|
146 |
+
.Ar file
|
147 |
+
argument can be specified when this option is used.
|
148 |
+
.It Fl b
|
149 |
+
Don't recalculate glyph bounding boxes. Use the values in the
|
150 |
+
.Tn TTX
|
151 |
+
file as is.
|
152 |
+
.El
|
153 |
+
.Sh "THE TTX FILE FORMAT"
|
154 |
+
You can find some information about the
|
155 |
+
.Tn TTX
|
156 |
+
file format in
|
157 |
+
.Pa documentation.html .
|
158 |
+
In particular, you will find in that file the list of tables understood by
|
159 |
+
.Nm
|
160 |
+
and the relations between TrueType GlyphIDs and the glyph names used in
|
161 |
+
.Tn TTX
|
162 |
+
files.
|
163 |
+
.Sh EXAMPLES
|
164 |
+
In the following examples, all files are read from and written to the
|
165 |
+
current directory. Additionally, the name given for the output file
|
166 |
+
assumes in every case that it did not exist before
|
167 |
+
.Nm
|
168 |
+
was invoked.
|
169 |
+
.Pp
|
170 |
+
Dump the TrueType font contained in
|
171 |
+
.Pa FreeSans.ttf
|
172 |
+
to
|
173 |
+
.Pa FreeSans.ttx :
|
174 |
+
.Pp
|
175 |
+
.Dl ttx FreeSans.ttf
|
176 |
+
.Pp
|
177 |
+
Compile
|
178 |
+
.Pa MyFont.ttx
|
179 |
+
into a TrueType or OpenType font file:
|
180 |
+
.Pp
|
181 |
+
.Dl ttx MyFont.ttx
|
182 |
+
.Pp
|
183 |
+
List the tables in
|
184 |
+
.Pa FreeSans.ttf
|
185 |
+
along with some information:
|
186 |
+
.Pp
|
187 |
+
.Dl ttx -l FreeSans.ttf
|
188 |
+
.Pp
|
189 |
+
Dump the
|
190 |
+
.Sq cmap
|
191 |
+
table from
|
192 |
+
.Pa FreeSans.ttf
|
193 |
+
to
|
194 |
+
.Pa FreeSans.ttx :
|
195 |
+
.Pp
|
196 |
+
.Dl ttx -t cmap FreeSans.ttf
|
197 |
+
.Sh NOTES
|
198 |
+
On MS\-Windows and MacOS,
|
199 |
+
.Nm
|
200 |
+
is available as a graphical application to which files can be dropped.
|
201 |
+
.Sh SEE ALSO
|
202 |
+
.Pa documentation.html
|
203 |
+
.Pp
|
204 |
+
.Xr fontforge 1 ,
|
205 |
+
.Xr ftinfo 1 ,
|
206 |
+
.Xr gfontview 1 ,
|
207 |
+
.Xr xmbdfed 1 ,
|
208 |
+
.Xr Font::TTF 3pm
|
209 |
+
.Sh AUTHORS
|
210 |
+
.Nm
|
211 |
+
was written by
|
212 |
+
.An -nosplit
|
213 |
+
.An "Just van Rossum" Aq just@letterror.com .
|
214 |
+
.Pp
|
215 |
+
This manual page was written by
|
216 |
+
.An "Florent Rougon" Aq f.rougon@free.fr
|
217 |
+
for the Debian GNU/Linux system based on the existing FontTools
|
218 |
+
documentation. It may be freely used, modified and distributed without
|
219 |
+
restrictions.
|
220 |
+
.\" For Emacs:
|
221 |
+
.\" Local Variables:
|
222 |
+
.\" fill-column: 72
|
223 |
+
.\" sentence-end: "[.?!][]\"')}]*\\($\\| $\\| \\| \\)[ \n]*"
|
224 |
+
.\" sentence-end-double-space: t
|
225 |
+
.\" End:
|