Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2bc6e7e
updated gitignore to ignore .vscode folder
hflexgrig Jan 26, 2026
ce02fc8
Created abstraction atom called UnderAnnotation for under annotations…
hflexgrig Jan 26, 2026
d2eabcb
Added basic latex parser for under annotation
hflexgrig Jan 26, 2026
64ee413
Merge branch 'master' into under_annotations
hflexgrig Jan 27, 2026
6ffa3e7
Merge branch 'verybadcat:master' into master
hflexgrig Jan 28, 2026
1a6629b
Created abstraction atom called UnderAnnotation for under annotations…
hflexgrig Jan 26, 2026
ddad85d
Added basic latex parser for under annotation
hflexgrig Jan 26, 2026
c98495b
Merge branch 'under_annotations' of https://github.com/hflexgrig/CSha…
hflexgrig Jan 28, 2026
92a5fb3
commented failing test
hflexgrig Jan 28, 2026
9227ea6
basic display of underbrace
hflexgrig Feb 1, 2026
9c55b71
add underbrace underlist to a latex parser
hflexgrig Feb 2, 2026
e981a2b
Finished implementation
hflexgrig Feb 2, 2026
6109461
Merge remote-tracking branch 'origin/master' into under_annotations
hflexgrig Feb 3, 2026
06c19f8
Implemented GetHorizontalGlyphAssembly
hflexgrig Feb 3, 2026
a0f06ef
ran dotnet format with fixups
hflexgrig Feb 3, 2026
374a442
fixed unittests
hflexgrig Feb 3, 2026
bf2e3cb
Add Typesetter tests for UnderAnnotation
Happypig375 Feb 3, 2026
fd8484b
merged from master and resolved conflicts
hflexgrig Feb 11, 2026
4bf254b
Merge branch 'master' into under_annotations
Happypig375 Feb 12, 2026
ee314a7
Format
Happypig375 Feb 12, 2026
24712ba
Fix head
Happypig375 Feb 12, 2026
d7a00f2
Use ref?
Happypig375 Feb 12, 2026
377f29e
sha?
Happypig375 Feb 12, 2026
3bce9c8
Check out pull request HEAD commit?
Happypig375 Feb 12, 2026
d2ca42e
fetch?
Happypig375 Feb 12, 2026
696dae0
Need origin?
Happypig375 Feb 12, 2026
8451047
Fetch all?
Happypig375 Feb 12, 2026
5fa3866
Use base_ref and head_ref given commit history
Happypig375 Feb 12, 2026
3109e54
Still need origin huh
Happypig375 Feb 12, 2026
2d20ff3
sha?
Happypig375 Feb 12, 2026
4f8f330
pull_request_target?
Happypig375 Feb 12, 2026
7012adf
Fix Labeller?
Happypig375 Feb 12, 2026
906323f
Fix warnings?
Happypig375 Feb 12, 2026
b9242ba
Underbrace rendering tests
Happypig375 Feb 12, 2026
bd680f9
Fix image baselines
Happypig375 Feb 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/Label.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Label breaking changes for semantic versioning

on: [pull_request]
on: [pull_request_target] # run on the merge target branch instead of the merge commit to grant pull-requests:write permission
jobs:
Label:
runs-on: windows-latest
permissions:
pull-requests: write # allow adding a label to this pull request
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0 # fetch all commit history and tags, instead of the default fetch of only one commit
ref: ${{ github.event.pull_request.head.sha }} # checkout the PR branch
- name: If there are changes in PublicApi.Shipped.txt, fail the workflow
if: github.head_ref != 'action/ship-publicapi' # Same branch name specified in Release.yml
run: |
git fetch origin ${{ github.base_ref }}
$changes = git diff --numstat --shortstat origin/${{ github.base_ref }}...HEAD -- '**/PublicApi.Shipped.txt'
Write-Output "$changes"
if ($changes) {
Expand All @@ -21,10 +23,7 @@ jobs:
shell: pwsh
- name: Label based on PublicApi.Unshipped.txt
run: |
git fetch origin ${{ github.base_ref }}

# Determine the appropriate label (Sync these labels with release-drafter.yml)
if ("${{ github.head_ref }}" -eq "action/ship-publicapi") { # Same branch name specified in Release.yml
if ("${{ github.head_ref }}" -eq "action/ship-publicapi") {
$labels = @('Type/Housekeeping')
Write-Output "This is a ship-publicapi PR, labeling as Type/Maintenance"
} else {
Expand Down
18 changes: 15 additions & 3 deletions CSharpMath.Core.Example/BackEnd/JsonMathTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JsonMathTable : FontMathTable<TFont, TGlyph> {
/// typically loaded from a .json file.</summary>
private readonly JToken _mathTable;
private readonly JObject _constantsDictionary;
private readonly JObject _assemblyTable;
private readonly JObject _vAssemblyTable, _hAssemblyTable;
private readonly JObject _italicTable;
public TestFontMeasurer FontMeasurer { get; }
public TestGlyphNameProvider GlyphNameProvider { get; }
Expand All @@ -41,7 +41,8 @@ JObject GetTable(string name) =>
GlyphBoundsProvider = glyphBoundsProvider;
_mathTable = mathTable;
_constantsDictionary = GetTable("constants");
_assemblyTable = GetTable("v_assembly");
_vAssemblyTable = GetTable("v_assembly");
_hAssemblyTable = GetTable("h_assembly");
_italicTable = GetTable("italic");
}
// different from _ConstantFromTable in that the _ConstantFromTable requires
Expand Down Expand Up @@ -137,7 +138,18 @@ public override float RadicalExtraAscender(TFont font) =>
private const string _extenderKey = "extender";
private const string _glyphKey = "glyph";
public override IEnumerable<GlyphPart<TGlyph>>? GetVerticalGlyphAssembly(TGlyph rawGlyph, TFont font) =>
_assemblyTable[GlyphNameProvider.GetGlyphName(rawGlyph)]?[_assemblyPartsKey] is JArray parts
_vAssemblyTable[GlyphNameProvider.GetGlyphName(rawGlyph)]?[_assemblyPartsKey] is JArray parts
? parts.Select(partInfo =>
new GlyphPart<TGlyph>(
GlyphNameProvider.GetGlyph(partInfo[_glyphKey]!.Value<string>()!),
FontUnitsToPt(font, partInfo[_advanceKey]!.Value<int>()),
FontUnitsToPt(font, partInfo[_startConnectorKey]!.Value<int>()),
FontUnitsToPt(font, partInfo[_endConnectorKey]!.Value<int>()),
partInfo[_extenderKey]!.Value<bool>()))
// Should have been defined, but let's return null
: null;
public override IEnumerable<GlyphPart<TGlyph>>? GetHorizontalGlyphAssembly(TGlyph rawGlyph, TFont font) =>
_hAssemblyTable[GlyphNameProvider.GetGlyphName(rawGlyph)]?[_assemblyPartsKey] is JArray parts
? parts.Select(partInfo =>
new GlyphPart<TGlyph>(
GlyphNameProvider.GetGlyph(partInfo[_glyphKey]!.Value<string>()!),
Expand Down
7 changes: 4 additions & 3 deletions CSharpMath.Core.Example/CSharpMath.Core.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<StartupObject>CSharpMath.Core.Checker</StartupObject>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\CSharpMath\CSharpMath.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<EmbeddedResource Include="Resources\latinmodern-math.json" />
<ProjectReference Include="..\CSharpMath\CSharpMath.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<EmbeddedResource Include="Resources\latinmodern-math.json" />
<None Include="Resources\MathTableExport.py" />
</ItemGroup>
</Project>
216 changes: 216 additions & 0 deletions CSharpMath.Core.Example/Resources/MathTableExport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# Based on https://github.com/kostub/iosMath/blob/master/fonts/math_table_to_plist.py
# Added: get_h_assembly (version 1.3 -> 1.4)

import sys
import json
from fontTools.ttLib import TTFont

def process_font(font_file, out_file):
font = TTFont(font_file)
math_table = font['MATH'].table
constants = get_constants(math_table)
italic_c = get_italic_correction(math_table)
v_variants = get_v_variants(math_table)
h_variants = get_h_variants(math_table)
v_assembly = get_v_assembly(math_table)
h_assembly = get_h_assembly(math_table)
accents = get_accent_attachments(math_table)
pl = {
"version" : "1.4",
"constants": constants,
"v_variants" : v_variants,
"h_variants" : h_variants,
"italic" : italic_c,
"accents" : accents,
"v_assembly" : v_assembly,
"h_assembly" : h_assembly }
ofile = open(out_file, 'w')
json.dump(pl, ofile)
ofile.close()

def get_constants(math_table):
constants = math_table.MathConstants
if constants is None:
raise 'Cannot find MathConstants in MATH table'

int_consts = [ 'ScriptPercentScaleDown',
'ScriptScriptPercentScaleDown',
'DelimitedSubFormulaMinHeight',
'DisplayOperatorMinHeight',
'RadicalDegreeBottomRaisePercent']
consts = { c : getattr(constants, c) for c in int_consts }

record_consts = [ 'MathLeading',
'AxisHeight',
'AccentBaseHeight',
'FlattenedAccentBaseHeight',
'SubscriptShiftDown',
'SubscriptTopMax',
'SubscriptBaselineDropMin',
'SuperscriptShiftUp',
'SuperscriptShiftUpCramped',
'SuperscriptBottomMin',
'SuperscriptBaselineDropMax',
'SubSuperscriptGapMin',
'SuperscriptBottomMaxWithSubscript',
'SpaceAfterScript',
'UpperLimitGapMin',
'UpperLimitBaselineRiseMin',
'LowerLimitGapMin',
'LowerLimitBaselineDropMin',
'StackTopShiftUp',
'StackTopDisplayStyleShiftUp',
'StackBottomShiftDown',
'StackBottomDisplayStyleShiftDown',
'StackGapMin',
'StackDisplayStyleGapMin',
'StretchStackTopShiftUp',
'StretchStackBottomShiftDown',
'StretchStackGapAboveMin',
'StretchStackGapBelowMin',
'FractionNumeratorShiftUp',
'FractionNumeratorDisplayStyleShiftUp',
'FractionDenominatorShiftDown',
'FractionDenominatorDisplayStyleShiftDown',
'FractionNumeratorGapMin',
'FractionNumDisplayStyleGapMin',
'FractionRuleThickness',
'FractionDenominatorGapMin',
'FractionDenomDisplayStyleGapMin',
'SkewedFractionHorizontalGap',
'SkewedFractionVerticalGap',
'OverbarVerticalGap',
'OverbarRuleThickness',
'OverbarExtraAscender',
'UnderbarVerticalGap',
'UnderbarRuleThickness',
'UnderbarExtraDescender',
'RadicalVerticalGap',
'RadicalDisplayStyleVerticalGap',
'RadicalRuleThickness',
'RadicalExtraAscender',
'RadicalKernBeforeDegree',
'RadicalKernAfterDegree',
]
consts_2 = { c : getattr(constants, c).Value for c in record_consts }
consts.update(consts_2)

variants = math_table.MathVariants
consts['MinConnectorOverlap'] = variants.MinConnectorOverlap
return consts

def get_italic_correction(math_table):
glyph_info = math_table.MathGlyphInfo
if glyph_info is None:
raise "Cannot find MathGlyphInfo in MATH table."
italic = glyph_info.MathItalicsCorrectionInfo
if italic is None:
raise "Cannot find Italic Correction in GlyphInfo"

glyphs = italic.Coverage.glyphs
count = italic.ItalicsCorrectionCount
records = italic.ItalicsCorrection
italic_dict = {}
for i in range(count):
name = glyphs[i]
record = records[i]
if record.DeviceTable is not None:
raise "Don't know how to process device table for italic correction."
italic_dict[name] = record.Value
return italic_dict

def get_accent_attachments(math_table):
glyph_info = math_table.MathGlyphInfo
if glyph_info is None:
raise "Cannot find MathGlyphInfo in MATH table."
attach = glyph_info.MathTopAccentAttachment
if attach is None:
raise "Cannot find Top Accent Attachment in GlyphInfo"

glyphs = attach.TopAccentCoverage.glyphs
count = attach.TopAccentAttachmentCount
records = attach.TopAccentAttachment
attach_dict = {}
for i in range(count):
name = glyphs[i]
record = records[i]
if record.DeviceTable is not None:
raise "Don't know how to process device table for accent attachment."
attach_dict[name] = record.Value
return attach_dict

def get_v_variants(math_table):
variants = math_table.MathVariants
vglyphs = variants.VertGlyphCoverage.glyphs
vconstruction = variants.VertGlyphConstruction
count = variants.VertGlyphCount
variant_dict = {}
for i in range(count):
name = vglyphs[i]
record = vconstruction[i]
glyph_variants = [x.VariantGlyph for x in
record.MathGlyphVariantRecord]
variant_dict[name] = glyph_variants
return variant_dict

def get_h_variants(math_table):
variants = math_table.MathVariants
hglyphs = variants.HorizGlyphCoverage.glyphs
hconstruction = variants.HorizGlyphConstruction
count = variants.HorizGlyphCount
variant_dict = {}
for i in range(count):
name = hglyphs[i]
record = hconstruction[i]
glyph_variants = [x.VariantGlyph for x in
record.MathGlyphVariantRecord]
variant_dict[name] = glyph_variants
return variant_dict

def get_v_assembly(math_table):
variants = math_table.MathVariants
vglyphs = variants.VertGlyphCoverage.glyphs
vconstruction = variants.VertGlyphConstruction
count = variants.VertGlyphCount
assembly_dict = {}
for i in range(count):
name = vglyphs[i]
record = vconstruction[i]
assembly = record.GlyphAssembly
if assembly is not None:
# There is an assembly for this glyph
italic = assembly.ItalicsCorrection.Value
parts = [part_dict(part) for part in assembly.PartRecords]
assembly_dict[name] = {
"italic" : assembly.ItalicsCorrection.Value,
"parts" : parts }
return assembly_dict

def get_h_assembly(math_table):
variants = math_table.MathVariants
hglyphs = variants.HorizGlyphCoverage.glyphs
hconstruction = variants.HorizGlyphConstruction
count = variants.HorizGlyphCount
assembly_dict = {}
for i in range(count):
name = hglyphs[i]
record = hconstruction[i]
assembly = record.GlyphAssembly
if assembly is not None:
# There is an assembly for this glyph
italic = assembly.ItalicsCorrection.Value
parts = [part_dict(part) for part in assembly.PartRecords]
assembly_dict[name] = {
"italic" : assembly.ItalicsCorrection.Value,
"parts" : parts }
return assembly_dict

def part_dict(part):
return {
"glyph": part.glyph,
"startConnector" : part.StartConnectorLength,
"endConnector" : part.EndConnectorLength,
"advance" : part.FullAdvance,
"extender" : (part.PartFlags == 1) }

process_font('../../CSharpMath.Rendering/Reference Fonts/latinmodern-math.otf', 'latinmodern-math.json')
Loading
Loading