C++ का उपयोग करके फ़ॉन्ट मेट्रिक्स कैसे प्राप्त करें

इस विषय में, हम यह पता लगाएंगे कि C++ का उपयोग करके *फ़ॉन्ट मेट्रिक्स कैसे प्राप्त करें। फ़ॉन्ट मेट्रिक्स में फ़ॉन्ट फ़ाइल में ग्लिफ़ के बारे में जानकारी शामिल होती है। आप कुछ एपीआई कॉल के साथ C++ का उपयोग करके आसानी से *फ़ॉन्ट मेट्रिक्स निकाल सकते हैं, अन्यथा फ़ॉन्ट मेट्रिक्स के बारे में जानकारी प्राप्त करना इतना आसान नहीं है।

C++ का उपयोग करके फ़ॉन्ट मेट्रिक्स प्राप्त करने के चरण

  1. NuGet पैकेज मैनेजर टूल का उपयोग करके Aspose.Font for C++ लाइब्रेरी इंस्टॉल करें
  2. Aspose::Font नाम स्थान का संदर्भ शामिल करें
  3. FontDefinition क्लास ऑब्जेक्ट बनाएं
  4. Type1Font क्लास के ऑब्जेक्ट को इनिशियलाइज़ करें
  5. फ़ॉन्ट मेट्रिक्स के विभिन्न गुण प्राप्त करें

आप कुछ साधारण API कॉलों में C++* का उपयोग करके *फ़ॉन्ट मेट्रिक्स निकाल सकते हैं। आपको बस FontDefinition क्लास इंस्टेंस को एक्सेस करना है और C++ के साथ फॉन्ट मेट्रिक्स को पढ़ना है।

C++ का उपयोग कर फ़ॉन्ट मेट्रिक्स पढ़ने के लिए कोड

#pragma once
#include <cstdint>
#include <stdio.h>
#include <system/console.h>
#include <system/string.h>
#include <system/shared_ptr.h>
#include <system/io/file.h>
#include <system/exceptions.h>
#include <Aspose.Font.Cpp/src/Sources/FontFileDefinition.h>
#include <Aspose.Font.Cpp/src/Sources/FontDefinition.h>
#include <Aspose.Font.Cpp/src/Sources/FileSystemStreamSource.h>
#include <Aspose.Font.Cpp/src/Sources/ByteContentStreamSource.h>
#include <Aspose.Font.Cpp/src/FontType.h>
#include <Aspose.Font.Cpp/src/Font.h>
#include <Aspose.Font.Cpp/src/Cff/CffFont.h>
#include <Aspose.Font.Cpp/src/License.h>
#include <Aspose.Font.Cpp/src/Type1/Type1Font.h>
#include <Aspose.Font.Cpp/src/Font.h>
#include <Aspose.Font.Cpp/src/IFontMetrics.h>
using namespace System;
using namespace Aspose::Font;
using namespace Aspose::Font::Type1;
using namespace Aspose::Font::Cff;
using namespace Aspose::Font::Sources;
class GetFontMetricsEx {
public:
static void GetFontMetricsInfo()
{
// Initialize license object of Aspose.PUB to convert PUB to PDF
auto Fontslicense = System::MakeObject<Aspose::Font::License>();
// Set license
Fontslicense->SetLicense(u"Aspose.Total.NET.lic");
//Font file name with full path
System::String fileName = u"courier.pfb";
System::SharedPtr<FontDefinition> fd =
System::MakeObject<FontDefinition>(Aspose::Font::FontType::Type1,
System::MakeObject<FontFileDefinition>(u"pfb", System::MakeObject<FileSystemStreamSource>(fileName)));
System::SharedPtr<Type1Font> font =
System::DynamicCast_noexcept<Aspose::Font::Type1::Type1Font>(Aspose::Font::Font::Open(fd));
System::String name = font->get_FontName();
System::Console::WriteLine(System::String(u"Font name: ") + name);
System::Console::WriteLine(System::String(u"Glyph count: ") + font->get_NumGlyphs());
System::String metrics = System::String::Format(u"Font metrics: ascender - {0}, descender - {1}, typo ascender = {2}, typo descender = {3}, UnitsPerEm = {4}",
font->get_Metrics()->get_Ascender(), font->get_Metrics()->get_Descender(), font->get_Metrics()->get_TypoAscender(),
font->get_Metrics()->get_TypoDescender(), font->get_Metrics()->get_UnitsPerEM());
System::Console::WriteLine(metrics);
}
};

पहले, हमने सी # में फ़ॉन्ट मीट्रिक कैसे प्राप्त करें सीखा था। हालाँकि, इस विषय में हमने C++* का उपयोग करके *फ़ॉन्ट मेट्रिक्स निकालने का तरीका लागू किया है।

 हिन्दी