[TD]add ANSI Y14.5 compatible font

- also add osifont-italic
- update osifont to latest version
This commit is contained in:
wandererfan
2023-01-15 11:08:12 -05:00
committed by WandererFan
parent bbce4cb4c4
commit 5800d9155b
6 changed files with 38 additions and 18 deletions

View File

@@ -22,7 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QFontDatabase>
#include <QFontDatabase>
#endif
#include <Base/Console.h>
@@ -82,18 +82,26 @@ void loadTechDrawResource()
Q_INIT_RESOURCE(TechDraw);
Gui::Translator::instance()->refresh();
// add osifont
// add fonts
std::string fontDir = App::Application::getResourceDir() + "Mod/TechDraw/Resources/fonts/";
QString fontFile = Base::Tools::fromStdString(fontDir + "osifont-lgpl3fe.ttf");
QFontDatabase fontDB;
int rc = fontDB.addApplicationFont(fontFile);
if (rc) {
Base::Console().Warning("TechDraw failed to load osifont file: %d from: %s\n", rc, qPrintable(fontFile));
std::vector<std::string> fontsAll(
{"osifont-lgpl3fe.ttf", "osifont-italic.ttf", "Y14.5-2018.ttf", "Y14.5-FreeCAD.ttf"});
for (auto& font : fontsAll) {
QString fontFile = Base::Tools::fromStdString(fontDir + font);
int rc = fontDB.addApplicationFont(fontFile);
if (rc < 0) {
Base::Console().Warning(
"TechDraw failed to load font file: %d from: %s\n", rc, qPrintable(fontFile));
}
}
}
namespace TechDrawGui {
extern PyObject* initModule();
namespace TechDrawGui
{
extern PyObject* initModule();
}
/* Python entry */
@@ -107,7 +115,7 @@ PyMOD_INIT_FUNC(TechDrawGui)
try {
Base::Interpreter().loadModule("TechDraw");
}
catch(const Base::Exception& e) {
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(nullptr);
}
@@ -152,21 +160,21 @@ PyMOD_INIT_FUNC(TechDrawGui)
TechDrawGui::ViewProviderTile::init();
TechDrawGui::ViewProviderWeld::init();
TechDrawGui::ViewProviderPageExtension ::init();
// TechDrawGui::ViewProviderPageExtensionPython::init();
TechDrawGui::ViewProviderPageExtension ::init();
// TechDrawGui::ViewProviderPageExtensionPython::init();
TechDrawGui::ViewProviderDrawingViewExtension::init();
TechDrawGui::ViewProviderTemplateExtension::init();
TechDrawGui::ViewProviderCosmeticExtension::init();
// register preferences pages
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawGeneralImp> ("TechDraw"); //General
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawScaleImp> ("TechDraw"); //Scale
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawDimensionsImp>("TechDraw"); //Dimensions
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawAnnotationImp> ("TechDraw"); //Annotation
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawColorsImp>("TechDraw"); //Colors
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawHLRImp> ("TechDraw"); //HLR
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawAdvancedImp> ("TechDraw"); //Advanced
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawGeneralImp>("TechDraw"); //General
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawScaleImp>("TechDraw"); //Scale
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawDimensionsImp>("TechDraw");//Dimensions
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawAnnotationImp>("TechDraw");//Annotation
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawColorsImp>("TechDraw"); //Colors
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawHLRImp>("TechDraw"); //HLR
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawAdvancedImp>("TechDraw"); //Advanced
// add resources and reloads the translators
loadTechDrawResource();

View File

@@ -453,7 +453,11 @@ SET(TechDrawGuiIcon_SVG
##install OSIFONT
SET(TechDrawGuiFonts
Resources/fonts/osifont-lgpl3fe.ttf
Resources/fonts/osifont-italic.ttf
Resources/fonts/osifont.license
Resources/fonts/Y14.5-2018.ttf
Resources/fonts/Y14.5Font.license
Resources/fonts/Y14.5-FreeCAD.ttf
)
if(FREECAD_USE_PCH)

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,8 @@
ASME Y14.5 Font License
Original Y14.5-2018.ttf courtesy of Peter Kanold (https://peterkanold.com/)
"This font is free to use for all personal and commercial applications. Copying and redistribution of the font is encouraged. Credit to me as the creator of the font is appreciated but not necessary."
Modified 2023 for the FreeCAD CAx development system by WandererFan (wandererfan@gmail.com). Modifications are distributed under LGPL2 or later.