-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and add 35 postscript base fonts (fix #1)
- Loading branch information
1 parent
570f745
commit 8d02a11
Showing
40 changed files
with
781 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from .utils import POPPLER_DATA_DIR, _get_root_dirs, _get_root_files | ||
|
||
|
||
def _process_poppler_data(entry): | ||
lines = [ | ||
"# {0}".format(entry), | ||
] | ||
|
||
if entry == "nameToUnicode": | ||
for file in _get_root_files(Path(POPPLER_DATA_DIR, entry)): | ||
lines.append('nameToUnicode "{0}"'.format(file.absolute())) | ||
elif entry == "cidToUnicode": | ||
for file in _get_root_files(Path(POPPLER_DATA_DIR, entry)): | ||
lines.append('cidToUnicode {0} "{1}"'.format(file.name, file.absolute())) | ||
elif entry == "unicodeMap": | ||
for file in _get_root_files(Path(POPPLER_DATA_DIR, entry)): | ||
lines.append('unicodeMap {0} "{1}"'.format(file.name, file.absolute())) | ||
elif entry == "cMap": | ||
for directory in _get_root_dirs(Path(POPPLER_DATA_DIR, entry)): | ||
lines.append( | ||
'cMapDir {0} "{1}"'.format(directory.name, directory.absolute()) | ||
) | ||
|
||
lines.append("") | ||
return lines | ||
|
||
|
||
def _get_encodings_block(): | ||
enc_block = [ | ||
"# Extra Encodings".upper(), | ||
] | ||
for entry in ["nameToUnicode", "cidToUnicode", "unicodeMap", "cMap"]: | ||
enc_block += _process_poppler_data(entry) | ||
enc_block.append("") | ||
return enc_block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from pathlib import Path | ||
|
||
from .utils import FONT_DATA_DIR | ||
|
||
# fmt: off | ||
fonts_mapping = { | ||
"AvantGarde-Book": "URWGothic-Book", | ||
"AvantGarde-BookOblique": "URWGothic-BookOblique", | ||
"AvantGarde-Demi": "URWGothic-Demi", | ||
"AvantGarde-DemiOblique": "URWGothic-DemiOblique", | ||
"Bookman-Demi": "URWBookman-Demi", | ||
"Bookman-DemiItalic": "URWBookman-DemiItalic", | ||
"Bookman-Light": "URWBookman-Light", | ||
"Bookman-LightItalic": "URWBookman-LightItalic", | ||
"Courier": "NimbusMonoPS-Regular", | ||
"Courier-Bold": "NimbusMonoPS-Bold", | ||
"Courier-BoldOblique": "NimbusMonoPS-BoldItalic", | ||
"Courier-Oblique": "NimbusMonoPS-Italic", | ||
"Helvetica": "NimbusSans-Regular", | ||
"Helvetica-Bold": "NimbusSans-Bold", | ||
"Helvetica-BoldOblique": "NimbusSans-BoldItalic", | ||
"Helvetica-Narrow": "NimbusSansNarrow-Regular", | ||
"Helvetica-Narrow-Bold": "NimbusSansNarrow-Bold", | ||
"Helvetica-Narrow-BoldOblique": "NimbusSansNarrow-BdOblique", | ||
"Helvetica-Narrow-Oblique": "NimbusSansNarrow-Oblique", | ||
"Helvetica-Oblique": "NimbusSans-Italic", | ||
"NewCenturySchlbk-Bold": "C059-Bold", | ||
"NewCenturySchlbk-BoldItalic": "C059-BdIta", | ||
"NewCenturySchlbk-Italic": "C059-Italic", | ||
"NewCenturySchlbk-Roman": "C059-Roman", | ||
"Palatino-Bold": "P052-Bold", | ||
"Palatino-BoldItalic": "P052-BoldItalic", | ||
"Palatino-Italic": "P052-Italic", | ||
"Palatino-Roman": "P052-Roman", | ||
"Symbol": "StandardSymbolsPS", | ||
"Times-Bold": "NimbusRoman-Bold", | ||
"Times-BoldItalic": "NimbusRoman-BoldItalic", | ||
"Times-Italic": "NimbusRoman-Italic", | ||
"Times-Roman": "NimbusRoman-Regular", | ||
"ZapfChancery-MediumItalic": "Z003-MediumItalic", | ||
"ZapfDingbats": "D050000L", | ||
} | ||
|
||
|
||
# fmt: on | ||
def get_fonts(): | ||
return { | ||
font: Path(FONT_DATA_DIR, "{0}.ttf".format(fname)) | ||
for font, fname in fonts_mapping.items() | ||
} | ||
|
||
|
||
def _get_fonts_block(): | ||
xpdfrc_fonts = [ | ||
"# 35 PostScript Level 2 base fonts".upper(), | ||
] | ||
for font_name, font_file in get_fonts().items(): | ||
xpdfrc_fonts.append("fontFile {0} {1}".format(font_name, font_file.absolute())) | ||
# extra blank line at end | ||
xpdfrc_fonts.append("") | ||
return xpdfrc_fonts |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.