Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc05767

Browse files
authored
Merge pull request#29828 from anntzer/dvitype
2 parentscf948de +829dcaa commitdc05767

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

‎lib/matplotlib/dviread.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,26 +1108,44 @@ def _fontfile(cls, suffix, texname):
11081108
fromargparseimportArgumentParser
11091109
importitertools
11101110

1111+
importfontTools.agl
1112+
1113+
frommatplotlib.ft2fontimportFT2Font
1114+
frommatplotlib.textpathimportTextToPath
1115+
11111116
parser=ArgumentParser()
11121117
parser.add_argument("filename")
11131118
parser.add_argument("dpi",nargs="?",type=float,default=None)
11141119
args=parser.parse_args()
1120+
1121+
def_print_fields(*args):
1122+
print(" ".join(map("{:>11}".format,args)))
1123+
11151124
withDvi(args.filename,args.dpi)asdvi:
11161125
fontmap=PsfontsMap(find_tex_file('pdftex.map'))
11171126
forpageindvi:
1118-
print(f"===new page === "
1127+
print(f"===NEW PAGE === "
11191128
f"(w:{page.width}, h:{page.height}, d:{page.descent})")
1129+
print("--- GLYPHS ---")
11201130
forfont,groupinitertools.groupby(
11211131
page.text,lambdatext:text.font):
1122-
print(f"font:{font.texname.decode('latin-1')!r}\t"
1123-
f"scale:{font._scale/2**20}")
1124-
print("x","y","glyph","chr","w","(glyphs)",sep="\t")
1132+
psfont=fontmap[font.texname]
1133+
fontpath=psfont.filename
1134+
print(f"font:{font.texname.decode('latin-1')} "
1135+
f"(scale:{font._scale/2**20}) at{fontpath}")
1136+
face=FT2Font(fontpath)
1137+
TextToPath._select_native_charmap(face)
1138+
_print_fields("x","y","glyph","chr","w")
11251139
fortextingroup:
1126-
print(text.x,text.y,text.glyph,
1127-
chr(text.glyph)ifchr(text.glyph).isprintable()
1128-
else".",
1129-
text.width,sep="\t")
1140+
ifpsfont.encoding:
1141+
glyph_name=_parse_enc(psfont.encoding)[text.glyph]
1142+
else:
1143+
glyph_name=face.get_glyph_name(
1144+
face.get_char_index(text.glyph))
1145+
glyph_str=fontTools.agl.toUnicode(glyph_name)
1146+
_print_fields(text.x,text.y,text.glyph,glyph_str,text.width)
11301147
ifpage.boxes:
1131-
print("x","y","h","w","","(boxes)",sep="\t")
1148+
print("--- BOXES ---")
1149+
_print_fields("x","y","h","w")
11321150
forboxinpage.boxes:
1133-
print(box.x,box.y,box.height,box.width,sep="\t")
1151+
_print_fields(box.x,box.y,box.height,box.width)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp