跳转至

Defines

Defines

Template type define

WMTemplateType

Bases: Enum

watermark template types

Source code in textwatermark/template_type.py
Python
@unique
class WMTemplateType(Enum):
    """watermark template types"""

    # WMMethod.INSERT_INTO_POSITION
    # 不可见字符
    INVISIBLE_CHARS = invisible_chars
    """Invisible characters
    Notes: WMMethod.INSERT_INTO_POSITION
        WMMethod.INSERT_INTO_POSITION"""

    # 空白字符
    WHITESPACE_CHARS = whitespace_chars
    """White space characters
    Notes: WMMethod.INSERT_INTO_POSITION
        WMMethod.INSERT_INTO_POSITION"""

    # HTML空白标签
    HTML_EMPTY_TAGS = html_empty_tags
    """HTML empty tags
    Notes: WMMethod.INSERT_INTO_POSITION
        WMMethod.INSERT_INTO_POSITION"""

    # WMMethod.FIND_AND_REPLACE
    SPACE_CHARS = space_chars
    """Space characters
    Notes: WMMethod.FIND_AND_REPLACE
        WMMethod.FIND_AND_REPLACE"""

    # 同形异义字-数字
    HOMOGRAPH_NUMBERS = homograph_numbers
    """Homograph numbers
    Notes: WMMethod.FIND_AND_REPLACE
        WMMethod.FIND_AND_REPLACE"""

    # 同形异义字-英文
    HOMOGRAPH_LETTERS = homograph_letters
    """Homograph letters
    Notes: WMMethod.FIND_AND_REPLACE
        WMMethod.FIND_AND_REPLACE"""

    # 同形异义字-符号
    HOMOGRAPH_PUNCTUATIONS = homograph_punctuations
    """Homograph punctuations
    Notes: WMMethod.FIND_AND_REPLACE
        WMMethod.FIND_AND_REPLACE"""

    # 同形异义字-汉字
    HOMOGRAPH_CHINESE = homograph_chinese
    """Homograph Chinese
    Notes: WMMethod.FIND_AND_REPLACE
        WMMethod.FIND_AND_REPLACE"""

    # 繁体字
    # TRADITIONAL_CHINESE = 3007
    # 错别字-汉字
    # WRONG_CHINESE = 3008
    # 错别字-单词
    # WRONG_WORDS = 3009
    # 同义替换-数字
    # SYNONYM_NUMBERS = 3010
    # 同义替换-汉字
    # SYNONYM_CHINESE = 3011
    # 同义替换-单词
    # SYNONYM_WORDS = 3012

    # WMMethod.APPEND_TO_CHAR
    # 组合字符
    COMBINING_CHARS = combining_chars
    """Combining characters
    Notes: WMMethod.APPEND_TO_CHAR
        WMMethod.APPEND_TO_CHAR"""

    # WMMethod.DECORATE_EACH_CHAR
    # 字体颜色
    FONT_COLOR = font_color
    """Font color
    Notes: WMMethod.DECORATE_EACH_CHAR
        WMMethod.DECORATE_EACH_CHAR"""

    # 字体大小
    FONT_SIZE = font_size
    """Font size
    Notes: WMMethod.DECORATE_EACH_CHAR
        WMMethod.DECORATE_EACH_CHAR"""
    # 字体粗细
    FONT_WEIGHT = font_weight
    """Font weight
    Notes: WMMethod.DECORATE_EACH_CHAR
        WMMethod.DECORATE_EACH_CHAR"""

    # 字体浮动
    FONT_FLOAT = font_float
    """Font float
    Notes: WMMethod.DECORATE_EACH_CHAR
        WMMethod.DECORATE_EACH_CHAR"""

    # 字体样式
    FONT_STYLE = font_style
    """Font style
    Notes: WMMethod.DECORATE_EACH_CHAR
        WMMethod.DECORATE_EACH_CHAR"""

    # WMMethod.APPEND_AS_BINARY

    BINARY_REPRESENTATION = binary_representation
    """Delete character
    Notes: WMMethod.APPEND_AS_BINARY
        WMMethod.APPEND_AS_BINARY"""

INVISIBLE_CHARS = invisible_chars class-attribute

Invisible characters

WMMethod.INSERT_INTO_POSITION

WMMethod.INSERT_INTO_POSITION

WHITESPACE_CHARS = whitespace_chars class-attribute

White space characters

WMMethod.INSERT_INTO_POSITION

WMMethod.INSERT_INTO_POSITION

HTML_EMPTY_TAGS = html_empty_tags class-attribute

HTML empty tags

WMMethod.INSERT_INTO_POSITION

WMMethod.INSERT_INTO_POSITION

SPACE_CHARS = space_chars class-attribute

Space characters

WMMethod.FIND_AND_REPLACE

WMMethod.FIND_AND_REPLACE

HOMOGRAPH_NUMBERS = homograph_numbers class-attribute

Homograph numbers

WMMethod.FIND_AND_REPLACE

WMMethod.FIND_AND_REPLACE

HOMOGRAPH_LETTERS = homograph_letters class-attribute

Homograph letters

WMMethod.FIND_AND_REPLACE

WMMethod.FIND_AND_REPLACE

HOMOGRAPH_PUNCTUATIONS = homograph_punctuations class-attribute

Homograph punctuations

WMMethod.FIND_AND_REPLACE

WMMethod.FIND_AND_REPLACE

HOMOGRAPH_CHINESE = homograph_chinese class-attribute

Homograph Chinese

WMMethod.FIND_AND_REPLACE

WMMethod.FIND_AND_REPLACE

COMBINING_CHARS = combining_chars class-attribute

Combining characters

WMMethod.APPEND_TO_CHAR

WMMethod.APPEND_TO_CHAR

FONT_COLOR = font_color class-attribute

Font color

WMMethod.DECORATE_EACH_CHAR

WMMethod.DECORATE_EACH_CHAR

FONT_SIZE = font_size class-attribute

Font size

WMMethod.DECORATE_EACH_CHAR

WMMethod.DECORATE_EACH_CHAR

FONT_WEIGHT = font_weight class-attribute

Font weight

WMMethod.DECORATE_EACH_CHAR

WMMethod.DECORATE_EACH_CHAR

FONT_FLOAT = font_float class-attribute

Font float

WMMethod.DECORATE_EACH_CHAR

WMMethod.DECORATE_EACH_CHAR

FONT_STYLE = font_style class-attribute

Font style

WMMethod.DECORATE_EACH_CHAR

WMMethod.DECORATE_EACH_CHAR

BINARY_REPRESENTATION = binary_representation class-attribute

Delete character

WMMethod.APPEND_AS_BINARY

WMMethod.APPEND_AS_BINARY

Defines

WMMode

Bases: IntEnum

An enumerarion of watermark mode

Source code in textwatermark/defines.py
Python
@unique
class WMMode(IntEnum):
    """An enumerarion of watermark mode"""

    REAL_NUMBER: int = 1
    """Real numbers, which will be represented directly by binary values, 
        with the smallest length"""

    LETTERS_LOWER_CASE: int = 2
    """Lowercase letters, each letter is represented by 5 binary bytes"""

    LETTERS_UPPER_CASE: int = 3
    """Uppercase letters, each letter is represented by 5 binary bytes"""

    LETTERS_MIXED_CASE: int = 4
    """Mixed case letters, each character is represented by 6 binary bytes"""

    ALPHA_NUMERICAL: int = 5
    """Uppercase and lowercase letters + numbers, each character is represented by 6 binary bytes"""

    ALPHA_NUMERICAL_SPECIAL: int = 6
    """Uppercase and lowercase letters + numbers + special symbols, 
        each character is represented by 7 binary bytes"""

    UNICODE: int = 7
    """Arbitrary Unicode characters, expressed in UTF-8 encoding"""

REAL_NUMBER: int = 1 class-attribute

Real numbers, which will be represented directly by binary values, with the smallest length

LETTERS_LOWER_CASE: int = 2 class-attribute

Lowercase letters, each letter is represented by 5 binary bytes

LETTERS_UPPER_CASE: int = 3 class-attribute

Uppercase letters, each letter is represented by 5 binary bytes

LETTERS_MIXED_CASE: int = 4 class-attribute

Mixed case letters, each character is represented by 6 binary bytes

ALPHA_NUMERICAL: int = 5 class-attribute

Uppercase and lowercase letters + numbers, each character is represented by 6 binary bytes

ALPHA_NUMERICAL_SPECIAL: int = 6 class-attribute

Uppercase and lowercase letters + numbers + special symbols, each character is represented by 7 binary bytes

UNICODE: int = 7 class-attribute

Arbitrary Unicode characters, expressed in UTF-8 encoding

WMMethod

Bases: IntEnum

Watermark insert methods

Source code in textwatermark/defines.py
Python
@unique
class WMMethod(IntEnum):
    """Watermark insert methods"""

    # 查找特定字符并替换成水印字符
    FIND_AND_REPLACE: int = 1
    """Find specific characters and replace with watermark characters"""

    # 在指定位置插入不可见水印
    INSERT_INTO_POSITION: int = 2
    """Insert an invisible watermark at the specified position"""

    # 对文本中的字符进行修饰
    DECORATE_EACH_CHAR: int = 3
    """Decorate characters in text"""

    # 在字符后添加单个水印
    APPEND_TO_CHAR: int = 4
    """Add one watermark byte after one character"""

    # 以二进制形式在字符后面添加水印字符
    APPEND_AS_BINARY: int = 5
    """Add one watermark byte after one character, in binary"""

FIND_AND_REPLACE: int = 1 class-attribute

Find specific characters and replace with watermark characters

INSERT_INTO_POSITION: int = 2 class-attribute

Insert an invisible watermark at the specified position

DECORATE_EACH_CHAR: int = 3 class-attribute

Decorate characters in text

APPEND_TO_CHAR: int = 4 class-attribute

Add one watermark byte after one character

APPEND_AS_BINARY: int = 5 class-attribute

Add one watermark byte after one character, in binary

WhiteSpaceChars

Bases: Enum

Defines of white space chars

From: https://jkorpela.fi/chars/spaces.html

Source code in textwatermark/defines.py
Python
@unique
class WhiteSpaceChars(Enum):
    """Defines of white space chars

    From: <https://jkorpela.fi/chars/spaces.html>
    """

    SPACE_1_4: str = "\u0020"
    """Depends on font, typically 1/4 em, often adjusted"""

    NO_BREAK_SPACE_1_4: str = "\u00A0"
    """As a space, but often not adjusted"""

    EN_QUAD_1_2: str = "\u2000"
    """1 en (= 1/2 em)"""

    EM_QUAD_1: str = "\u2001"
    """	1 em (nominally, the height of the font)"""

    EN_SPACE_1_2: str = "\u2002"
    """1 en (= 1/2 em)"""

    EM_SPACE_1: str = "\u2003"
    """1 em"""

    THREE_PER_EM_SPACE_1_3: str = "\u2004"
    """1/3 em"""

    FOUR_PER_EM_SPACE_1_4: str = "\u2005"
    """1/4 em"""

    SIX_PER_EM_SPACE_1_6: str = "\u2006"
    """1/6 em"""

    FIGURE_SPACE_LIKE_DIGITS: str = "\u2007"
    """“Tabular width”, the width of digits"""

    PUNCTUATION_SPACE_LIKE_DOT: str = "\u2008"
    """The width of a period “.”"""

    THIN_SPACE_1_6: str = "\u2009"
    """	1/5 em (or sometimes 1/6 em)"""

    HAIR_SPACE_1_8: str = "\u200A"
    """Narrower than `THIN SPACE`"""

    NARROW_NO_BREAK_SPACE_1_6: str = "\u202F"
    """Narrower than `NO-BREAK SPACE` (or `SPACE`), 
    “typically the width of a thin space or a mid space”"""

    MEDIUM_MATHEMATICAL_SPACE_2_9: str = "\u205F"
    """4/18 em"""

SPACE_1_4: str = ' ' class-attribute

Depends on font, typically 1/4 em, often adjusted

NO_BREAK_SPACE_1_4: str = '\xa0' class-attribute

As a space, but often not adjusted

EN_QUAD_1_2: str = '\u2000' class-attribute

1 en (= 1/2 em)

EM_QUAD_1: str = '\u2001' class-attribute

1 em (nominally, the height of the font)

EN_SPACE_1_2: str = '\u2002' class-attribute

1 en (= 1/2 em)

EM_SPACE_1: str = '\u2003' class-attribute

1 em

THREE_PER_EM_SPACE_1_3: str = '\u2004' class-attribute

1/3 em

FOUR_PER_EM_SPACE_1_4: str = '\u2005' class-attribute

1/4 em

SIX_PER_EM_SPACE_1_6: str = '\u2006' class-attribute

1/6 em

FIGURE_SPACE_LIKE_DIGITS: str = '\u2007' class-attribute

“Tabular width”, the width of digits

PUNCTUATION_SPACE_LIKE_DOT: str = '\u2008' class-attribute

The width of a period “.”

THIN_SPACE_1_6: str = '\u2009' class-attribute

1/5 em (or sometimes 1/6 em)

HAIR_SPACE_1_8: str = '\u200a' class-attribute

Narrower than THIN SPACE

NARROW_NO_BREAK_SPACE_1_6: str = '\u202f' class-attribute

Narrower than NO-BREAK SPACE (or SPACE), “typically the width of a thin space or a mid space”

MEDIUM_MATHEMATICAL_SPACE_2_9: str = '\u205f' class-attribute

4/18 em