Commits

anatoly techtonik  committed 2a7103e

Add charset information.

  • Participants
  • Parent commits 36d864d

Comments (0)

Files changed (1)

File fontquery.py

 TCHAR = wintypes.CHAR
 BYTE = ctypes.c_ubyte   # http://bugs.python.org/issue16376
 
+# charset codes for LOGFONT structure
+ANSI_CHARSET    = 0
+ARABIC_CHARSET  = 178
+BALTIC_CHARSET  = 186
+CHINESEBIG5_CHARSET = 136
+DEFAULT_CHARSET = 1
+  # - charset for current system locale -
+  #   means function can be called several times
+  #   for the single font (for each charset)
+EASTEUROPE_CHARSET = 238
+GB2312_CHARSET = 134
+GREEK_CHARSET  = 161
+HANGUL_CHARSET = 129
+HEBREW_CHARSET = 177
+JOHAB_CHARSET  = 130
+MAC_CHARSET = 77
+OEM_CHARSET = 255  # OS dependent system charset
+RUSSIAN_CHARSET  = 204
+SHIFTJIS_CHARSET = 128
+SYMBOL_CHARSET   = 2
+THAI_CHARSET     = 222
+TURKISH_CHARSET  = 162
+VIETNAMESE_CHARSET = 163
+
+# build lookup dictionary to get charset name from its code
+CHARSET_NAMES = {}
+for (name, value) in locals().copy().items():
+  if name.endswith('_CHARSET'):
+    CHARSET_NAMES[value] = name
+
 
 class LOGFONT(ctypes.Structure):
   # EnumFontFamiliesEx examines only 3 fields:
     ('lfUnderline', BYTE),
     ('lfStrikeOut', BYTE),
     ('lfCharSet',   BYTE),
-      # 0    ANSI_CHARSET
-      # 186  BALTIC_CHARSET
-      # 136  CHINESEBIG5_CHARSET
-      # 1    DEFAULT_CHARSET     - charset for current system locale -
-      #                       means function can be called several times
-      #                       for the single font (for each charset) [ ]
-      # 238  EASTEUROPE_CHARSET
-      # 134  GB2312_CHARSET
-      # 161  GREEK_CHARSET
-      # 129  HANGUL_CHARSET
-      # 77   MAC_CHARSET
-      # 255  OEM_CHARSET         - OS dependent system charset
-      # 204  RUSSIAN_CHARSET
-      # 128  SHIFTJIS_CHARSET
-      # 2    SYMBOL_CHARSET
-      # 162  TURKISH_CHARSET
-      # 163  VIETNAMESE_CHARSET
+      # ANSI_CHARSET, BALTIC_CHARSET, ... - see *_CHARSET constants above
     ('lfOutPrecision', BYTE),
       # many constants how the output must match height, width, pitch etc.
       # OUT_DEFAULT_PRECIS