Skip to content
44 changes: 25 additions & 19 deletions doc/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ of approval tests used to help test the library for regressions.
- [Subscripts and Superscripts](#subscripts-and-superscripts)
- [Fractions](#fractions)
- [Radicals](#radicals)
- [Matrices](#matrices)
- [Big Operators](#big-operators)
- [Accents](#accents)
- [Overlining and Underlining](#overlining-and-underlining)
Expand All @@ -29,36 +30,49 @@ of approval tests used to help test the library for regressions.
- [Punctuation](#punctuation)
- [Others](#others)
- [Spaces](#spaces)


## Subscripts and Superscripts

Subscripts and superscripts including all levels of nesting are supported:

![](./../tests/approval_tests/approved_files/docs.subscripts_and_superscripts.approved.svg)


## Fractions

There is full support for the standard `\frac` command - again, including all levels of nesting:

![](./../tests/approval_tests/approved_files/docs.fractions.approved.svg)

The `\binom` command is also supported and anything that is not covered by either `\frac` or
The `\binom` command is also supported and anything that is not covered by either `\frac` or
`\binom` can be achieved using the generalized fraction command `\genfrac`:

![](./../tests/approval_tests/approved_files/docs.genfrac.approved.svg)

Note that in generalized fractions the third argument - the line thickness - is always in points and that currently
Note that in generalized fractions the third argument - the line thickness - is always in points and that currently
the fourth argument - the style - is ignored and treated as if `\displaystyle` was set.


## Radicals

*mfl* has full support for radicals, including the optional degree and unlimited nesting:

![](./../tests/approval_tests/approved_files/docs.radicals.approved.svg)

## Matrices

TeX-style matrices are supported via the `\matrix` command:

![](./../tests/approval_tests/approved_files/docs.matrix.approved.svg)

For example, *J* in the second row above is defined as follows:

```
J = \left(\matrix{
\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_n} \cr
\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_n} \cr
\vdots & \vdots & \ddots & \vdots \cr
\frac{\partial f_m}{\partial x_1} & \frac{\partial f_m}{\partial x_2} & \cdots & \frac{\partial f_m}{\partial x_n}
}\right)
```

## Big Operators

Expand All @@ -75,7 +89,6 @@ The extended integral symbols are also considered big operators:

![](./../tests/approval_tests/approved_files/docs.big_ops_integrals.approved.svg)


## Accents

There is support for the common mathematical accents:
Expand All @@ -90,14 +103,12 @@ There is also support for some additional mathematical accents:

![](./../tests/approval_tests/approved_files/docs.additional_accents.approved.svg)


## Overlining and Underlining

The automatic positioning and sizing of overlines and underlines is fully supported:

![](./../tests/approval_tests/approved_files/docs.lines.approved.svg)


## Functions and User Defined Operators

Unlike variables, known functions are typeset in roman instead of italics. *mfl* also
Expand All @@ -110,7 +121,6 @@ behave like built-in functions:

![](./../tests/approval_tests/approved_files/docs.operatorname.approved.svg)


## Delimiters

The following symbols are recognized as opening and closing delimiters:
Expand All @@ -122,17 +132,20 @@ available, and the dot variants `\left.` and `\right.` can be used to omit one o

![](./../tests/approval_tests/approved_files/docs.sized_delimiters.approved.svg)

If supported by the font, *mfl* will also assemble delimiters from "parts" allowing the use of
oversized - and effectively arbitrarily sized - delimiters:

![](./../tests/approval_tests/approved_files/docs.extra_large_delimiters.approved.svg)

## Fonts

*mfl* only supports the scoped font switches (like `\mathrm`, `\mathit` etc.) and not the
deprecated state switches (like `\rm`, `\it` etc.). *mfl* recognises the font
commands in the examples below. Availability and appearance of glyphs will of course
commands in the examples below. Availability and appearance of glyphs will of course
depend on the actual fonts that are being used. This is what the *Stix2* fonts look like:

![](./../tests/approval_tests/approved_files/docs.fonts.approved.svg)


## Symbols

*mfl* recognises most mathematical symbols. Here is an overview of the most important ones
Expand All @@ -142,12 +155,11 @@ for reference.

![](./../tests/approval_tests/approved_files/docs.greek_alphabet_lowercase.approved.svg)

As per mathematical convention, Greek capitals are automatically set in roman font and
As per mathematical convention, Greek capitals are automatically set in roman font and
not in italics.

![](./../tests/approval_tests/approved_files/docs.greek_alphabet_uppercase.approved.svg)


### Binary Operators

*mfl* supports the basic TeX binary operators:
Expand All @@ -158,7 +170,6 @@ as well as various binary operators from additional packages like the AMS packag

![](./../tests/approval_tests/approved_files/docs.additional_binary_operators.approved.svg)


### Relational Operators

Similarly to the binary operators, *mfl* supports the fundamental relational operators:
Expand All @@ -169,7 +180,6 @@ but also recognises many others:

![](./../tests/approval_tests/approved_files/docs.additional_relational_operators.approved.svg)


#### Negations

Many relations can be negated by prepending `\not`:
Expand All @@ -180,7 +190,6 @@ and some further negated relational operators are also supported:

![](./../tests/approval_tests/approved_files/docs.additional_negations.approved.svg)


### Arrows

The TeX arrow symbols are supported:
Expand All @@ -191,14 +200,12 @@ and *mfl* will also recognise the following extended set of arrow symbols:

![](./../tests/approval_tests/approved_files/docs.additional_arrows.approved.svg)


### Punctuation

*mfl* recognises the following symbols as punctuation:

![](./../tests/approval_tests/approved_files/docs.punctuation.approved.svg)


### Others

For completeness, the following tables show the remaining supported symbols:
Expand All @@ -207,7 +214,6 @@ For completeness, the following tables show the remaining supported symbols:
![](./../tests/approval_tests/approved_files/docs.combining_symbols.approved.svg)
![](./../tests/approval_tests/approved_files/docs.dots.approved.svg)


## Spaces

The following mathematical spacing commands are recognized by *mfl*:
Expand Down
20 changes: 18 additions & 2 deletions include/mfl/abstract_font_face.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include "mfl/font_family.hpp"
#include "mfl/units.hpp"

#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <optional>
#include <vector>

namespace mfl
Expand Down Expand Up @@ -68,6 +67,21 @@ namespace mfl
std::int32_t size = 0;
};

struct glyph_part
{
size_t glyph_index = 0;
std::int32_t start_connector_length = 0;
std::int32_t end_connector_length = 0;
std::int32_t full_advance = 0;
bool is_extender;
};

struct glyph_assembly
{
std::vector<glyph_part> parts;
std::int32_t italic_correction;
};

struct abstract_font_face
{
virtual ~abstract_font_face() = default;
Expand All @@ -77,6 +91,8 @@ namespace mfl
const bool use_large_variant) const = 0;
[[nodiscard]] virtual std::vector<size_variant> horizontal_size_variants(const code_point char_code) const = 0;
[[nodiscard]] virtual std::vector<size_variant> vertical_size_variants(const code_point char_code) const = 0;
[[nodiscard]] virtual std::optional<glyph_assembly> horizontal_assembly(const code_point char_code) const = 0;
[[nodiscard]] virtual std::optional<glyph_assembly> vertical_assembly(const code_point char_code) const = 0;
virtual void set_size(const points size) = 0;
};

Expand Down
4 changes: 3 additions & 1 deletion include/mfl/detail/quantity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,7 @@ namespace mfl::detail

template <typename Tag>
std::ostream& operator<<(std::ostream& os, const quantity<Tag>& p)
{ return os << std::format("{}", p); }
{
return os << std::format("{}", p);
}
}
4 changes: 3 additions & 1 deletion include/mfl/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ namespace mfl

constexpr dots_per_inch operator""_dpi(const long double x) { return dots_per_inch{static_cast<double>(x)}; }
constexpr dots_per_inch operator""_dpi(const unsigned long long x)
{ return dots_per_inch{static_cast<double>(x)}; }
{
return dots_per_inch{static_cast<double>(x)};
}

constexpr pixels operator""_px(const long double x) { return pixels{static_cast<double>(x)}; }
constexpr pixels operator""_px(const unsigned long long x) { return pixels{static_cast<double>(x)}; }
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ add_library(mfl
noad/gen_script.cpp
noad/left_right.cpp
noad/math_char.cpp
noad/matrix.cpp
noad/noad.cpp
noad/overline.cpp
noad/radical.cpp
Expand All @@ -33,6 +34,7 @@ add_library(mfl
parser/line.cpp
parser/math_char.cpp
parser/math_space.cpp
parser/matrix.cpp
parser/parse.cpp
parser/parser_state.cpp
parser/parser_utilities.cpp
Expand Down
Loading