diff options
-rw-r--r-- | ChangeLog | 34 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 34 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 34 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 34 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 34 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 34 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 34 | ||||
-rw-r--r-- | examples/viewer-win32.c | 44 | ||||
-rw-r--r-- | modules/basic/basic-win32.c | 6 | ||||
-rw-r--r-- | pango/pango-font.h | 6 | ||||
-rw-r--r-- | pango/pango-utils.c | 231 | ||||
-rw-r--r-- | pango/pango-utils.h | 15 | ||||
-rw-r--r-- | pango/pangowin32-fontmap.c | 397 | ||||
-rw-r--r-- | pango/pangowin32-private.h | 6 | ||||
-rw-r--r-- | pango/pangowin32.c | 16 | ||||
-rw-r--r-- | pango/pangox-fontmap.c | 204 |
16 files changed, 594 insertions, 569 deletions
@@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index bb9cdc0c..93c75e4f 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index bb9cdc0c..93c75e4f 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index bb9cdc0c..93c75e4f 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index bb9cdc0c..93c75e4f 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index bb9cdc0c..93c75e4f 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index bb9cdc0c..93c75e4f 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,37 @@ +2000-07-16 Tor Lillqvist <tml@iki.fi> + + * pango/pango-utils.h + * pango/pango-utils.c + * pango/pangox-fontmap.c + * pango/pangowin32-fontmap.c: Move the get_{style,variant, + weight,stretch} functions to pango-utils.c, and rename + them to pango_parse_*. Would otherwise be duplicated in + pangox and angowin32. + + * pango/pango.def: Export them. + + * pango/pango-font.h: Add PANGO_WEIGHT_ULTRALIGHT, + PANGO_WEIGHT_LIGHT, PANGO_WEIGHT_EXTRABOLD and PANGO_WEIGHT_HEAVY + values to PangoWeight. + * pango/pango-utils.c: Recognize the new weight strings. + + * pango/pangowin32.c (pango_win32_list_subfonts): Don't g_free the + subfont_list from the subfonts_by_subrange hash table... + + * pango/pangowin32-fontmap.c (pango_win32_font_map_read_alias_file): + Also set the other properties in the LOGFONT, not only the face name. + + (pango_win32_insert_font): Insert a pointer to a freshly allocated + LOGFONT in the hash table, not the one passed in as a parameter, + which could be (and in fact, *is*) a pointer to an auto + variable. Quantize the description weight values to exact + PANGO_WEIGHT_* values. + (pango_win32_get_unknown_glyph): Use subfont 1. + + * examples/viewer-win32.c: (split_paragraphs): Don't include the + newline. + (draw): Correct 1st parameter to gdk_win32_hdc_{get,release}. + 2000-07-15 Tor Lillqvist <tml@iki.fi> * pango/pangowin32.h diff --git a/examples/viewer-win32.c b/examples/viewer-win32.c index 9304b7d2..f5007a7d 100644 --- a/examples/viewer-win32.c +++ b/examples/viewer-win32.c @@ -1,4 +1,3 @@ -#define PING() g_print ("%s:%d\n", __PRETTY_FUNCTION__, __LINE__) /* Pango * viewer-win32.c: Example program to view a UTF-8 encoding file * using Pango to render result. @@ -70,7 +69,6 @@ read_file(char *name) char *text; char buffer[BUFSIZE]; - PING(); file = fopen (name, "r"); if (!file) { @@ -128,6 +126,9 @@ split_paragraphs (char *text) Paragraph *para = g_new (Paragraph, 1); para->text = last_para; para->length = p - last_para; + /* Don't include the newline */ + if (wc == '\n') + para->length--; para->layout = pango_layout_new (context); pango_layout_set_text (para->layout, para->text, para->length); para->height = 0; @@ -155,7 +156,6 @@ xy_to_cp (int width, int x, int y, Paragraph **para_return, int *index) *para_return = NULL; - PING(); para_list = paragraphs; while (para_list && height < y) { @@ -174,7 +174,6 @@ xy_to_cp (int width, int x, int y, Paragraph **para_return, int *index) height += para->height; para_list = para_list->next; } - PING(); return FALSE; } @@ -253,7 +252,6 @@ size_allocate (GtkWidget *layout, GtkAllocation *allocation) int height = 0; PangoDirection base_dir = pango_context_get_base_dir (context); - PING(); tmp_list = paragraphs; while (tmp_list) { @@ -287,7 +285,6 @@ draw (GtkWidget *layout, GdkRectangle *area) GList *tmp_list; int height = 0; - PING(); gdk_draw_rectangle (GTK_LAYOUT (layout)->bin_window, layout->style->base_gc[layout->state], TRUE, @@ -296,7 +293,6 @@ draw (GtkWidget *layout, GdkRectangle *area) gdk_gc_set_clip_rectangle (layout->style->text_gc[layout->state], area); - PING(); tmp_list = paragraphs; while (tmp_list && height < area->y + area->height + GTK_LAYOUT (layout)->yoffset) @@ -304,18 +300,17 @@ draw (GtkWidget *layout, GdkRectangle *area) Paragraph *para = tmp_list->data; tmp_list = tmp_list->next; - PING(); if (height + para->height >= GTK_LAYOUT (layout)->yoffset + area->y) { GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_BACKGROUND; - HDC hdc = gdk_win32_hdc_get (GDK_WINDOW_XWINDOW (GTK_LAYOUT (layout)->bin_window), - layout->style->text_gc[GTK_STATE_NORMAL], - mask); - + HDC hdc; + + hdc = gdk_win32_hdc_get (GTK_LAYOUT (layout)->bin_window, + layout->style->text_gc[GTK_STATE_NORMAL], + mask); pango_win32_render_layout (hdc, para->layout, 0, height - GTK_LAYOUT (layout)->yoffset); - - gdk_win32_hdc_release (GDK_WINDOW_XWINDOW (GTK_LAYOUT (layout)->bin_window), + gdk_win32_hdc_release (GTK_LAYOUT (layout)->bin_window, layout->style->text_gc[GTK_STATE_NORMAL], mask); } @@ -323,18 +318,15 @@ draw (GtkWidget *layout, GdkRectangle *area) height += para->height; } - PING(); gdk_gc_set_clip_rectangle (layout->style->text_gc[layout->state], NULL); if (highlight_para) xor_char (layout, area, highlight_para, highlight_offset); - PING(); } gboolean expose (GtkWidget *layout, GdkEventExpose *event) { - PING(); if (event->window == GTK_LAYOUT (layout)->bin_window) draw (layout, &event->area); @@ -348,7 +340,6 @@ button_press (GtkWidget *layout, GdkEventButton *event) int offset; gchar *message; - PING(); xy_to_cp (layout->allocation.width, event->x, event->y + GTK_LAYOUT (layout)->yoffset, ¶, &offset); @@ -371,7 +362,6 @@ button_press (GtkWidget *layout, GdkEventButton *event) else message = g_strdup_printf ("Current char:"); - PING(); gtk_label_set_text (GTK_LABEL (message_label), message); g_free (message); } @@ -381,7 +371,6 @@ checkbutton_toggled (GtkWidget *widget, gpointer data) { GList *para_list; - PING(); pango_context_set_base_dir (context, GTK_TOGGLE_BUTTON (widget)->active ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR); para_list = paragraphs; @@ -401,7 +390,6 @@ reload_font () { GList *para_list; - PING(); pango_context_set_font_description (context, &font_description); para_list = paragraphs; @@ -415,7 +403,6 @@ reload_font () if (layout) gtk_widget_queue_resize (layout); - PING(); } void @@ -431,7 +418,6 @@ set_style (GtkWidget *entry, gpointer data) char *str = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); PangoFontDescription *tmp_desc; - PING(); tmp_desc = pango_font_description_from_string (str); font_description.style = tmp_desc->style; @@ -448,7 +434,6 @@ set_style (GtkWidget *entry, gpointer data) void font_size_changed (GtkAdjustment *adj) { - PING(); font_description.size = (int)(adj->value * PANGO_SCALE + 0.5); reload_font(); } @@ -500,14 +485,11 @@ fill_styles_combo (GtkWidget *combo) GList *style_list = NULL; FontDescInfo *info = g_new (FontDescInfo, 1); - PING(); pango_context_list_fonts (context, font_description.family_name, &info->descs, &info->n_descs); gtk_object_set_data_full (GTK_OBJECT (combo), "descs", info, (GtkDestroyNotify)free_info); - PING(); qsort (info->descs, info->n_descs, sizeof(PangoFontDescription *), font_description_sort_func); - PING(); for (i=0; i<info->n_descs; i++) { char *str; @@ -524,7 +506,6 @@ fill_styles_combo (GtkWidget *combo) style_list = g_list_reverse (style_list); - PING(); gtk_combo_set_popdown_strings (GTK_COMBO (combo), style_list); g_list_foreach (style_list, (GFunc)g_free, NULL); } @@ -534,7 +515,6 @@ make_styles_combo () { GtkWidget *combo; - PING(); combo = gtk_combo_new (); gtk_combo_set_value_in_list (GTK_COMBO (combo), TRUE, FALSE); gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE); @@ -545,7 +525,6 @@ make_styles_combo () styles_combo = combo; fill_styles_combo (combo); - PING(); return combo; } @@ -564,11 +543,9 @@ make_families_menu () GList *family_list = NULL; int i; - PING(); pango_context_list_families (context, &families, &n_families); qsort (families, n_families, sizeof(char *), cmp_strings); - PING(); for (i=0; i<n_families; i++) family_list = g_list_prepend (family_list, families[i]); @@ -587,7 +564,6 @@ make_families_menu () g_list_free (family_list); pango_font_map_free_families (families, n_families); - PING(); return combo; } @@ -722,7 +698,6 @@ main (int argc, char **argv) gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - PING(); message_label = gtk_label_new ("Current char:"); gtk_misc_set_padding (GTK_MISC (message_label), 1, 1); gtk_misc_set_alignment (GTK_MISC (message_label), 0.0, 0.5); @@ -735,7 +710,6 @@ main (int argc, char **argv) gtk_widget_show_all (window); - PING(); gtk_main (); return 0; diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index d174d9e1..bf669a24 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -128,7 +128,7 @@ find_char (CharCache *cache, PangoFont *font, gunichar wc) n_subfonts = pango_win32_list_subfonts (font, subrange, &subfonts); - for (i=0; i<n_subfonts; i++) + for (i = 0; i < n_subfonts; i++) { PangoGlyph glyph; @@ -217,7 +217,7 @@ basic_engine_shape (PangoFont *font, pango_glyph_string_set_size (glyphs, n_chars); p = text; - for (i=0; i < n_chars; i++) + for (i = 0; i < n_chars; i++) { gunichar wc; FriBidiChar mirrored_ch; @@ -285,7 +285,7 @@ basic_engine_shape (PangoFont *font, swap_range (glyphs, 0, n_chars); /* Now reorder glyphs within each cluster back to LTR */ - for (start=0; start<n_chars;) + for (start = 0; start < n_chars;) { end = start; while (end < n_chars && diff --git a/pango/pango-font.h b/pango/pango-font.h index a299a887..3819b815 100644 --- a/pango/pango-font.h +++ b/pango/pango-font.h @@ -54,8 +54,12 @@ typedef enum { } PangoVariant; typedef enum { + PANGO_WEIGHT_ULTRALIGHT = 200, + PANGO_WEIGHT_LIGHT = 300, PANGO_WEIGHT_NORMAL = 400, - PANGO_WEIGHT_BOLD = 700 + PANGO_WEIGHT_BOLD = 700, + PANGO_WEIGHT_ULTRABOLD = 800, + PANGO_WEIGHT_HEAVY = 900 } PangoWeight; typedef enum { diff --git a/pango/pango-utils.c b/pango/pango-utils.c index c267a692..f54bd340 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -25,6 +25,7 @@ #include <config.h> +#include "pango-font.h" #include "pango-utils.h" #ifndef HAVE_FLOCKFILE @@ -651,3 +652,233 @@ pango_get_lib_subdirectory (void) return LIBDIR "/pango"; #endif } + +gboolean +pango_parse_style (GString *str, + PangoFontDescription *desc) +{ + if (str->len == 0) + return FALSE; + + switch (str->str[0]) + { + case 'n': + case 'N': + if (strncasecmp (str->str, "normal", str->len) == 0) + { + desc->style = PANGO_STYLE_NORMAL; + return TRUE; + } + break; + case 'i': + if (strncasecmp (str->str, "italic", str->len) == 0) + { + desc->style = PANGO_STYLE_ITALIC; + return TRUE; + } + break; + case 'o': + if (strncasecmp (str->str, "oblique", str->len) == 0) + { + desc->style = PANGO_STYLE_OBLIQUE; + return TRUE; + } + break; + } + g_warning ("Style must be normal, italic, or oblique"); + + return FALSE; +} + +gboolean +pango_parse_variant (GString *str, + PangoFontDescription *desc) +{ + if (str->len == 0) + return FALSE; + + switch (str->str[0]) + { + case 'n': + case 'N': + if (strncasecmp (str->str, "normal", str->len) == 0) + { + desc->variant = PANGO_VARIANT_NORMAL; + return TRUE; + } + break; + case 's': + case 'S': + if (strncasecmp (str->str, "small_caps", str->len) == 0) + { + desc->variant = PANGO_VARIANT_SMALL_CAPS; + return TRUE; + } + break; + } + + g_warning ("Variant must be normal, or small_caps"); + return FALSE; +} + +gboolean +pango_parse_weight (GString *str, + PangoFontDescription *desc) +{ + if (str->len == 0) + return FALSE; + + switch (str->str[0]) + { + case 'b': + case 'B': + if (strncasecmp (str->str, "bold", str->len) == 0) + { + desc->weight = PANGO_WEIGHT_BOLD; + return TRUE; + } + break; + case 'h': + case 'H': + if (strncasecmp (str->str, "heavy", str->len) == 0) + { + desc->weight = PANGO_WEIGHT_HEAVY; + return TRUE; + } + break; + case 'l': + case 'L': + if (strncasecmp (str->str, "light", str->len) == 0) + { + desc->weight = PANGO_WEIGHT_LIGHT; + return TRUE; + } + break; + case 'n': + case 'N': + if (strncasecmp (str->str, "normal", str->len) == 0) + { + desc->weight = PANGO_WEIGHT_NORMAL; + return TRUE; + } + break; + case 'u': + case 'U': + if (strncasecmp (str->str, "ultralight", str->len) == 0) + { + desc->weight = PANGO_WEIGHT_ULTRALIGHT; + return TRUE; + } + else if (strncasecmp (str->str, "ultrabold", str->len) == 0) + { + desc->weight = PANGO_WEIGHT_ULTRABOLD; + return TRUE; + } + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + char *numstr, *end; + + numstr = g_strndup (str->str, str->len); + + desc->weight = strtol (numstr, &end, 0); + if (*end != '\0') + { + g_warning ("Cannot parse numerical weight '%s'", numstr); + g_free (numstr); + return FALSE; + } + + g_free (numstr); + return TRUE; + } + } + + g_warning ("Weight must be ultralight, light, normal, bold, ultrabold, heavy, or an integer"); + return FALSE; +} + +gboolean +pango_parse_stretch (GString *str, + PangoFontDescription *desc) +{ + if (str->len == 0) + return FALSE; + + switch (str->str[0]) + { + case 'c': + case 'C': + if (strncasecmp (str->str, "condensed", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_CONDENSED; + return TRUE; + } + break; + case 'e': + case 'E': + if (strncasecmp (str->str, "extra_condensed", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_EXTRA_CONDENSED; + return TRUE; + } + if (strncasecmp (str->str, "extra_expanded", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_EXTRA_EXPANDED; + return TRUE; + } + if (strncasecmp (str->str, "expanded", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_EXPANDED; + return TRUE; + } + break; + case 'n': + case 'N': + if (strncasecmp (str->str, "normal", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_NORMAL; + return TRUE; + } + break; + case 's': + case 'S': + if (strncasecmp (str->str, "semi_condensed", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_SEMI_CONDENSED; + return TRUE; + } + if (strncasecmp (str->str, "semi_expanded", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_SEMI_EXPANDED; + return TRUE; + } + break; + case 'u': + case 'U': + if (strncasecmp (str->str, "ultra_condensed", str->len) == 0) + { + desc->stretch = PANGO_STRETCH_ULTRA_CONDENSED; + return TRUE; + } + if (strncasecmp (str->str, "ultra_expanded", str->len) == 0) + { + desc->variant = PANGO_STRETCH_ULTRA_EXPANDED; + return TRUE; + } + break; + } + + g_warning ("Stretch must be ultra_condensed, extra_condensed, condensed, semi_condensed, normal, semi_expanded, expanded, extra_expanded, or ultra_expanded"); + return FALSE; +} + diff --git a/pango/pango-utils.h b/pango/pango-utils.h index 1c8dfcaa..941ad515 100644 --- a/pango/pango-utils.h +++ b/pango/pango-utils.h @@ -38,6 +38,20 @@ gboolean pango_scan_int (const char **pos, char * pango_config_key_get (const char *key); +/* Functions for parsing textual representations + * of PangoFontDescription fields. They return TRUE if the input string + * contains a valid value, which then has been assigned to the corresponding + * field in the PangoFontDescription. + */ +gboolean pango_parse_style (GString *str, + PangoFontDescription *desc); +gboolean pango_parse_variant (GString *str, + PangoFontDescription *desc); +gboolean pango_parse_weight (GString *str, + PangoFontDescription *desc); +gboolean pango_parse_stretch (GString *str, + PangoFontDescription *desc); + /* On Unix, return the name of the "pango" subdirectory of SYSCONFDIR * (which is set at compile time). On Win32, return the Pango * installation directory (which is set at installation time, and @@ -51,3 +65,4 @@ char * pango_get_sysconf_subdirectory (void); * g_free'd either. */ char * pango_get_lib_subdirectory (void); + diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c index 67d4129d..a7b6cde4 100644 --- a/pango/pangowin32-fontmap.c +++ b/pango/pangowin32-fontmap.c @@ -204,9 +204,9 @@ static PangoWin32FontMap *fontmap = NULL; static int CALLBACK pango_win32_inner_enum_proc (LOGFONT *lfp, - TEXTMETRIC *metrics, - DWORD fontType, - LPARAM lParam) + TEXTMETRIC *metrics, + DWORD fontType, + LPARAM lParam) { pango_win32_insert_font (fontmap, lfp); @@ -235,7 +235,6 @@ PangoFontMap * pango_win32_font_map_for_display (void) { LOGFONT logfont; - int screen; /* Make sure that the type system is initialized */ g_type_init(); @@ -498,300 +497,6 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap, return result; } -/* Similar to GNU libc's getline, but buffer is g_malloc'd */ -static size_t -pango_getline (char **lineptr, size_t *n, FILE *stream) -{ -#define EXPAND_CHUNK 16 - - int n_read = 0; - int result = -1; - - g_return_val_if_fail (lineptr != NULL, -1); - g_return_val_if_fail (n != NULL, -1); - g_return_val_if_fail (*lineptr != NULL || *n == 0, -1); - -#ifdef HAVE_FLOCKFILE - flockfile (stream); -#endif - - while (1) - { - int c; - -#ifdef HAVE_FLOCKFILE - c = getc_unlocked (stream); -#else - c = getc (stream); -#endif - - if (c == EOF) - { - if (n_read > 0) - { - result = n_read; - (*lineptr)[n_read] = '\0'; - } - break; - } - - if (n_read + 2 >= *n) - { - *n += EXPAND_CHUNK; - *lineptr = g_realloc (*lineptr, *n); - } - - (*lineptr)[n_read] = c; - n_read++; - - if (c == '\n' || c == '\r') - { - result = n_read; - (*lineptr)[n_read] = '\0'; - break; - } - } - -#ifdef HAVE_FLOCKFILE - funlockfile (stream); -#endif - - return n_read - 1; -} - -static int -find_tok (char **start, char **tok) -{ - char *p = *start; - - while (*p && (*p == ' ' || *p == '\t')) - p++; - - if (*p == 0 || *p == '\n' || *p == '\r') - return -1; - - if (*p == '"') - { - p++; - *tok = p; - - while (*p && *p != '"') - p++; - - if (*p != '"') - return -1; - - *start = p + 1; - return p - *tok; - } - else - { - *tok = p; - - while (*p && *p != ' ' && *p != '\t' && *p != '\r' && *p != '\n') - p++; - - *start = p; - return p - *tok; - } -} - -static gboolean -get_style (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->style = PANGO_STYLE_NORMAL; - return TRUE; - } - break; - case 'i': - if (strncasecmp (str->str, "italic", str->len) == 0) - { - desc->style = PANGO_STYLE_ITALIC; - return TRUE; - } - break; - case 'o': - if (strncasecmp (str->str, "oblique", str->len) == 0) - { - desc->style = PANGO_STYLE_OBLIQUE; - return TRUE; - } - break; - } - g_warning ("Style must be normal, italic, or oblique"); - - return FALSE; -} - -static gboolean -get_variant (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->variant = PANGO_VARIANT_NORMAL; - return TRUE; - } - break; - case 's': - case 'S': - if (strncasecmp (str->str, "small_caps", str->len) == 0) - { - desc->variant = PANGO_VARIANT_SMALL_CAPS; - return TRUE; - } - break; - } - - g_warning ("Variant must be normal, or small_caps"); - return FALSE; -} - -static gboolean -get_weight (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->weight = PANGO_WEIGHT_NORMAL; - return TRUE; - } - break; - case 'b': - case 'B': - if (strncasecmp (str->str, "bold", str->len) == 0) - { - desc->weight = PANGO_WEIGHT_BOLD; - return TRUE; - } - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - char *numstr, *end; - - numstr = g_strndup (str->str, str->len); - - desc->weight = strtol (numstr, &end, 0); - if (*end != '\0') - { - g_warning ("Cannot parse numerical weight '%s'", numstr); - g_free (numstr); - return FALSE; - } - - g_free (numstr); - return TRUE; - } - } - - g_warning ("Weight must be normal, bold, or an integer"); - return FALSE; -} - -static gboolean -get_stretch (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'c': - case 'C': - if (strncasecmp (str->str, "condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_CONDENSED; - return TRUE; - } - break; - case 'e': - case 'E': - if (strncasecmp (str->str, "extra_condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_EXTRA_CONDENSED; - return TRUE; - } - if (strncasecmp (str->str, "extra_expanded", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_EXTRA_EXPANDED; - return TRUE; - } - if (strncasecmp (str->str, "expanded", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_EXPANDED; - return TRUE; - } - break; - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_NORMAL; - return TRUE; - } - break; - case 's': - case 'S': - if (strncasecmp (str->str, "semi_condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_SEMI_CONDENSED; - return TRUE; - } - if (strncasecmp (str->str, "semi_expanded", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_SEMI_EXPANDED; - return TRUE; - } - break; - case 'u': - case 'U': - if (strncasecmp (str->str, "ultra_condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_ULTRA_CONDENSED; - return TRUE; - } - if (strncasecmp (str->str, "ultra_expanded", str->len) == 0) - { - desc->variant = PANGO_STRETCH_ULTRA_EXPANDED; - return TRUE; - } - break; - } - - g_warning ("Stretch must be ultra_condensed, extra_condensed, condensed, semi_condensed, normal, semi_expanded, expanded, extra_expanded, or ultra_expanded"); - return FALSE; -} - static gboolean pango_win32_guess_subranges (UINT charset, FONTSIGNATURE *fsp) @@ -1286,25 +991,25 @@ pango_win32_font_map_read_alias_file (PangoWin32FontMap *win32fontmap, if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_style (tmp_buf, &font_entry->description)) + if (!pango_parse_style (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_variant (tmp_buf, &font_entry->description)) + if (!pango_parse_variant (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_weight (tmp_buf, &font_entry->description)) + if (!pango_parse_weight (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_stretch (tmp_buf, &font_entry->description)) + if (!pango_parse_stretch (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) @@ -1326,6 +1031,37 @@ pango_win32_font_map_read_alias_file (PangoWin32FontMap *win32fontmap, for (i=0; i<nfaces; i++) { strcpy (font_entry->lfp[i].lfFaceName, faces[i]); + + /* Set LOGFONT properties based on the PangoFontDescription */ + if (font_entry->description.style == PANGO_STYLE_OBLIQUE || + font_entry->description.style == PANGO_STYLE_ITALIC) + font_entry->lfp[i].lfItalic = TRUE; + + /* Quantize weight */ + if (font_entry->description.weight <= + (PANGO_WEIGHT_ULTRALIGHT + PANGO_WEIGHT_LIGHT) / 2) + font_entry->lfp[i].lfWeight = FW_ULTRALIGHT; + else if (font_entry->description.weight <= + (PANGO_WEIGHT_LIGHT + PANGO_WEIGHT_NORMAL) / 2) + font_entry->lfp[i].lfWeight = FW_LIGHT; + else if (font_entry->description.weight <= + (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_BOLD) / 2) + font_entry->lfp[i].lfWeight = FW_NORMAL; + else if (font_entry->description.weight <= + (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) + font_entry->lfp[i].lfWeight = FW_BOLD; + else if (font_entry->description.weight <= + (PANGO_WEIGHT_ULTRABOLD + PANGO_WEIGHT_HEAVY) / 2) + font_entry->lfp[i].lfWeight = FW_ULTRABOLD; + else + font_entry->lfp[i].lfWeight = FW_HEAVY; + + /* Stretch ? */ + + /* Charset is ignored anyway when used with the widechar + * API? + */ + font_entry->lfp[i].lfCharSet = DEFAULT_CHARSET; } g_strfreev (faces); @@ -1418,33 +1154,33 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap, PangoWin32SizeInfo *size_info; int i; + PING(("lfp.face=%s,wt=%d,ht=%d",lfp->lfFaceName,lfp->lfWeight,lfp->lfHeight)); description.size = 0; /* First insert the LOGFONT into the list of LOGFONTs for the typeface name */ + lfp2 = g_new (LOGFONT, 1); + *lfp2 = *lfp; + g_strdown (lfp2->lfFaceName); size_info = g_hash_table_lookup (win32fontmap->size_infos, lfp); if (!size_info) { + PING(("SizeInfo not found")); size_info = g_new (PangoWin32SizeInfo, 1); - pango_win32_setup_signature (win32fontmap, lfp, &size_info->signature); + pango_win32_setup_signature (win32fontmap, lfp2, + &size_info->signature); size_info->logfonts = NULL; - g_hash_table_insert (win32fontmap->size_infos, lfp, size_info); + g_hash_table_insert (win32fontmap->size_infos, lfp2, size_info); } - lfp2 = g_new (LOGFONT, 1); - *lfp2 = *lfp; size_info->logfonts = g_slist_prepend (size_info->logfonts, lfp2); /* Convert the LOGFONT into a PangoFontDescription */ - description.family_name = g_strdup (lfp->lfFaceName); - g_strdown (description.family_name); + description.family_name = g_strdup (lfp2->lfFaceName); - if (!description.family_name[0]) - return; - - if (!lfp->lfItalic) + if (!lfp2->lfItalic) description.style = PANGO_STYLE_NORMAL; else description.style = PANGO_STYLE_ITALIC; @@ -1452,12 +1188,23 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap, description.variant = PANGO_VARIANT_NORMAL; /* The PangoWeight values PANGO_WEIGHT_* map exactly do Windows FW_* values. - * Is this on purpose? + * Is this on purpose? Quantize the weight to exact PANGO_WEIGHT_* + * values. Is this a good idea? */ - if (lfp->lfWeight == FW_DONTCARE) + if (lfp2->lfWeight == FW_DONTCARE) + description.weight = PANGO_WEIGHT_NORMAL; + else if (lfp2->lfWeight <= (FW_ULTRALIGHT + FW_LIGHT) / 2) + description.weight = PANGO_WEIGHT_ULTRALIGHT; + else if (lfp2->lfWeight <= (FW_LIGHT + FW_NORMAL) / 2) + description.weight = PANGO_WEIGHT_LIGHT; + else if (lfp2->lfWeight <= (FW_NORMAL + FW_BOLD) / 2) description.weight = PANGO_WEIGHT_NORMAL; + else if (lfp2->lfWeight <= (FW_BOLD + FW_ULTRABOLD) / 2) + description.weight = PANGO_WEIGHT_BOLD; + else if (lfp2->lfWeight <= (FW_ULTRABOLD + FW_HEAVY) / 2) + description.weight = PANGO_WEIGHT_ULTRABOLD; else - description.weight = lfp->lfWeight; + description.weight = PANGO_WEIGHT_HEAVY; /* XXX No idea how to figure out the stretch */ description.stretch = PANGO_STRETCH_NORMAL; @@ -1512,21 +1259,25 @@ pango_win32_logfont_has_subrange (PangoFontMap *fontmap, PangoWin32FontMap *win32fontmap; PangoWin32SizeInfo *size_info; + PING(("lfp.face=%s,wt=%d,ht=%d,subr:%d",lfp->lfFaceName,lfp->lfWeight,lfp->lfHeight,subrange)); win32fontmap = PANGO_WIN32_FONT_MAP (fontmap); size_info = g_hash_table_lookup (win32fontmap->size_infos, lfp); if (!size_info) - return FALSE; + { + PING(("SizeInfo not found")); + return FALSE; + } - return size_info->signature.fsUsb[subrange/32] & (1 << subrange % 32); + return ((size_info->signature.fsUsb[subrange/32] & (1 << subrange % 32)) != 0); } /* Given a LOGFONT and size, make a matching LOGFONT corresponding to * an installed font. */ LOGFONT * -pango_win32_make_matching_logfont (PangoFontMap *fontmap, - LOGFONT *lfp, - int size) +pango_win32_make_matching_logfont (PangoFontMap *fontmap, + LOGFONT *lfp, + int size) { PangoWin32FontMap *win32fontmap; GSList *tmp_list; @@ -1535,12 +1286,16 @@ pango_win32_make_matching_logfont (PangoFontMap *fontmap, LOGFONT *result = NULL; gint match_distance = 0; + PING(("lfp.face=%s,wt=%d,ht=%d,size:%d",lfp->lfFaceName,lfp->lfWeight,lfp->lfHeight,size)); win32fontmap = PANGO_WIN32_FONT_MAP (fontmap); size_info = g_hash_table_lookup (win32fontmap->size_infos, lfp); if (!size_info) - return NULL; + { + PING(("SizeInfo not found")); + return NULL; + } tmp_list = size_info->logfonts; while (tmp_list) diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h index 9d748798..78d459a3 100644 --- a/pango/pangowin32-private.h +++ b/pango/pangowin32-private.h @@ -22,6 +22,12 @@ #ifndef __PANGOWIN32_PRIVATE_H__ #define __PANGOWIN32_PRIVATE_H__ +/* Just for debugging, will be removed */ +#define PING(printlist) \ +(g_print ("%s:%d ", __PRETTY_FUNCTION__, __LINE__), \ + g_print printlist, \ + g_print ("\n")) + #include "pango-modules.h" #include "pangowin32.h" diff --git a/pango/pangowin32.c b/pango/pangowin32.c index 38937184..2147fef2 100644 --- a/pango/pangowin32.c +++ b/pango/pangowin32.c @@ -260,7 +260,7 @@ pango_win32_font_new (PangoFontMap *fontmap, result->fontmap = fontmap; g_object_ref (G_OBJECT (fontmap)); - result -> n_fonts = n_fonts; + result->n_fonts = n_fonts; result->fonts = g_new (LOGFONT, n_fonts); memcpy (result->fonts, lfp, sizeof (LOGFONT) * n_fonts); result->size = size; @@ -320,7 +320,7 @@ pango_win32_render (HDC hdc, g_return_if_fail (glyphs != NULL); - for (i=0; i<glyphs->num_glyphs; i++) + for (i = 0; i <glyphs->num_glyphs; i++) { if (glyphs->glyphs[i].glyph) { @@ -874,7 +874,7 @@ pango_win32_list_subfonts (PangoFont *font, PangoWin32Subfont *subfont_list; PangoFontMap *fontmap; int i, j; - int n_subfonts = 0; + int n_subfonts; g_return_val_if_fail (font != NULL, 0); @@ -906,6 +906,7 @@ pango_win32_list_subfonts (PangoFont *font, g_hash_table_insert (win32font->subfonts_by_subrange, (gpointer) subrange, subfont_list); } + n_subfonts = 0; for (i = 0; i < win32font->n_fonts; i++) if (subfont_list[i]) n_subfonts++; @@ -913,16 +914,13 @@ pango_win32_list_subfonts (PangoFont *font, *subfont_ids = g_new (PangoWin32Subfont, n_subfonts); n_subfonts = 0; - - for (i=0; i<win32font->n_fonts; i++) + for (i = 0; i < win32font->n_fonts; i++) if (subfont_list[i]) { (*subfont_ids)[n_subfonts] = subfont_list[i]; n_subfonts++; } - g_free (subfont_list); - return n_subfonts; } @@ -1096,7 +1094,7 @@ pango_win32_font_finalize (GObject *object) PangoWin32FontCache *cache = pango_win32_font_map_get_font_cache (win32font->fontmap); int i; - for (i=0; i<win32font->n_subfonts; i++) + for (i = 0; i < win32font->n_subfonts; i++) { PangoWin32SubfontInfo *info = win32font->subfonts[i]; @@ -1219,7 +1217,7 @@ pango_win32_find_glyph (PangoFont *font, PangoGlyph pango_win32_get_unknown_glyph (PangoFont *font) { - return PANGO_WIN32_MAKE_GLYPH (0, 0); /* XXX */ + return PANGO_WIN32_MAKE_GLYPH (1, 0); /* XXX */ } /** diff --git a/pango/pangox-fontmap.c b/pango/pangox-fontmap.c index 6b0c90bb..007e3ad1 100644 --- a/pango/pangox-fontmap.c +++ b/pango/pangox-fontmap.c @@ -547,202 +547,6 @@ pango_x_font_map_load_font (PangoFontMap *fontmap, return result; } -static gboolean -get_style (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->style = PANGO_STYLE_NORMAL; - return TRUE; - } - break; - case 'i': - if (strncasecmp (str->str, "italic", str->len) == 0) - { - desc->style = PANGO_STYLE_ITALIC; - return TRUE; - } - break; - case 'o': - if (strncasecmp (str->str, "oblique", str->len) == 0) - { - desc->style = PANGO_STYLE_OBLIQUE; - return TRUE; - } - break; - } - g_warning ("Style must be normal, italic, or oblique"); - - return FALSE; -} - -static gboolean -get_variant (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->variant = PANGO_VARIANT_NORMAL; - return TRUE; - } - break; - case 's': - case 'S': - if (strncasecmp (str->str, "small_caps", str->len) == 0) - { - desc->variant = PANGO_VARIANT_SMALL_CAPS; - return TRUE; - } - break; - } - - g_warning ("Variant must be normal, or small_caps"); - return FALSE; -} - -static gboolean -get_weight (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->weight = PANGO_WEIGHT_NORMAL; - return TRUE; - } - break; - case 'b': - case 'B': - if (strncasecmp (str->str, "bold", str->len) == 0) - { - desc->weight = PANGO_WEIGHT_BOLD; - return TRUE; - } - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - char *numstr, *end; - - numstr = g_strndup (str->str, str->len); - - desc->weight = strtol (numstr, &end, 0); - if (*end != '\0') - { - g_warning ("Cannot parse numerical weight '%s'", numstr); - g_free (numstr); - return FALSE; - } - - g_free (numstr); - return TRUE; - } - } - - g_warning ("Weight must be normal, bold, or an integer"); - return FALSE; -} - -static gboolean -get_stretch (GString *str, PangoFontDescription *desc) -{ - if (str->len == 0) - return FALSE; - - switch (str->str[0]) - { - case 'c': - case 'C': - if (strncasecmp (str->str, "condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_CONDENSED; - return TRUE; - } - break; - case 'e': - case 'E': - if (strncasecmp (str->str, "extra_condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_EXTRA_CONDENSED; - return TRUE; - } - if (strncasecmp (str->str, "extra_expanded", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_EXTRA_EXPANDED; - return TRUE; - } - if (strncasecmp (str->str, "expanded", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_EXPANDED; - return TRUE; - } - break; - case 'n': - case 'N': - if (strncasecmp (str->str, "normal", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_NORMAL; - return TRUE; - } - break; - case 's': - case 'S': - if (strncasecmp (str->str, "semi_condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_SEMI_CONDENSED; - return TRUE; - } - if (strncasecmp (str->str, "semi_expanded", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_SEMI_EXPANDED; - return TRUE; - } - break; - case 'u': - case 'U': - if (strncasecmp (str->str, "ultra_condensed", str->len) == 0) - { - desc->stretch = PANGO_STRETCH_ULTRA_CONDENSED; - return TRUE; - } - if (strncasecmp (str->str, "ultra_expanded", str->len) == 0) - { - desc->variant = PANGO_STRETCH_ULTRA_EXPANDED; - return TRUE; - } - break; - } - - g_warning ("Stretch must be ultra_condensed, extra_condensed, condensed, semi_condensed, normal, semi_expanded, expanded, extra_expanded, or ultra_expanded"); - return FALSE; -} - static void pango_x_font_map_read_alias_file (PangoXFontMap *xfontmap, const char *filename) @@ -781,25 +585,25 @@ pango_x_font_map_read_alias_file (PangoXFontMap *xfontmap, if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_style (tmp_buf, &font_entry->description)) + if (!pango_parse_style (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_variant (tmp_buf, &font_entry->description)) + if (!pango_parse_variant (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_weight (tmp_buf, &font_entry->description)) + if (!pango_parse_weight (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) goto error; - if (!get_stretch (tmp_buf, &font_entry->description)) + if (!pango_parse_stretch (tmp_buf, &font_entry->description)) goto error; if (!pango_scan_string (&p, tmp_buf)) |