Repository navigation
Adds ability for user to use their own custom font files #641
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,6 +348,22 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename, const LLSD& | |
| success = parse_single_fonts_file(this, path) || success; | ||
| } | ||
|
|
||
| { | ||
| const std::string overlay = LLFontGL::getImportedFontsOverlayPath(); | ||
| if (!overlay.empty() && gDirUtilp->fileExists(overlay)) | ||
| { | ||
| if (!parse_single_fonts_file(this, overlay)) | ||
| { | ||
| LL_WARNS() << "fonts.xml: failed to parse imported-fonts overlay " | ||
| << overlay << LL_ENDL; | ||
| } | ||
| else | ||
| { | ||
| success = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Resolve cross-family <use> and per-family inherit="true" once across | ||
| // the merged registry, after all skinned fonts.xml files have been read. | ||
| // Doing this per-file would double-append references for entries that | ||
|
|
@@ -1697,6 +1713,12 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) | |
| bool is_first_found = true; | ||
|
|
||
| string_vec_t font_search_paths; | ||
| // Imported fonts first so they can shadow bundled ones. | ||
| const std::string user_font_path = LLFontGL::getFontPathUser(); | ||
| if (!user_font_path.empty()) | ||
| { | ||
| font_search_paths.push_back(user_font_path); | ||
| } | ||
|
Comment on lines
+1716
to
+1721
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| font_search_paths.push_back(LLFontGL::getFontPathLocal()); | ||
| font_search_paths.push_back(LLFontGL::getFontPathSystem()); | ||
| #if LL_DARWIN | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * @file alfloaterfontreset.cpp | ||
| * @brief Confirmation dialog for the "reset fonts to defaults" recovery action. | ||
| * | ||
| * $LicenseInfo:firstyear=2026&license=viewerlgpl$ | ||
| * Alchemy Viewer Source Code | ||
| * Copyright (C) 2026, Rye <rye@alchemyviewer.org> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; | ||
| * version 2.1 of the License only. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * $/LicenseInfo$ | ||
| */ | ||
|
|
||
| #include "llviewerprecompiledheaders.h" | ||
|
|
||
| #include "alfloaterfontreset.h" | ||
|
|
||
| #include "alimportedfonts.h" | ||
| #include "llbutton.h" | ||
| #include "llfloaterpreference.h" | ||
| #include "llfloaterreg.h" | ||
|
|
||
| ALFloaterFontReset::ALFloaterFontReset(const LLSD& key) | ||
| : LLFloater(key) | ||
| { | ||
| } | ||
|
|
||
| bool ALFloaterFontReset::postBuild() | ||
| { | ||
| childSetAction("reset_btn", boost::bind(&ALFloaterFontReset::onReset, this)); | ||
| childSetAction("cancel_btn", boost::bind(&ALFloaterFontReset::onCancel, this)); | ||
| return true; | ||
| } | ||
|
|
||
| void ALFloaterFontReset::onOpen(const LLSD& key) | ||
| { | ||
| // Focus Cancel so Enter can't clear fonts by accident. | ||
| if (LLUICtrl* cancel = getChild<LLUICtrl>("cancel_btn")) | ||
| { | ||
| cancel->setFocus(true); | ||
| } | ||
| } | ||
|
|
||
| void ALFloaterFontReset::onReset() | ||
| { | ||
| ALImportedFonts::resetOverrides(); | ||
| LLFloaterPreference::scheduleFontDropdownRefresh(); | ||
| closeFloater(); | ||
| } | ||
|
|
||
| void ALFloaterFontReset::onCancel() | ||
| { | ||
| closeFloater(); | ||
| } | ||
|
|
||
| // static | ||
| void ALFloaterFontReset::showConfirm() | ||
| { | ||
| LLFloaterReg::showInstance("font_reset"); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * @file alfloaterfontreset.h | ||
| * @brief Confirmation dialog for resetting UI fonts to defaults. | ||
| * | ||
| * $LicenseInfo:firstyear=2026&license=viewerlgpl$ | ||
| * Alchemy Viewer Source Code | ||
| * Copyright (C) 2026, Rye <rye@alchemyviewer.org> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; | ||
| * version 2.1 of the License only. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * $/LicenseInfo$ | ||
| */ | ||
|
|
||
| #ifndef AL_ALFLOATERFONTRESET_H | ||
| #define AL_ALFLOATERFONTRESET_H | ||
|
|
||
| #include "llfloater.h" | ||
|
|
||
| class ALFloaterFontReset final : public LLFloater | ||
| { | ||
| public: | ||
| ALFloaterFontReset(const LLSD& key); | ||
| ~ALFloaterFontReset() override = default; | ||
|
|
||
| static void showConfirm(); | ||
|
|
||
| bool postBuild() override; | ||
| void onOpen(const LLSD& key) override; | ||
|
|
||
| private: | ||
| void onReset(); | ||
| void onCancel(); | ||
| }; | ||
|
|
||
| #endif // AL_ALFLOATERFONTRESET_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 42321
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 39428
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 29074
Web query:
FreeType FT_Set_Char_Size bitmap-only fonts nonmatching strike error FT_Open_Face OpenType embedded bitmap scalable documentationResult:
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 13214
Web query:
FreeType source truetype bitmap only FT_Request_Size FT_Match_Size no matching strike invalid pixel size TTF CBDT sbixResult:
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 7399
Web query:
vcpkg 0e5030f583a5427123cd3b714255e5ae62faa3ba freetype version baselineResult:
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 10180
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 12143
Script executed:
Repository: AlchemyViewer/Alchemy
Length of output: 15005
Validate bitmap fonts before importing them.
A bitmap-only font can pass this probe but fail to load at viewer sizes that do not match a strike. The font remains listed, while the registry uses another face. Reject fonts that the viewer cannot use at its required sizes, or support scaling their bitmap strikes.