Skip to content

Commit

Permalink
Merge pull request #103 from Kolaru/italic_hbar
Browse files Browse the repository at this point in the history
Make hbar italic
  • Loading branch information
Kolaru authored Apr 19, 2023
2 parents d59b23f + 1ddde82 commit 9708b15
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MathTeXEngine"
uuid = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
authors = ["Benoît Richard <[email protected]>"]
version = "0.5.5"
version = "0.5.6"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MathTeXEngine

This is a work in progress package aimed at providing a pure Julia engine for LaTeX math mode. It is composed of two main parts: a LaTeX parser and a LaTeX engine, both only for LaTeX math mode.
This is a package aimed at providing a pure Julia engine for LaTeX math mode. It is composed of two main parts: a LaTeX parser and a LaTeX engine, both only for LaTeX math mode.

# Main features

Expand Down Expand Up @@ -98,6 +98,8 @@ julia> generate_tex_elements(L"A_{B_{C_D}}")

Parsing is done through the exported function `texparse` into nested `TeXExpr` objects forming a tree. The parser does not perform any operation to layout the elements, it only transforms them into a syntax tree.

The readme file in the `src/parser` folder contains more details about the inner working of the parser.

## Supported constructions

The table below contains the list of all supported LaTeX construction and their representation when parsed.
Expand Down Expand Up @@ -165,4 +167,8 @@ julia> expr.args[1].args
└─ '2'

nothing
```
```

# Acknowledgement

The font inspector site [FontDrop!](https://fontdrop.info) has been invaluable for this package.
2 changes: 2 additions & 0 deletions prototype/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43"
FreeTypeAbstraction = "663a7486-cb36-511b-a19d-713bb74d65c9"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Expand Down
5 changes: 2 additions & 3 deletions prototype/glyphtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Pkg.activate("prototype")
using MathTeXEngine
using CairoMakie

tex = L"\int dx \theta 2 x"
text(0, 0 ; text = tex, textsize=20)

tex = L"\hbar \omega"
text(0, 0 ; text = tex, fontsize = 120)

elems = generate_tex_elements(tex)
21 changes: 21 additions & 0 deletions prototype/show_glyphs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using CairoMakie
using MathTeXEngine

offset = 8400
ncols = 30
nrows = 15

glyph_ids = [offset + j + (i -1)*ncols for i in 1:nrows, j in 1:ncols]
font = "assets/fonts/NewComputerModern/NewCMMath-Regular.otf"
fig = Figure(; resolution = (1800, 1000))

for ci in CartesianIndices(glyph_ids)
gid = glyph_ids[ci]
try
Label(fig[ci[1], ci[2]], "$(Char(gid))" ; font)
catch
Label(fig[ci[1], ci[2]], " " ; font)
end
end

fig
1 change: 1 addition & 0 deletions reference/compare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include("references.jl")
const git = Git.git()

@testset begin "Reference images"
readchomp(`$git fetch`)
master_id = readchomp(`$git rev-parse --short master`)
current_id = readchomp(`$git rev-parse --short HEAD`)
is_clean = isempty(readchomp(`$git status -s`))
Expand Down
6 changes: 6 additions & 0 deletions src/engine/new_computer_modern_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ for i in 0:24
_symbol_to_new_computer_modern[small] = (cmmath_fontpath, 3352 + i)
end
end

# Special case : get hbar from the italic font
_symbol_to_new_computer_modern['ħ'] = (
joinpath("NewComputerModern", "NewCM10-Italic.otf"),
231
)

2 comments on commit 9708b15

@Kolaru
Copy link
Owner Author

@Kolaru Kolaru commented on 9708b15 Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/81894

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.6 -m "<description of version>" 9708b1545645d41dc33355dc19d262d0efd30eab
git push origin v0.5.6

Please sign in to comment.