Skip to content

Commit

Permalink
feat: 字体安装器版权\许可证信息展示
Browse files Browse the repository at this point in the history
字体安装器版权\许可证信息展示

Log: 字体安装器版权\许可证信息展示
  • Loading branch information
myk1343 committed Mar 12, 2024
1 parent 2ac23f7 commit e92f4b6
Show file tree
Hide file tree
Showing 48 changed files with 1,496 additions and 354 deletions.
54 changes: 54 additions & 0 deletions deepin-font-manager/views/dfontinfoscrollarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <DApplication>

#include <QTimer>
#include "freetype/ftsnames.h"
#include "freetype/ttnameid.h"
QString convertToUtf8(unsigned char *content, unsigned int len);

#define LAEBL_TEXT_WIDTH 165
#define TITLE_VISIBLE_WIDTH 90
Expand Down Expand Up @@ -45,6 +48,10 @@ dfontinfoscrollarea::dfontinfoscrollarea(DFontPreviewItemData *pData, DWidget *
*************************************************************************/
void dfontinfoscrollarea::initUi()
{
QStringList sFontList;
sFontList << "Bitstream Charter-Regular" << "Bitstream Charter-Bold" << "Bitstream Charter-Italic"
<<"Bitstream Charter-Bold Italic" << "Courier 10 Pitch-Italic" << "Courier 10 Pitch-Bold Italic"
<< "Courier 10 Pitch-Regular" << "Courier 10 Pitch-Bold";
auto gridLayout = new QGridLayout;
gridLayout->setContentsMargins(0, 6, 0, 6);
gridLayout->setSpacing(3);
Expand All @@ -70,7 +77,54 @@ void dfontinfoscrollarea::initUi()
createLabel(gridLayout, 4, DApplication::translate("FontDetailDailog", "Full name"), m_fontInfo->fontInfo.fullname);
createLabel(gridLayout, 5, DApplication::translate("FontDetailDailog", "Ps name"), m_fontInfo->fontInfo.psname);
createLabel(gridLayout, 6, DApplication::translate("FontDetailDailog", "Trademark"), m_fontInfo->fontInfo.trademark);
//获取 LICENSE
FT_Library library = nullptr;
FT_Init_FreeType(&library);
FT_Face face = nullptr;
FT_Error error = FT_New_Face(library, m_fontInfo->fontInfo.filePath.toUtf8().constData(), 0, &face);
QString sLicense = "";
if (error == 0) {
if (FT_IS_SFNT(face)) {
FT_SfntName sname;
const unsigned int count = FT_Get_Sfnt_Name_Count(face);
for (unsigned int i = 0; i < count; ++i) {
if (FT_Get_Sfnt_Name(face, i, &sname) != 0) {
continue;
}

// only handle the unicode names for US langid.
if (sname.language_id == 0) {
continue;
}
bool bExitLoop = false;
switch (sname.name_id) {
// 0
case TT_NAME_ID_LICENSE: {
sLicense = convertToUtf8(sname.string, sname.string_len).simplified();
bExitLoop = true;
break;
}
default:
break;
}
if(bExitLoop) break;
}
}
}
FT_Done_Face(face);
FT_Done_FreeType(library);
if(sFontList.contains(m_fontInfo->fontData.strFontName)) {
QString version = "Copyright 1989-1992, Bitstream Inc., Cambridge, MA.";
QString sLicenseDes = "You are hereby granted permission under all Bitstream propriety rights to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream Charter (r) \
Type 1 outline fonts and the 4 Courier Type 1 outline fonts for any purpose and without restriction; \
provided, that this notice is left intact on all copies of such fonts and that Bitstream's trademark is acknowledged as shown below on all unmodified copies of the 4 Charter Type 1 fonts. \
BITSTREAM CHARTER is a registered trademark of Bitstream Inc.";
createLabel(gridLayout, 7, DApplication::translate("FontDetailDailog", "Copyright"), m_fontInfo->fontInfo.copyright.isEmpty()?version:m_fontInfo->fontInfo.copyright);
createLabel(gridLayout, 8, DApplication::translate("FontDetailDailog", "License Description"), sLicense.isEmpty()?sLicenseDes:sLicense);
} else {
createLabel(gridLayout, 7, DApplication::translate("FontDetailDailog", "Copyright"), m_fontInfo->fontInfo.copyright.isEmpty()?DApplication::translate("FontDetailDailog", "Unknown"):m_fontInfo->fontInfo.copyright);
createLabel(gridLayout, 8, DApplication::translate("FontDetailDailog", "License Description"), sLicense.isEmpty()?DApplication::translate("FontDetailDailog", "Unknown"):sLicense);
}
auto vLayout = new QVBoxLayout;
vLayout->setContentsMargins(10, 10, 10, 10);
basicLabel = new DLabel(DApplication::translate("FontDetailDailog", "Basic info"));
Expand Down
28 changes: 26 additions & 2 deletions translations/deepin-font-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@
<source>Failed to install %1 fonts. There is not enough disk space.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fonts</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DFontWidget</name>
<message>
<source>Broken file</source>
<translation type="unfinished">Broken file</translation>
</message>
</context>
<context>
<name>DeleteConfirmDailog</name>
Expand Down Expand Up @@ -213,15 +224,20 @@
</message>
<message>
<source>Exit</source>
<comment>button</comment>
<translation type="unfinished">Exit</translation>
</message>
<message>
<source>Continue</source>
<comment>button</comment>
<translation type="unfinished">Continue</translation>
</message>
</context>
<context>
<name>Font</name>
<message>
<source>Don&apos;t let your dreams be dreams</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FontDetailDailog</name>
<message>
Expand Down Expand Up @@ -260,6 +276,14 @@
<source>Trademark</source>
<translation>Trademark</translation>
</message>
<message>
<source>Copyright</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>License Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Main</name>
Expand Down
18 changes: 16 additions & 2 deletions translations/deepin-font-manager_am_ET.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@
<source>Fonts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to install %1 font. There is not enough disk space.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to install %1 fonts. There is not enough disk space.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DFontWidget</name>
Expand Down Expand Up @@ -216,12 +224,10 @@
</message>
<message>
<source>Exit</source>
<comment>button</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Continue</source>
<comment>button</comment>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down Expand Up @@ -270,6 +276,14 @@
<source>Basic info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copyright</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>License Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Main</name>
Expand Down
72 changes: 49 additions & 23 deletions translations/deepin-font-manager_ar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="ar">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ar">
<context>
<name>Category</name>
<message>
Expand Down Expand Up @@ -42,7 +44,7 @@
<name>DFDeleteTTCDialog</name>
<message>
<source>%1 is a font family, if you proceed, all fonts in it will be deleted</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete</source>
Expand All @@ -54,11 +56,11 @@
<name>DFDisableTTCDialog</name>
<message>
<source>%1 is a font family, if you proceed, all fonts in it will be enabled</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 is a font family, if you proceed, all fonts in it will be disabled</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable</source>
Expand All @@ -75,7 +77,7 @@
<name>DFHandleTTCDialog</name>
<message>
<source>Apply to all selected font families</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
Expand Down Expand Up @@ -145,19 +147,30 @@
</message>
<message>
<source>Alt+M</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>CTRL+I</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to install %1 font. There is not enough disk space.</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to install %1 fonts. There is not enough disk space.</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fonts</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DFontWidget</name>
<message>
<source>Broken file</source>
<translation type="unfinished">ملف معطوب</translation>
</message>
</context>
<context>
Expand All @@ -172,19 +185,19 @@
</message>
<message>
<source>The other %1 system fonts cannot be deleted</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>The font &quot;%1&quot; in use cannot be deleted</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>The other %1 system fonts and the font &quot;%2&quot; in use cannot be deleted</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to delete %1 font(s)?</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete</source>
Expand All @@ -211,13 +224,18 @@
</message>
<message>
<source>Exit</source>
<comment>button</comment>
<translation>خروج</translation>
<translation type="unfinished">خروج</translation>
</message>
<message>
<source>Continue</source>
<comment>button</comment>
<translation>تأكيد</translation>
<translation type="unfinished">تأكيد</translation>
</message>
</context>
<context>
<name>Font</name>
<message>
<source>Don&apos;t let your dreams be dreams</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -258,6 +276,14 @@
<source>Trademark</source>
<translation>العلامة التجارية</translation>
</message>
<message>
<source>Copyright</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>License Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Main</name>
Expand All @@ -283,11 +309,11 @@
</message>
<message>
<source>Failed to export 1 font. There is not enough disk space.</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to export %1 fonts. There is not enough disk space.</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -341,15 +367,15 @@
</message>
<message>
<source>%1 is in use, so you cannot disable it</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>You cannot disable system fonts and the fonts in use</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
<message>
<source>You cannot disable system fonts</source>
<translation type="unfinished"/>
<translation type="unfinished"></translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -447,4 +473,4 @@
<translation>أدخل معاينة النص</translation>
</message>
</context>
</TS>
</TS>
Loading

0 comments on commit e92f4b6

Please sign in to comment.