MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / Font

Class Font

src/__init__.py:8178–8430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8176
8177
8178class Font:
8179
8180 def __del__(self):
8181 if type(self) is not Font:
8182 return None
8183
8184 def __init__(
8185 self,
8186 fontname=None,
8187 fontfile=None,
8188 fontbuffer=None,
8189 script=0,
8190 language=None,
8191 ordering=-1,
8192 is_bold=0,
8193 is_italic=0,
8194 is_serif=0,
8195 embed=1,
8196 ):
8197
8198 if fontbuffer:
8199 if hasattr(fontbuffer, "getvalue"):
8200 fontbuffer = fontbuffer.getvalue()
8201 elif isinstance(fontbuffer, bytearray):
8202 fontbuffer = bytes(fontbuffer)
8203 if not isinstance(fontbuffer, bytes):
8204 raise ValueError("bad type: 'fontbuffer'")
8205
8206 if isinstance(fontname, str):
8207 fname_lower = fontname.lower()
8208 if "/" in fname_lower or "\\" in fname_lower or "." in fname_lower:
8209 message("Warning: did you mean a fontfile?")
8210
8211 if fname_lower in ("cjk", "china-t", "china-ts"):
8212 ordering = 0
8213
8214 elif fname_lower.startswith("china-s"):
8215 ordering = 1
8216 elif fname_lower.startswith("korea"):
8217 ordering = 3
8218 elif fname_lower.startswith("japan"):
8219 ordering = 2
8220 elif fname_lower in fitz_fontdescriptors.keys():
8221 import pymupdf_fonts # optional fonts
8222 fontbuffer = pymupdf_fonts.myfont(fname_lower) # make a copy
8223 fontname = None # ensure using fontbuffer only
8224 del pymupdf_fonts # remove package again
8225
8226 elif ordering < 0:
8227 fontname = Base14_fontdict.get(fontname, fontname)
8228
8229 lang = mupdf.fz_text_language_from_string(language)
8230 font = JM_get_font(fontname, fontfile,
8231 fontbuffer, script, lang, ordering,
8232 is_bold, is_italic, is_serif, embed)
8233 self.this = font
8234
8235 def __repr__(self):

Callers 8

build_subsetMethod · 0.85
repl_fontnamesMethod · 0.85
appendMethod · 0.85
fill_textboxMethod · 0.85
_get_font_propertiesFunction · 0.85
fill_textboxFunction · 0.85
build_subsetFunction · 0.85
repl_fontnamesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…