__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
#
# THIS IS WORK IN PROGRESS
#
# The Python Imaging Library
# $Id$
#
# portable compiled font file parser
#
# history:
# 1997-08-19 fl created
# 2003-09-13 fl fixed loading of unicode fonts
#
# Copyright (c) 1997-2003 by Secret Labs AB.
# Copyright (c) 1997-2003 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#
from __future__ import annotations
import io
from typing import BinaryIO, Callable
from . import FontFile, Image
from ._binary import i8
from ._binary import i16be as b16
from ._binary import i16le as l16
from ._binary import i32be as b32
from ._binary import i32le as l32
# --------------------------------------------------------------------
# declarations
PCF_MAGIC = 0x70636601 # "\x01fcp"
PCF_PROPERTIES = 1 << 0
PCF_ACCELERATORS = 1 << 1
PCF_METRICS = 1 << 2
PCF_BITMAPS = 1 << 3
PCF_INK_METRICS = 1 << 4
PCF_BDF_ENCODINGS = 1 << 5
PCF_SWIDTHS = 1 << 6
PCF_GLYPH_NAMES = 1 << 7
PCF_BDF_ACCELERATORS = 1 << 8
BYTES_PER_ROW: list[Callable[[int], int]] = [
lambda bits: ((bits + 7) >> 3),
lambda bits: ((bits + 15) >> 3) & ~1,
lambda bits: ((bits + 31) >> 3) & ~3,
lambda bits: ((bits + 63) >> 3) & ~7,
]
def sz(s: bytes, o: int) -> bytes:
return s[o : s.index(b"\0", o)]
class PcfFontFile(FontFile.FontFile):
"""Font file plugin for the X11 PCF format."""
name = "name"
def __init__(self, fp: BinaryIO, charset_encoding: str = "iso8859-1"):
self.charset_encoding = charset_encoding
magic = l32(fp.read(4))
if magic != PCF_MAGIC:
msg = "not a PCF file"
raise SyntaxError(msg)
super().__init__()
count = l32(fp.read(4))
self.toc = {}
for i in range(count):
type = l32(fp.read(4))
self.toc[type] = l32(fp.read(4)), l32(fp.read(4)), l32(fp.read(4))
self.fp = fp
self.info = self._load_properties()
metrics = self._load_metrics()
bitmaps = self._load_bitmaps(metrics)
encoding = self._load_encoding()
#
# create glyph structure
for ch, ix in enumerate(encoding):
if ix is not None:
(
xsize,
ysize,
left,
right,
width,
ascent,
descent,
attributes,
) = metrics[ix]
self.glyph[ch] = (
(width, 0),
(left, descent - ysize, xsize + left, descent),
(0, 0, xsize, ysize),
bitmaps[ix],
)
def _getformat(
self, tag: int
) -> tuple[BinaryIO, int, Callable[[bytes], int], Callable[[bytes], int]]:
format, size, offset = self.toc[tag]
fp = self.fp
fp.seek(offset)
format = l32(fp.read(4))
if format & 4:
i16, i32 = b16, b32
else:
i16, i32 = l16, l32
return fp, format, i16, i32
def _load_properties(self) -> dict[bytes, bytes | int]:
#
# font properties
properties = {}
fp, format, i16, i32 = self._getformat(PCF_PROPERTIES)
nprops = i32(fp.read(4))
# read property description
p = [(i32(fp.read(4)), i8(fp.read(1)), i32(fp.read(4))) for _ in range(nprops)]
if nprops & 3:
fp.seek(4 - (nprops & 3), io.SEEK_CUR) # pad
data = fp.read(i32(fp.read(4)))
for k, s, v in p:
property_value: bytes | int = sz(data, v) if s else v
properties[sz(data, k)] = property_value
return properties
def _load_metrics(self) -> list[tuple[int, int, int, int, int, int, int, int]]:
#
# font metrics
metrics: list[tuple[int, int, int, int, int, int, int, int]] = []
fp, format, i16, i32 = self._getformat(PCF_METRICS)
append = metrics.append
if (format & 0xFF00) == 0x100:
# "compressed" metrics
for i in range(i16(fp.read(2))):
left = i8(fp.read(1)) - 128
right = i8(fp.read(1)) - 128
width = i8(fp.read(1)) - 128
ascent = i8(fp.read(1)) - 128
descent = i8(fp.read(1)) - 128
xsize = right - left
ysize = ascent + descent
append((xsize, ysize, left, right, width, ascent, descent, 0))
else:
# "jumbo" metrics
for i in range(i32(fp.read(4))):
left = i16(fp.read(2))
right = i16(fp.read(2))
width = i16(fp.read(2))
ascent = i16(fp.read(2))
descent = i16(fp.read(2))
attributes = i16(fp.read(2))
xsize = right - left
ysize = ascent + descent
append((xsize, ysize, left, right, width, ascent, descent, attributes))
return metrics
def _load_bitmaps(
self, metrics: list[tuple[int, int, int, int, int, int, int, int]]
) -> list[Image.Image]:
#
# bitmap data
fp, format, i16, i32 = self._getformat(PCF_BITMAPS)
nbitmaps = i32(fp.read(4))
if nbitmaps != len(metrics):
msg = "Wrong number of bitmaps"
raise OSError(msg)
offsets = [i32(fp.read(4)) for _ in range(nbitmaps)]
bitmap_sizes = [i32(fp.read(4)) for _ in range(4)]
# byteorder = format & 4 # non-zero => MSB
bitorder = format & 8 # non-zero => MSB
padindex = format & 3
bitmapsize = bitmap_sizes[padindex]
offsets.append(bitmapsize)
data = fp.read(bitmapsize)
pad = BYTES_PER_ROW[padindex]
mode = "1;R"
if bitorder:
mode = "1"
bitmaps = []
for i in range(nbitmaps):
xsize, ysize = metrics[i][:2]
b, e = offsets[i : i + 2]
bitmaps.append(
Image.frombytes("1", (xsize, ysize), data[b:e], "raw", mode, pad(xsize))
)
return bitmaps
def _load_encoding(self) -> list[int | None]:
fp, format, i16, i32 = self._getformat(PCF_BDF_ENCODINGS)
first_col, last_col = i16(fp.read(2)), i16(fp.read(2))
first_row, last_row = i16(fp.read(2)), i16(fp.read(2))
i16(fp.read(2)) # default
nencoding = (last_col - first_col + 1) * (last_row - first_row + 1)
# map character code to bitmap index
encoding: list[int | None] = [None] * min(256, nencoding)
encoding_offsets = [i16(fp.read(2)) for _ in range(nencoding)]
for i in range(first_col, len(encoding)):
try:
encoding_offset = encoding_offsets[
ord(bytearray([i]).decode(self.charset_encoding))
]
if encoding_offset != 0xFFFF:
encoding[i] = encoding_offset
except UnicodeDecodeError:
# character is not supported in selected encoding
pass
return encoding
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| BdfFontFile.py | File | 3.4 KB | 0644 |
|
| BlpImagePlugin.py | File | 16.29 KB | 0644 |
|
| BmpImagePlugin.py | File | 19.29 KB | 0644 |
|
| BufrStubImagePlugin.py | File | 1.71 KB | 0644 |
|
| ContainerIO.py | File | 4.5 KB | 0644 |
|
| CurImagePlugin.py | File | 1.75 KB | 0644 |
|
| DcxImagePlugin.py | File | 1.99 KB | 0644 |
|
| DdsImagePlugin.py | File | 16.54 KB | 0644 |
|
| EpsImagePlugin.py | File | 15.98 KB | 0644 |
|
| ExifTags.py | File | 9.7 KB | 0644 |
|
| FitsImagePlugin.py | File | 4.53 KB | 0644 |
|
| FliImagePlugin.py | File | 4.57 KB | 0644 |
|
| FontFile.py | File | 3.49 KB | 0644 |
|
| FpxImagePlugin.py | File | 7.12 KB | 0644 |
|
| FtexImagePlugin.py | File | 3.44 KB | 0644 |
|
| GbrImagePlugin.py | File | 2.94 KB | 0644 |
|
| GdImageFile.py | File | 2.74 KB | 0644 |
|
| GifImagePlugin.py | File | 40.48 KB | 0644 |
|
| GimpGradientFile.py | File | 3.81 KB | 0644 |
|
| GimpPaletteFile.py | File | 1.39 KB | 0644 |
|
| GribStubImagePlugin.py | File | 1.71 KB | 0644 |
|
| Hdf5StubImagePlugin.py | File | 1.71 KB | 0644 |
|
| IcnsImagePlugin.py | File | 12.65 KB | 0644 |
|
| IcoImagePlugin.py | File | 12.18 KB | 0644 |
|
| ImImagePlugin.py | File | 11.17 KB | 0644 |
|
| Image.py | File | 142.7 KB | 0644 |
|
| ImageChops.py | File | 7.76 KB | 0644 |
|
| ImageCms.py | File | 41.03 KB | 0644 |
|
| ImageColor.py | File | 9.22 KB | 0644 |
|
| ImageDraw.py | File | 41.28 KB | 0644 |
|
| ImageDraw2.py | File | 7.06 KB | 0644 |
|
| ImageEnhance.py | File | 3.54 KB | 0644 |
|
| ImageFile.py | File | 25.51 KB | 0644 |
|
| ImageFilter.py | File | 18.27 KB | 0644 |
|
| ImageFont.py | File | 62.75 KB | 0644 |
|
| ImageGrab.py | File | 5.86 KB | 0644 |
|
| ImageMath.py | File | 11.66 KB | 0644 |
|
| ImageMode.py | File | 2.62 KB | 0644 |
|
| ImageMorph.py | File | 8.36 KB | 0644 |
|
| ImageOps.py | File | 24.5 KB | 0644 |
|
| ImagePalette.py | File | 8.79 KB | 0644 |
|
| ImagePath.py | File | 371 B | 0644 |
|
| ImageQt.py | File | 6.67 KB | 0644 |
|
| ImageSequence.py | File | 2.15 KB | 0644 |
|
| ImageShow.py | File | 9.76 KB | 0644 |
|
| ImageStat.py | File | 5.2 KB | 0644 |
|
| ImageTransform.py | File | 3.79 KB | 0644 |
|
| ImageWin.py | File | 7.9 KB | 0644 |
|
| ImtImagePlugin.py | File | 2.6 KB | 0644 |
|
| IptcImagePlugin.py | File | 6.51 KB | 0644 |
|
| Jpeg2KImagePlugin.py | File | 13.56 KB | 0644 |
|
| JpegImagePlugin.py | File | 31.05 KB | 0644 |
|
| JpegPresets.py | File | 12.09 KB | 0644 |
|
| McIdasImagePlugin.py | File | 1.89 KB | 0644 |
|
| MicImagePlugin.py | File | 2.62 KB | 0644 |
|
| MpegImagePlugin.py | File | 2.05 KB | 0644 |
|
| MpoImagePlugin.py | File | 6.07 KB | 0644 |
|
| MspImagePlugin.py | File | 5.74 KB | 0644 |
|
| PSDraw.py | File | 6.75 KB | 0644 |
|
| PaletteFile.py | File | 1.18 KB | 0644 |
|
| PalmImagePlugin.py | File | 9.13 KB | 0644 |
|
| PcdImagePlugin.py | File | 1.55 KB | 0644 |
|
| PcfFontFile.py | File | 6.98 KB | 0644 |
|
| PcxImagePlugin.py | File | 6.1 KB | 0644 |
|
| PdfImagePlugin.py | File | 9.13 KB | 0644 |
|
| PdfParser.py | File | 37.09 KB | 0644 |
|
| PixarImagePlugin.py | File | 1.71 KB | 0644 |
|
| PngImagePlugin.py | File | 49.67 KB | 0644 |
|
| PpmImagePlugin.py | File | 12.06 KB | 0644 |
|
| PsdImagePlugin.py | File | 8.42 KB | 0644 |
|
| QoiImagePlugin.py | File | 4.08 KB | 0644 |
|
| SgiImagePlugin.py | File | 6.57 KB | 0644 |
|
| SpiderImagePlugin.py | File | 9.9 KB | 0644 |
|
| SunImagePlugin.py | File | 4.48 KB | 0644 |
|
| TarIO.py | File | 1.34 KB | 0644 |
|
| TgaImagePlugin.py | File | 6.82 KB | 0644 |
|
| TiffImagePlugin.py | File | 81.44 KB | 0644 |
|
| TiffTags.py | File | 16.68 KB | 0644 |
|
| WalImageFile.py | File | 5.57 KB | 0644 |
|
| WebPImagePlugin.py | File | 9.83 KB | 0644 |
|
| WmfImagePlugin.py | File | 5.02 KB | 0644 |
|
| XVThumbImagePlugin.py | File | 2.06 KB | 0644 |
|
| XbmImagePlugin.py | File | 2.6 KB | 0644 |
|
| XpmImagePlugin.py | File | 3.15 KB | 0644 |
|
| __init__.py | File | 1.96 KB | 0644 |
|
| __main__.py | File | 133 B | 0644 |
|
| _binary.py | File | 2.49 KB | 0644 |
|
| _deprecate.py | File | 1.89 KB | 0644 |
|
| _imaging.cpython-313-x86_64-linux-gnu.so | File | 750.65 KB | 0644 |
|
| _imaging.pyi | File | 868 B | 0644 |
|
| _imagingcms.cpython-313-x86_64-linux-gnu.so | File | 41.73 KB | 0644 |
|
| _imagingcms.pyi | File | 4.29 KB | 0644 |
|
| _imagingft.cpython-313-x86_64-linux-gnu.so | File | 45.63 KB | 0644 |
|
| _imagingft.pyi | File | 1.75 KB | 0644 |
|
| _imagingmath.cpython-313-x86_64-linux-gnu.so | File | 34.48 KB | 0644 |
|
| _imagingmath.pyi | File | 63 B | 0644 |
|
| _imagingmorph.cpython-313-x86_64-linux-gnu.so | File | 14.48 KB | 0644 |
|
| _imagingmorph.pyi | File | 63 B | 0644 |
|
| _imagingtk.pyi | File | 63 B | 0644 |
|
| _tkinter_finder.py | File | 540 B | 0644 |
|
| _typing.py | File | 1.21 KB | 0644 |
|
| _util.py | File | 635 B | 0644 |
|
| _version.py | File | 87 B | 0644 |
|
| _webp.cpython-313-x86_64-linux-gnu.so | File | 23.97 KB | 0644 |
|
| _webp.pyi | File | 63 B | 0644 |
|
| features.py | File | 11 KB | 0644 |
|
| py.typed | File | 0 B | 0644 |
|
| report.py | File | 100 B | 0644 |
|