⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkfont-win32.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 4 页
字号:
/* GDK - The GIMP Drawing Kit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * Copyright (C) 1998-2002 Tor Lillqvist * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. *//* * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS * file for a list of people on the GTK+ Team.  See the ChangeLog * files for a list of changes.  These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/.  */#include <config.h>#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <pango/pangowin32.h>#include "gdkfont.h"#include "gdkpango.h" /* gdk_pango_context_get() */#include "gdkdisplay.h"#include "gdkprivate-win32.h"static GHashTable *font_name_hash = NULL;static GHashTable *fontset_name_hash = NULL;static voidgdk_font_hash_insert (GdkFontType  type,		      GdkFont     *font,		      const gchar *font_name){  GdkFontPrivateWin32 *private = (GdkFontPrivateWin32 *) font;  GHashTable **hashp = (type == GDK_FONT_FONT) ?    &font_name_hash : &fontset_name_hash;  if (!*hashp)    *hashp = g_hash_table_new (g_str_hash, g_str_equal);  private->names = g_slist_prepend (private->names, g_strdup (font_name));  g_hash_table_insert (*hashp, private->names->data, font);}static voidgdk_font_hash_remove (GdkFontType type,		      GdkFont    *font){  GdkFontPrivateWin32 *private = (GdkFontPrivateWin32 *) font;  GSList *tmp_list;  GHashTable *hash = (type == GDK_FONT_FONT) ?    font_name_hash : fontset_name_hash;  tmp_list = private->names;  while (tmp_list)    {      g_hash_table_remove (hash, tmp_list->data);      g_free (tmp_list->data);            tmp_list = tmp_list->next;    }  g_slist_free (private->names);  private->names = NULL;}static GdkFont *gdk_font_hash_lookup (GdkFontType  type,		      const gchar *font_name){  GdkFont *result;  GHashTable *hash = (type == GDK_FONT_FONT) ?    font_name_hash : fontset_name_hash;  if (!hash)    return NULL;  else    {      result = g_hash_table_lookup (hash, font_name);      if (result)	gdk_font_ref (result);            return result;    }}static const char *charset_name (DWORD charset){  switch (charset)    {    case ANSI_CHARSET: return "ansi";    case DEFAULT_CHARSET: return "default";    case SYMBOL_CHARSET: return "symbol";    case SHIFTJIS_CHARSET: return "shiftjis";    case HANGEUL_CHARSET: return "hangeul";    case GB2312_CHARSET: return "gb2312";    case CHINESEBIG5_CHARSET: return "big5";    case JOHAB_CHARSET: return "johab";    case HEBREW_CHARSET: return "hebrew";    case ARABIC_CHARSET: return "arabic";    case GREEK_CHARSET: return "greek";    case TURKISH_CHARSET: return "turkish";    case VIETNAMESE_CHARSET: return "vietnamese";    case THAI_CHARSET: return "thai";    case EASTEUROPE_CHARSET: return "easteurope";    case RUSSIAN_CHARSET: return "russian";    case MAC_CHARSET: return "mac";    case BALTIC_CHARSET: return "baltic";    }  return "unknown";}/* This table classifies Unicode characters according to the Microsoft * Unicode subset numbering. This is based on the table in "Developing * International Software for Windows 95 and Windows NT". This is almost, * but not quite, the same as the official Unicode block table in * Blocks.txt from ftp.unicode.org. The bit number field is the bitfield * number as in the FONTSIGNATURE struct's fsUsb field. * There are some grave bugs in the table in the books. For instance * it claims there are Hangul at U+3400..U+4DFF while this range in * fact contains CJK Unified Ideographs Extension A. Also, the whole * block of Hangul Syllables U+AC00..U+D7A3 is missing from the book. */typedef enum{  U_BASIC_LATIN = 0,  U_LATIN_1_SUPPLEMENT = 1,  U_LATIN_EXTENDED_A = 2,  U_LATIN_EXTENDED_B = 3,  U_IPA_EXTENSIONS = 4,  U_SPACING_MODIFIER_LETTERS = 5,  U_COMBINING_DIACRITICAL_MARKS = 6,  U_BASIC_GREEK = 7,  U_GREEK_SYMBOLS_AND_COPTIC = 8,  U_CYRILLIC = 9,  U_ARMENIAN = 10,  U_HEBREW_EXTENDED = 12,  U_BASIC_HEBREW = 11,  U_BASIC_ARABIC = 13,  U_ARABIC_EXTENDED = 14,  U_DEVANAGARI = 15,  U_BENGALI = 16,  U_GURMUKHI = 17,  U_GUJARATI = 18,  U_ORIYA = 19,  U_TAMIL = 20,  U_TELUGU = 21,  U_KANNADA = 22,  U_MALAYALAM = 23,  U_THAI = 24,  U_LAO = 25,  U_GEORGIAN_EXTENDED = 27,  U_BASIC_GEORGIAN = 26,  U_HANGUL_JAMO = 28,  U_LATIN_EXTENDED_ADDITIONAL = 29,  U_GREEK_EXTENDED = 30,  U_GENERAL_PUNCTUATION = 31,  U_SUPERSCRIPTS_AND_SUBSCRIPTS = 32,  U_CURRENCY_SYMBOLS = 33,  U_COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS = 34,  U_LETTERLIKE_SYMBOLS = 35,  U_NUMBER_FORMS = 36,  U_ARROWS = 37,  U_MATHEMATICAL_OPERATORS = 38,  U_MISCELLANEOUS_TECHNICAL = 39,  U_CONTROL_PICTURES = 40,  U_OPTICAL_CHARACTER_RECOGNITION = 41,  U_ENCLOSED_ALPHANUMERICS = 42,  U_BOX_DRAWING = 43,  U_BLOCK_ELEMENTS = 44,  U_GEOMETRIC_SHAPES = 45,  U_MISCELLANEOUS_SYMBOLS = 46,  U_DINGBATS = 47,  U_CJK_SYMBOLS_AND_PUNCTUATION = 48,  U_HIRAGANA = 49,  U_KATAKANA = 50,  U_BOPOMOFO = 51,  U_HANGUL_COMPATIBILITY_JAMO = 52,  U_CJK_MISCELLANEOUS = 53,  U_ENCLOSED_CJK = 54,  U_CJK_COMPATIBILITY = 55,  U_HANGUL = 56,  U_HANGUL_SUPPLEMENTARY_A = 57,  U_HANGUL_SUPPLEMENTARY_B = 58,  U_CJK_UNIFIED_IDEOGRAPHS = 59,  U_PRIVATE_USE_AREA = 60,  U_CJK_COMPATIBILITY_IDEOGRAPHS = 61,  U_ALPHABETIC_PRESENTATION_FORMS = 62,  U_ARABIC_PRESENTATION_FORMS_A = 63,  U_COMBINING_HALF_MARKS = 64,  U_CJK_COMPATIBILITY_FORMS = 65,  U_SMALL_FORM_VARIANTS = 66,  U_ARABIC_PRESENTATION_FORMS_B = 67,  U_SPECIALS = 69,  U_HALFWIDTH_AND_FULLWIDTH_FORMS = 68,  U_LAST_PLUS_ONE} unicode_subset;static struct {  wchar_t low, high;  unicode_subset bit;   gchar *name;} utab[] ={  { 0x0000, 0x007E,    U_BASIC_LATIN, "Basic Latin" },  { 0x00A0, 0x00FF,    U_LATIN_1_SUPPLEMENT, "Latin-1 Supplement" },  { 0x0100, 0x017F,    U_LATIN_EXTENDED_A, "Latin Extended-A" },  { 0x0180, 0x024F,    U_LATIN_EXTENDED_B, "Latin Extended-B" },  { 0x0250, 0x02AF,    U_IPA_EXTENSIONS, "IPA Extensions" },  { 0x02B0, 0x02FF,    U_SPACING_MODIFIER_LETTERS, "Spacing Modifier Letters" },  { 0x0300, 0x036F,    U_COMBINING_DIACRITICAL_MARKS, "Combining Diacritical Marks" },  { 0x0370, 0x03CF,    U_BASIC_GREEK, "Basic Greek" },  { 0x03D0, 0x03FF,    U_GREEK_SYMBOLS_AND_COPTIC, "Greek Symbols and Coptic" },  { 0x0400, 0x04FF,    U_CYRILLIC, "Cyrillic" },  { 0x0530, 0x058F,    U_ARMENIAN, "Armenian" },  { 0x0590, 0x05CF,    U_HEBREW_EXTENDED, "Hebrew Extended" },  { 0x05D0, 0x05FF,    U_BASIC_HEBREW, "Basic Hebrew" },  { 0x0600, 0x0652,    U_BASIC_ARABIC, "Basic Arabic" },  { 0x0653, 0x06FF,    U_ARABIC_EXTENDED, "Arabic Extended" },  { 0x0900, 0x097F,    U_DEVANAGARI, "Devanagari" },  { 0x0980, 0x09FF,    U_BENGALI, "Bengali" },  { 0x0A00, 0x0A7F,    U_GURMUKHI, "Gurmukhi" },  { 0x0A80, 0x0AFF,    U_GUJARATI, "Gujarati" },  { 0x0B00, 0x0B7F,    U_ORIYA, "Oriya" },  { 0x0B80, 0x0BFF,    U_TAMIL, "Tamil" },  { 0x0C00, 0x0C7F,    U_TELUGU, "Telugu" },  { 0x0C80, 0x0CFF,    U_KANNADA, "Kannada" },  { 0x0D00, 0x0D7F,    U_MALAYALAM, "Malayalam" },  { 0x0E00, 0x0E7F,    U_THAI, "Thai" },  { 0x0E80, 0x0EFF,    U_LAO, "Lao" },  { 0x10A0, 0x10CF,    U_GEORGIAN_EXTENDED, "Georgian Extended" },  { 0x10D0, 0x10FF,    U_BASIC_GEORGIAN, "Basic Georgian" },  { 0x1100, 0x11FF,    U_HANGUL_JAMO, "Hangul Jamo" },  { 0x1E00, 0x1EFF,    U_LATIN_EXTENDED_ADDITIONAL, "Latin Extended Additional" },  { 0x1F00, 0x1FFF,    U_GREEK_EXTENDED, "Greek Extended" },  { 0x2000, 0x206F,    U_GENERAL_PUNCTUATION, "General Punctuation" },  { 0x2070, 0x209F,    U_SUPERSCRIPTS_AND_SUBSCRIPTS, "Superscripts and Subscripts" },  { 0x20A0, 0x20CF,    U_CURRENCY_SYMBOLS, "Currency Symbols" },  { 0x20D0, 0x20FF,    U_COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS, "Combining Diacritical Marks for Symbols" },  { 0x2100, 0x214F,    U_LETTERLIKE_SYMBOLS, "Letterlike Symbols" },  { 0x2150, 0x218F,    U_NUMBER_FORMS, "Number Forms" },  { 0x2190, 0x21FF,    U_ARROWS, "Arrows" },  { 0x2200, 0x22FF,    U_MATHEMATICAL_OPERATORS, "Mathematical Operators" },  { 0x2300, 0x23FF,    U_MISCELLANEOUS_TECHNICAL, "Miscellaneous Technical" },  { 0x2400, 0x243F,    U_CONTROL_PICTURES, "Control Pictures" },  { 0x2440, 0x245F,    U_OPTICAL_CHARACTER_RECOGNITION, "Optical Character Recognition" },  { 0x2460, 0x24FF,    U_ENCLOSED_ALPHANUMERICS, "Enclosed Alphanumerics" },  { 0x2500, 0x257F,    U_BOX_DRAWING, "Box Drawing" },  { 0x2580, 0x259F,    U_BLOCK_ELEMENTS, "Block Elements" },  { 0x25A0, 0x25FF,    U_GEOMETRIC_SHAPES, "Geometric Shapes" },  { 0x2600, 0x26FF,    U_MISCELLANEOUS_SYMBOLS, "Miscellaneous Symbols" },  { 0x2700, 0x27BF,    U_DINGBATS, "Dingbats" },  { 0x3000, 0x303F,    U_CJK_SYMBOLS_AND_PUNCTUATION, "CJK Symbols and Punctuation" },  { 0x3040, 0x309F,    U_HIRAGANA, "Hiragana" },  { 0x30A0, 0x30FF,    U_KATAKANA, "Katakana" },  { 0x3100, 0x312F,    U_BOPOMOFO, "Bopomofo" },  { 0x3130, 0x318F,    U_HANGUL_COMPATIBILITY_JAMO, "Hangul Compatibility Jamo" },  { 0x3190, 0x319F,    U_CJK_MISCELLANEOUS, "CJK Miscellaneous" },  { 0x3200, 0x32FF,    U_ENCLOSED_CJK, "Enclosed CJK" },  { 0x3300, 0x33FF,    U_CJK_COMPATIBILITY, "CJK Compatibility" },  /* The book claims:   * U+3400..U+3D2D = Hangul   * U+3D2E..U+44B7 = Hangul Supplementary A   * U+44B8..U+4DFF = Hangul Supplementary B   * but actually in Unicode   * U+3400..U+4DB5 = CJK Unified Ideographs Extension A   */  { 0x3400, 0x4DB5,    U_CJK_UNIFIED_IDEOGRAPHS, "CJK Unified Ideographs Extension A" },  { 0x4E00, 0x9FFF,    U_CJK_UNIFIED_IDEOGRAPHS, "CJK Unified Ideographs" },  /* This was missing completely from the book's table. */  { 0xAC00, 0xD7A3,    U_HANGUL, "Hangul Syllables" },  { 0xE000, 0xF8FF,    U_PRIVATE_USE_AREA, "Private Use Area" },  { 0xF900, 0xFAFF,    U_CJK_COMPATIBILITY_IDEOGRAPHS, "CJK Compatibility Ideographs" },  { 0xFB00, 0xFB4F,    U_ALPHABETIC_PRESENTATION_FORMS, "Alphabetic Presentation Forms" },  { 0xFB50, 0xFDFF,    U_ARABIC_PRESENTATION_FORMS_A, "Arabic Presentation Forms-A" },  { 0xFE20, 0xFE2F,    U_COMBINING_HALF_MARKS, "Combining Half Marks" },  { 0xFE30, 0xFE4F,    U_CJK_COMPATIBILITY_FORMS, "CJK Compatibility Forms" },  { 0xFE50, 0xFE6F,    U_SMALL_FORM_VARIANTS, "Small Form Variants" },  { 0xFE70, 0xFEFE,    U_ARABIC_PRESENTATION_FORMS_B, "Arabic Presentation Forms-B" },  { 0xFEFF, 0xFEFF,    U_SPECIALS, "Specials" },  { 0xFF00, 0xFFEF,    U_HALFWIDTH_AND_FULLWIDTH_FORMS, "Halfwidth and Fullwidth Forms" },  { 0xFFF0, 0xFFFD,    U_SPECIALS, "Specials" }};static voidprint_unicode_subranges (FONTSIGNATURE *fsp){  int i;  gboolean checked[G_N_ELEMENTS (utab)];  gboolean need_comma = FALSE;  memset (checked, 0, sizeof (checked));  for (i = 0; i < G_N_ELEMENTS (utab); i++)    if (!checked[i]	&& (fsp->fsUsb[utab[i].bit/32] & (1 << (utab[i].bit % 32))))      {	g_print ("%s %s", (need_comma ? "," : ""), utab[i].name);	need_comma = TRUE;	checked[i] = TRUE;      }  if (!need_comma)    g_print (" none!");  g_print ("\n");}static gbooleancheck_unicode_subranges (UINT           charset,			 FONTSIGNATURE *fsp){  gint i;  gboolean retval = FALSE;  /* If the fsUsb bit array has at least one of the bits set, trust it */  for (i = 0; i < U_LAST_PLUS_ONE; i++)    if (i != U_PRIVATE_USE_AREA && (fsp->fsUsb[i/32] & (1 << (i % 32))))      return FALSE;  /* Otherwise, guess what subranges there should be in the font */  fsp->fsUsb[0] = fsp->fsUsb[1] = fsp->fsUsb[2] = fsp->fsUsb[3] = 0;#define set_bit(bitno) (fsp->fsUsb[(bitno)/32] |= (1 << ((bitno) % 32)))  /* Set Unicode subrange bits based on code pages supported.   * This is mostly just guesswork.   */#define check_cp(bit) (fsp->fsCsb[0] & (bit))  if (check_cp(FS_LATIN1))    {      set_bit (U_BASIC_LATIN);      set_bit (U_LATIN_1_SUPPLEMENT);      set_bit (U_CURRENCY_SYMBOLS);      retval = TRUE;    }  if (check_cp (FS_LATIN2))    {      set_bit (U_BASIC_LATIN);      set_bit (U_LATIN_1_SUPPLEMENT);      set_bit (U_LATIN_EXTENDED_A);      set_bit (U_CURRENCY_SYMBOLS);      retval = TRUE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -