Skip to content

Commit

Permalink
Change font handling in Latex
Browse files Browse the repository at this point in the history
  • Loading branch information
enzet committed Jul 22, 2024
1 parent ca6539d commit 9ada0e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Goals:

Requirements:

* `xelatex` compiler ([XeTeX](https://tug.org/xetex/)),
* C++20 compiler,
* CMake version 3.30 or higher.
* CMake version 3.30 or higher,
* `xelatex` compiler ([XeTeX](https://tug.org/xetex/)),
* [Doulos SIL](https://software.sil.org/doulos/download/) font.

To get a PDF file with the alphabet, run

Expand Down
17 changes: 7 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TikzPainter : public Painter {
stream << "\\usepackage[utf8]{inputenc}" << std::endl;
stream << "\\usepackage{tikz}" << std::endl;
stream << "\\usepackage{fontspec}" << std::endl;
stream << "\\setmainfont{Doulos SIL}" << std::endl;
stream << "\\newfontface\\doulos{Doulos SIL}" << std::endl;
stream << "\\usetikzlibrary{positioning}" << std::endl;

stream << "\\begin{document}" << std::endl;
Expand Down Expand Up @@ -552,7 +552,10 @@ void drawTikz(
center + Vector(-0.8, 0.25),
center + Vector(0.2, -0.25),
"draw=black");
painter->text(center - Vector(0.8, 0), ipaSymbol, "anchor=west");
painter->text(
center - Vector(0.8, 0),
"\\doulos{" + ipaSymbol + "}",
"anchor=west");
} else if (isImpossible) {
painter->rectangle(
center + Vector(-0.8, 0.25),
Expand Down Expand Up @@ -607,10 +610,7 @@ void parseConsonants(
for (int i = 0; i < headers.size(); i++) {
std::string tex = std::regex_replace(headers[i], std::regex("_"), " ");
tex = std::regex_replace(tex, std::regex(";"), ", ");
painter->text(
Vector(x - 0.5, y + 0.5),
"{\\fontfamily{cmr}\\selectfont " + tex + "}",
"anchor=west, rotate=30");
painter->text(Vector(x - 0.5, y + 0.5), tex, "anchor=west, rotate=30");
x += 1;
}
x = 0.0f;
Expand All @@ -622,10 +622,7 @@ void parseConsonants(

std::string tex = std::regex_replace(row[0], std::regex("_"), " ");
tex = std::regex_replace(tex, std::regex(";"), ", ");
painter->text(
Vector(x - 6, y),
"{\\fontfamily{cmr}\\selectfont " + tex + "}",
"anchor=west");
painter->text(Vector(x - 6, y), tex, "anchor=west");

for (int i = 1; i < row.size(); i++) {

Expand Down

0 comments on commit 9ada0e7

Please sign in to comment.