Cum să lucrați cu tipul 1 fonturi în Python
PostScript Type 1 a fost formatul de font profesional dominant înainte de TrueType și OpenTybe. Aspose.Font FOSS for Python supports loading Type 1 fonts via FontLoader.open() cu: detectarea automată a formatului.
Ghid pas cu pas
Pasul 1: Instalați pachetul
pip install "aspose-font>=1.0.0"Pasul 2: Importarea clasei necesare
from aspose_font.loader import FontLoader
from aspose_font.converter import FontConverter
from aspose_font import FontTypePasul 3: Încărcarea tipului 1 de font
font = FontLoader.open("MyFont.pfb")
print(font.font_name)
print(font.num_glyphs)Pasul 4: Convertiți tipul 1 în TTF
from aspose_font.loader import FontLoader
from aspose_font.converter import FontConverter
from aspose_font import FontType
font = FontLoader.open("MyFont.pfb")
ttf = FontConverter.convert(font, FontType.TTF)Pasul 5: Accesarea Glyph Outlines
from aspose_font.loader import FontLoader
font = FontLoader.open("MyFont.pfb")
glyph = font.glyph_accessor.get_glyph_by_unicode(0x0041) # 'A'
print(glyph.glyph_id)Probleme comune şi soluţii
Font nu se încarcă cu: .afm dosar Tipul 1 de tipuri de scris vine adesea în perechi (.pfb + .afm). Treci pe . .pfb dosar la FontLoader.open().- Ce ? .afm fişierul metric este citit automat. dacă este prezent în același registru.
Glifuri lipsă după conversie Unele tipuri de font 1 folosesc vectori de codificare ne-standard. Inspecție font.encoding înainte de a se converti.
Întrebări frecvente
Ce extensii de fişier foloseşte tipul 1?
Cele mai frecvente extensii sunt: .pfb (binar) și .pfa Ambele sunt suportate.
Pot să convertesc tipul 1 în WOFF2?
- Da, am fost.
FontConverter.convert(font, FontType.WOFF2)funcționează cu orice încărcatFontinclusiv: Tipul 1.