Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement additional font options #3586

Merged
merged 30 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e141bd6
Add fontname support for clef and meter symbols. Add extra fonts supp…
fernandoherreradelasheras Jan 22, 2024
0ac6c60
Fix formatting of the previous commit
fernandoherreradelasheras Jan 26, 2024
5a93b01
Rename option to --font-add-custom
lpugin Jan 30, 2024
5e13298
Fix forgotten renaming
lpugin Jan 30, 2024
6951615
Update Leipzig font
lpugin Jan 31, 2024
7af324f
Update xcode deployment target
lpugin Jan 31, 2024
444e9a0
Add --font-fallback and --font-load-all options
lpugin Jan 31, 2024
0506204
Adjust Resources class with the new options
lpugin Jan 31, 2024
1ab043a
Change SVG map key to const Glyph *
lpugin Jan 31, 2024
062e4a1
Fix formatting
lpugin Jan 31, 2024
227d923
Remove unused variable
lpugin Jan 31, 2024
72d7de6
Code commenting and renaming
lpugin Jan 31, 2024
dfded42
Refactoring of View::DrawSmuflCodeWithCustomFont
lpugin Jan 31, 2024
1a40d54
Change font globally DrawClef and DrawMeterSig
lpugin Jan 31, 2024
0b2bd6f
Use Resources CurrentFont and FallbackFont
lpugin Jan 31, 2024
0f5b36e
Convert path to string
lpugin Jan 31, 2024
e7d6c7b
Update other builds to 10.15
lpugin Feb 1, 2024
b3752ca
Add ZipFileReader class
lpugin Feb 1, 2024
bda46f1
Let the Glyph return the XML from the path
lpugin Feb 1, 2024
af9825e
Add missing include
lpugin Feb 1, 2024
df2c2d7
Add implementation for zip custom fonts
lpugin Feb 1, 2024
e2385fd
Retrieve the CSS font string from the Resource class
lpugin Feb 1, 2024
33f8194
Fix json types in font options
lpugin Feb 2, 2024
c8fd967
Implement reading base64 zip archive for passing custom font in the J…
lpugin Feb 2, 2024
bd53e2d
Add JS option preprocessing functions (experimental)
lpugin Feb 2, 2024
241f865
Fix const missing and remove hardcoded fontname
lpugin Feb 2, 2024
bf078a8
Adjust JS option preprocessing
lpugin Feb 2, 2024
78046a7
Adjust font loading from the command line
lpugin Feb 7, 2024
7607b26
Use fallback for text fonts
lpugin Feb 7, 2024
0a82570
Add support for meterSig@color
lpugin Feb 7, 2024
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
36 changes: 26 additions & 10 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
4D16945A1E3A44F300569BF4 /* dot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC34BA719BC4A83006175CD /* dot.cpp */; };
4D16946A1E3A455100569BF4 /* humlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40CA06581E351161009CFDD7 /* humlib.cpp */; };
4D1694741E3A455200569BF4 /* humlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40CA06581E351161009CFDD7 /* humlib.cpp */; };
4D1AC9772B6A9BB200434023 /* filereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1AC9762B6A9BB200434023 /* filereader.cpp */; };
4D1AC9782B6A9BB200434023 /* filereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1AC9762B6A9BB200434023 /* filereader.cpp */; };
4D1AC9792B6A9BB200434023 /* filereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1AC9762B6A9BB200434023 /* filereader.cpp */; };
4D1AC97A2B6A9BB200434023 /* filereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1AC9762B6A9BB200434023 /* filereader.cpp */; };
4D1AC97C2B6A9BD000434023 /* filereader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1AC97B2B6A9BD000434023 /* filereader.h */; };
4D1AC97D2B6A9BD000434023 /* filereader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1AC97B2B6A9BD000434023 /* filereader.h */; settings = {ATTRIBUTES = (Public, ); }; };
4D1BD1B521908D6B000D35B2 /* halfmrpt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1BD1B421908D6B000D35B2 /* halfmrpt.cpp */; };
4D1BD1B621908D6B000D35B2 /* halfmrpt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1BD1B421908D6B000D35B2 /* halfmrpt.cpp */; };
4D1BD1B721908D6B000D35B2 /* halfmrpt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1BD1B421908D6B000D35B2 /* halfmrpt.cpp */; };
Expand Down Expand Up @@ -1763,6 +1769,8 @@
4D09D3EC1EA8AD8500A420E6 /* horizontalaligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = horizontalaligner.cpp; path = src/horizontalaligner.cpp; sourceTree = "<group>"; };
4D14600F1EA8A913007DB90C /* horizontalaligner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = horizontalaligner.h; path = include/vrv/horizontalaligner.h; sourceTree = "<group>"; };
4D1694601E3A44F300569BF4 /* Verovio-Humdrum */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Verovio-Humdrum"; sourceTree = BUILT_PRODUCTS_DIR; };
4D1AC9762B6A9BB200434023 /* filereader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = filereader.cpp; path = src/filereader.cpp; sourceTree = "<group>"; };
4D1AC97B2B6A9BD000434023 /* filereader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = filereader.h; path = include/vrv/filereader.h; sourceTree = "<group>"; };
4D1BD1B421908D6B000D35B2 /* halfmrpt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = halfmrpt.cpp; path = src/halfmrpt.cpp; sourceTree = "<group>"; };
4D1BD1B821908D78000D35B2 /* halfmrpt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = halfmrpt.h; path = include/vrv/halfmrpt.h; sourceTree = "<group>"; };
4D1BE7661C688F5A0086DC0E /* Binasc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Binasc.cpp; path = src/midi/Binasc.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2776,6 +2784,8 @@
36E0442D2347A9290054F141 /* expansionmap.h */,
4D79643826C6B3520026288B /* featureextractor.cpp */,
4D79643026C6AA720026288B /* featureextractor.h */,
4D1AC9762B6A9BB200434023 /* filereader.cpp */,
4D1AC97B2B6A9BD000434023 /* filereader.h */,
4DF28A041A754DF000BA9F7D /* floatingobject.cpp */,
4D95D4F41D7185DE00B2B856 /* floatingobject.h */,
4D09D3EC1EA8AD8500A420E6 /* horizontalaligner.cpp */,
Expand Down Expand Up @@ -3388,6 +3398,7 @@
E79320642991452100D80975 /* calcstemfunctor.h in Headers */,
4D1BD1B921908D78000D35B2 /* halfmrpt.h in Headers */,
4DACC9F42990F29A00B55913 /* atts_visual.h in Headers */,
4D1AC97C2B6A9BD000434023 /* filereader.h in Headers */,
4DA0EADD22BB77AF00A7EBEB /* zone.h in Headers */,
E71EF3C32975E4DC00D36264 /* resetfunctor.h in Headers */,
4D763EC91987D067003FCAB5 /* metersig.h in Headers */,
Expand Down Expand Up @@ -3706,6 +3717,7 @@
BBC19FBF22B37CA000100F42 /* all.h in Headers */,
4DA0EAE222BB77AF00A7EBEB /* editortoolkit_mensural.h in Headers */,
E79C87C8269440810098FE85 /* lv.h in Headers */,
4D1AC97D2B6A9BD000434023 /* filereader.h in Headers */,
BB4C4B5822A932D7001F6AF0 /* layerelement.h in Headers */,
BB4C4B9422A932E5001F6AF0 /* areaposinterface.h in Headers */,
);
Expand Down Expand Up @@ -3873,6 +3885,7 @@
4D1693F61E3A44F300569BF4 /* barline.cpp in Sources */,
E7901661298BCB2C008FDB4E /* calcalignmentxposfunctor.cpp in Sources */,
400FEDD6206FA74D000D3233 /* gracegrp.cpp in Sources */,
4D1AC9782B6A9BB200434023 /* filereader.cpp in Sources */,
4D89F90F201771AE00A4D336 /* num.cpp in Sources */,
4D1693F71E3A44F300569BF4 /* bboxdevicecontext.cpp in Sources */,
4D1693F81E3A44F300569BF4 /* beam.cpp in Sources */,
Expand Down Expand Up @@ -4153,6 +4166,7 @@
files = (
4DEF8A6421B7AAF90093A76B /* f.cpp in Sources */,
4DB3D89E1F7E7FAA00B5FC2B /* fig.cpp in Sources */,
4D1AC9772B6A9BB200434023 /* filereader.cpp in Sources */,
4D4FCD121F54570E0009C455 /* staffdef.cpp in Sources */,
8F086EE2188539540037FD8E /* verticalaligner.cpp in Sources */,
4DEC4D9621C81E3B00D1D273 /* expan.cpp in Sources */,
Expand Down Expand Up @@ -4438,6 +4452,7 @@
4DB3D8F01F83D1A700B5FC2B /* fig.cpp in Sources */,
E790165F298BCB27008FDB4E /* calcalignmentxposfunctor.cpp in Sources */,
8F3DD36718854B410051330C /* verticalaligner.cpp in Sources */,
4D1AC9792B6A9BB200434023 /* filereader.cpp in Sources */,
4D766F0220ACAD6E006875D8 /* nc.cpp in Sources */,
4DEC4D9821C81E3B00D1D273 /* expan.cpp in Sources */,
4D3C3F0E294B89AF009993E6 /* ornam.cpp in Sources */,
Expand Down Expand Up @@ -4721,6 +4736,7 @@
BB4C4B9322A932E5001F6AF0 /* areaposinterface.cpp in Sources */,
E7901660298BCB27008FDB4E /* calcalignmentxposfunctor.cpp in Sources */,
BB4C4AA122A9328F001F6AF0 /* verticalaligner.cpp in Sources */,
4D1AC97A2B6A9BB200434023 /* filereader.cpp in Sources */,
BB4C4B2F22A932CF001F6AF0 /* pedal.cpp in Sources */,
4D2E759222BC2B80004C51F0 /* tuning.cpp in Sources */,
BB4C4B4922A932D7001F6AF0 /* clef.cpp in Sources */,
Expand Down Expand Up @@ -5003,7 +5019,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "-";
DEAD_CODE_STRIPPING = YES;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "";
};
Expand All @@ -5014,7 +5030,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "-";
DEAD_CODE_STRIPPING = YES;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "";
};
Expand Down Expand Up @@ -5072,7 +5088,7 @@
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.15;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "";
Expand Down Expand Up @@ -5124,7 +5140,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
./include/vrv/,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.15;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "";
Expand All @@ -5140,7 +5156,7 @@
"$(inherited)",
NO_HUMDRUM_SUPPORT,
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = "";
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "";
};
Expand All @@ -5152,7 +5168,7 @@
CODE_SIGN_IDENTITY = "-";
DEAD_CODE_STRIPPING = YES;
GCC_PREPROCESSOR_DEFINITIONS = NO_HUMDRUM_SUPPORT;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = "";
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "";
};
Expand All @@ -5166,7 +5182,7 @@
EXECUTABLE_PREFIX = lib;
HEADER_SEARCH_PATHS = "";
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand All @@ -5180,7 +5196,7 @@
EXECUTABLE_PREFIX = lib;
HEADER_SEARCH_PATHS = "";
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand Down Expand Up @@ -5227,7 +5243,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.rism.VerovioFramework;
Expand Down Expand Up @@ -5280,7 +5296,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.rism.VerovioFramework;
Expand Down
1 change: 1 addition & 0 deletions bindings/iOS/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
#import <VerovioFramework/featureextractor.h>
#import <VerovioFramework/fermata.h>
#import <VerovioFramework/fig.h>
#import <VerovioFramework/filereader.h>
#import <VerovioFramework/findfunctor.h>
#import <VerovioFramework/findlayerelementsfunctor.h>
#import <VerovioFramework/fing.h>
Expand Down
2 changes: 1 addition & 1 deletion data/Leipzig.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion data/Leipzig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@
<g c="E8F5" x="0.0" y="-375.0" w="14.0" h="750.0" h-a-x="14" n="chantDivisioMaxima" />
<g c="E8F6" x="0.0" y="-375.0" w="114.0" h="750.0" h-a-x="114" n="chantDivisioFinalis" />
<g c="E8F7" x="0.0" y="264.0" w="85.0" h="234.0" h-a-x="85" n="chantVirgula" />
<g c="E8F8" x="-0.11" y="263.68" w="137.45" h="234.59" h-a-x="138" n="chantCaesura" />
<g c="E8F8" x="-0.0" y="264.0" w="137.34" h="234.27" h-a-x="138" n="chantCaesura" />
<g c="EB90" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="1000" n="staffPosRaise1" />
<g c="EB91" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="1000" n="staffPosRaise2" />
<g c="EB92" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="1000" n="staffPosRaise3" />
Expand All @@ -792,4 +792,5 @@
<g c="EB9C" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="staffPosLower5" />
<g c="EB9D" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="staffPosLower6" />
<g c="EB9E" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="staffPosLower7" />
<g c="EB9F" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="staffPosLower8" />
</bounding-boxes>
2 changes: 1 addition & 1 deletion data/Leipzig/E8F8.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<symbol id="E8F8" viewBox="0 0 1000 1000" overflow="inherit"><path transform="scale(1,-1)" d="M0 270c-2 -5 23 53 48 110c53 121 66 123 80 116c16 -8 19 -16 -54 -130c-34 -53 -67 -107 -64 -102c-10 6 -3 2 -10 6z" /></symbol>
<symbol id="E8F8" viewBox="0 0 1000 1000" overflow="inherit"><path transform="scale(1,-1)" d="M120.146 498.265c0.224774 0 17.1897 -1.82497 17.1897 -14.4827c0 -13.3186 -15.0253 -42.3383 -63.3358 -117.782c-34 -53 -64 -102 -64 -102c-10 6 -3 2 -10 6c74.9234 172.649 99.0583 228.265 120.146 228.265z" /></symbol>
1 change: 1 addition & 0 deletions data/Leipzig/EB9F.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<symbol id="EB9F" viewBox="0 0 1000 1000" overflow="inherit" />
38 changes: 38 additions & 0 deletions emscripten/npm/src/verovio-toolkit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@

import { createEmscriptenProxy } from "./emscripten-proxy.js";

async function solve(options) {
const res = await fetch(
`https://raw.githubusercontent.com/lpugin/test-font/main/GoldenAge.zip`,
{
method: "GET",
}
);
const data = await res.blob();
console.log( res );
console.log( options );
return options;
}

export class VerovioToolkit {

constructor(VerovioModule) {
Expand Down Expand Up @@ -183,6 +196,7 @@ export class VerovioToolkit {
}

setOptions(options) {
options = this.preprocessOptions(options);
return this.proxy.setOptions(this.ptr, JSON.stringify(options));
}

Expand All @@ -193,6 +207,30 @@ export class VerovioToolkit {
return JSON.parse(this.proxy.validatePAE(this.ptr, data));
}

preprocessOptions(options) {
// Nothing to do if we do not have 'fontAddCustom' set
if (!Object.hasOwn(options, 'fontAddCustom')) {
return options;
}
const filenames = options['fontAddCustom'];
let filesInBase64 = [];
// Get all the files and convert them to a base64 string
for (let i = 0; i < filenames.length; i++ ) {
const request = new XMLHttpRequest();
request.open("GET", filenames[i], false); // `false` makes the request synchronous
request.send(null);

if (request.status === 200) {
filesInBase64.push(request.responseText);
}
else {
console.error(`${filenames[i]} could not be retrieved`);
}
}
options["fontAddCustom"] = filesInBase64;
//console.log( options );
return options;
}
}

// A pointer to the object - only one instance can be created for now
Expand Down
8 changes: 5 additions & 3 deletions fonts/Leipzig/Leipzig.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fonts/Leipzig/Leipzig.ttf
Binary file not shown.
Binary file modified fonts/Leipzig/Leipzig.woff2
Binary file not shown.
16 changes: 13 additions & 3 deletions fonts/Leipzig/leipzig_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"tupletBracketThickness": 0.16
},
"fontName": "Leipzig",
"fontVersion": "5.2.86",
"fontVersion": "5.2.87",
"glyphBBoxes": {
"4stringTabClef": {
"bBoxNE": [
Expand Down Expand Up @@ -1078,8 +1078,8 @@
1.9931
],
"bBoxSW": [
-0.0005,
1.0547
0.0,
1.056
]
},
"chantCclef": {
Expand Down Expand Up @@ -6452,6 +6452,16 @@
0.0
]
},
"staffPosLower8": {
"bBoxNE": [
0.0,
0.0
],
"bBoxSW": [
0.0,
0.0
]
},
"staffPosRaise1": {
"bBoxNE": [
0.0,
Expand Down
1 change: 1 addition & 0 deletions include/vrv/clef.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Clef : public LayerElement,
public AttOctave,
public AttOctaveDisplacement,
public AttStaffIdent,
public AttTypography,
public AttVisibility {
public:
/**
Expand Down
Loading
Loading