From: <kr_...@us...> - 2003-03-03 00:14:13
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv26260/src/cbits/GTK Modified Files: Font.c Log Message: Remove unused variables Index: Font.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Font.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Font.c 10 Feb 2003 22:42:09 -0000 1.3 --- Font.c 3 Mar 2003 00:14:10 -0000 1.4 *************** *** 1,256 **** ! #include "Font.h" ! #include "Internals.h" ! ! char *osGetAvailableFontNames() ! { ! int i, nCount, nBufferSize; ! Display *display; ! PangoFontMap *fontmap; ! PangoFontFamily **families; ! char *buffer, *p; ! ! display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ! fontmap = pango_x_font_map_for_display(display); ! ! pango_font_map_list_families(fontmap, &families, &nCount); ! ! nBufferSize = 0; ! for (i = 0; i < nCount; i++) ! { ! nBufferSize += strlen(pango_font_family_get_name(families[i]))+1; ! } ! ! buffer = rmalloc(nBufferSize+1); p = buffer; ! for (i = 0; i < nCount; i++) ! { ! strcpy(p, pango_font_family_get_name(families[i])); ! p += strlen(p)+1; ! } ! *p = 0; ! ! g_free(families); ! ! return buffer; ! } ! ! int *osGetAvailableFontVariants(char *szFontName, int nLow, int nHight) ! { ! int i, nCount, nBufferSize; ! Display *display; ! PangoFontMap *fontmap; ! PangoFontFamily **families, *family; ! PangoFontFace **faces; ! int *buffer, *p; ! gchar **xfontnames; ! ! display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ! fontmap = pango_x_font_map_for_display(display); ! ! pango_font_map_list_families(fontmap, &families, &nCount); ! ! family = NULL; ! for (i = 0; i < nCount; i++) ! { ! if (strcmp(pango_font_family_get_name(families[i]), szFontName) == 0) ! { ! family = families[i]; ! break; ! } ! } ! ! g_free(families); ! ! if (family) ! { ! pango_font_family_list_faces(family, &faces, &nCount); ! ! buffer = rmalloc(sizeof(int)*(nCount*3+1)); p = buffer; ! for (i = 0; i < nCount; i++) ! { ! PangoFontDescription *desc = pango_font_face_describe(faces[i]); ! ! *(p++) = pango_font_description_get_weight(desc); ! switch (pango_font_description_get_style(desc)) ! { ! case PANGO_STYLE_NORMAL: *(p++) = 0; break; ! case PANGO_STYLE_OBLIQUE: *(p++) = 1; break; ! case PANGO_STYLE_ITALIC: *(p++) = 2; break; ! default: *(p++) = -1; break; ! } ! *(p++) = 0; ! ! pango_font_description_free(desc); ! } ! *(p++) = 0; ! ! return buffer; ! } ! ! return NULL; ! ! } ! ! FontHandle osCreateFont(char *face, int size, int weight, int style, BOOL IsUnderlined, BOOL IsStriked) ! { ! FontHandle font; ! Display *display; ! PangoLayout *layout; ! PangoContext *pango_context; ! PangoFont *pango_font; ! ! font = rmalloc(sizeof(*font)); ! ! display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ! pango_context = pango_x_get_context(display); ! font->layout = pango_layout_new(pango_context); ! ! font->font_descr = pango_font_description_new(); ! pango_font_description_set_family(font->font_descr,face); ! pango_font_description_set_weight(font->font_descr,weight); ! pango_font_description_set_style(font->font_descr,style); ! pango_font_description_set_size(font->font_descr, size*PANGO_SCALE); ! ! pango_layout_set_font_description(font->layout, font->font_descr); ! ! pango_font = pango_font_map_load_font ! ( pango_x_font_map_for_display(display) ! , NULL ! , font->font_descr ! ); ! font->metrics = pango_font_get_metrics(pango_font, pango_context_get_language(pango_context)); ! ! font->IsUnderlined = IsUnderlined; ! font->IsStriked = IsStriked; ! ! if (font->IsUnderlined || font->IsStriked) ! pango_layout_set_attributes(font->layout, pango_attr_list_new()); ! ! return font; ! } ! ! void osDeleteFont(FontHandle font) ! { ! pango_font_metrics_unref(font->metrics); ! pango_font_description_free(font->font_descr); ! g_object_unref(font->layout); ! rfree(font); ! } /* osDeleteFont */ ! ! void osGetFontMetrics(FontHandle font, CanvasHandle canvas, int *ascent, int *descent, int *maxwidth, int *leading) ! { ! *ascent = pango_font_metrics_get_ascent(font->metrics)/PANGO_SCALE; ! *descent = pango_font_metrics_get_descent(font->metrics)/PANGO_SCALE; ! *maxwidth = pango_font_metrics_get_approximate_char_width(font->metrics)/PANGO_SCALE; ! *leading = 2; /* FIXME */ ! } /* osGetFontMetrics */ ! ! ! void osGetPenFontMetrics(CanvasHandle canvas, int *ascent, int *descent, int *maxwidth, int *leading) ! { ! *ascent = pango_font_metrics_get_ascent(canvas->theFont->metrics)/PANGO_SCALE; ! *descent = pango_font_metrics_get_descent(canvas->theFont->metrics)/PANGO_SCALE; ! *maxwidth = pango_font_metrics_get_approximate_char_width(canvas->theFont->metrics)/PANGO_SCALE; ! *leading = 2; /* FIXME */ ! } /* osGetPenFontMetrics */ ! ! ! int osGetStringWidth(char *string, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(canvas->theFont->layout, string, -1); ! pango_layout_get_pixel_size(canvas->theFont->layout, &width, NULL); ! pango_layout_set_text(canvas->theFont->layout, NULL, 0); ! ! ! return width; ! } /* osGetStringWidth */ ! ! int osGetCharWidth(char ch, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(canvas->theFont->layout, &ch, 1); ! pango_layout_get_pixel_size(canvas->theFont->layout, &width, NULL); ! pango_layout_set_text(canvas->theFont->layout, NULL, 0); ! ! return width; ! } /* osGetCharWidth */ ! ! int osGetFontStringWidth(char *string, FontHandle font, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(font->layout, string, -1); ! pango_layout_get_pixel_size(font->layout, &width, NULL); ! pango_layout_set_text(font->layout, NULL, 0); ! ! return width; ! } /* osGetFontStringWidth */ ! ! int osGetFontCharWidth(char ch, FontHandle font, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(font->layout, &ch, 1); ! pango_layout_get_pixel_size(font->layout, &width, NULL); ! pango_layout_set_text(font->layout, NULL, 0); ! ! return width; ! } /* osGetFontCharWidth */ ! ! void osDefaultFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 12; ! *weight = 500; ! *style = 0; ! } ! ! void osDialogFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 12; ! *weight = 500; ! *style = 0; ! } ! ! void osSerifFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "times"; ! *size = 10; ! *weight = 400; ! *style = 0; ! }; ! ! void osSansSerifFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 10; ! *weight = 500; ! *style = 0; ! }; ! ! void osSmallFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 7; ! *weight = 500; ! *style = 0; ! }; ! ! void osNonProportionalFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "fixed"; ! *size = 10; ! *weight = 400; ! *style = 0; ! }; ! ! void osSymbolFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "symbol"; ! *size = 10; ! *weight = 400; ! *style = 0; ! }; --- 1,254 ---- ! #include "Font.h" ! #include "Internals.h" ! ! char *osGetAvailableFontNames() ! { ! int i, nCount, nBufferSize; ! Display *display; ! PangoFontMap *fontmap; ! PangoFontFamily **families; ! char *buffer, *p; ! ! display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ! fontmap = pango_x_font_map_for_display(display); ! ! pango_font_map_list_families(fontmap, &families, &nCount); ! ! nBufferSize = 0; ! for (i = 0; i < nCount; i++) ! { ! nBufferSize += strlen(pango_font_family_get_name(families[i]))+1; ! } ! ! buffer = rmalloc(nBufferSize+1); p = buffer; ! for (i = 0; i < nCount; i++) ! { ! strcpy(p, pango_font_family_get_name(families[i])); ! p += strlen(p)+1; ! } ! *p = 0; ! ! g_free(families); ! ! return buffer; ! } ! ! int *osGetAvailableFontVariants(char *szFontName, int nLow, int nHight) ! { ! int i, nCount; ! Display *display; ! PangoFontMap *fontmap; ! PangoFontFamily **families, *family; ! PangoFontFace **faces; ! int *buffer, *p; ! ! display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ! fontmap = pango_x_font_map_for_display(display); ! ! pango_font_map_list_families(fontmap, &families, &nCount); ! ! family = NULL; ! for (i = 0; i < nCount; i++) ! { ! if (strcmp(pango_font_family_get_name(families[i]), szFontName) == 0) ! { ! family = families[i]; ! break; ! } ! } ! ! g_free(families); ! ! if (family) ! { ! pango_font_family_list_faces(family, &faces, &nCount); ! ! buffer = rmalloc(sizeof(int)*(nCount*3+1)); p = buffer; ! for (i = 0; i < nCount; i++) ! { ! PangoFontDescription *desc = pango_font_face_describe(faces[i]); ! ! *(p++) = pango_font_description_get_weight(desc); ! switch (pango_font_description_get_style(desc)) ! { ! case PANGO_STYLE_NORMAL: *(p++) = 0; break; ! case PANGO_STYLE_OBLIQUE: *(p++) = 1; break; ! case PANGO_STYLE_ITALIC: *(p++) = 2; break; ! default: *(p++) = -1; break; ! } ! *(p++) = 0; ! ! pango_font_description_free(desc); ! } ! *(p++) = 0; ! ! return buffer; ! } ! ! return NULL; ! ! } ! ! FontHandle osCreateFont(char *face, int size, int weight, int style, BOOL IsUnderlined, BOOL IsStriked) ! { ! FontHandle font; ! Display *display; ! PangoContext *pango_context; ! PangoFont *pango_font; ! ! font = rmalloc(sizeof(*font)); ! ! display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ! pango_context = pango_x_get_context(display); ! font->layout = pango_layout_new(pango_context); ! ! font->font_descr = pango_font_description_new(); ! pango_font_description_set_family(font->font_descr,face); ! pango_font_description_set_weight(font->font_descr,weight); ! pango_font_description_set_style(font->font_descr,style); ! pango_font_description_set_size(font->font_descr, size*PANGO_SCALE); ! ! pango_layout_set_font_description(font->layout, font->font_descr); ! ! pango_font = pango_font_map_load_font ! ( pango_x_font_map_for_display(display) ! , NULL ! , font->font_descr ! ); ! font->metrics = pango_font_get_metrics(pango_font, pango_context_get_language(pango_context)); ! ! font->IsUnderlined = IsUnderlined; ! font->IsStriked = IsStriked; ! ! if (font->IsUnderlined || font->IsStriked) ! pango_layout_set_attributes(font->layout, pango_attr_list_new()); ! ! return font; ! } ! ! void osDeleteFont(FontHandle font) ! { ! pango_font_metrics_unref(font->metrics); ! pango_font_description_free(font->font_descr); ! g_object_unref(font->layout); ! rfree(font); ! } /* osDeleteFont */ ! ! void osGetFontMetrics(FontHandle font, CanvasHandle canvas, int *ascent, int *descent, int *maxwidth, int *leading) ! { ! *ascent = pango_font_metrics_get_ascent(font->metrics)/PANGO_SCALE; ! *descent = pango_font_metrics_get_descent(font->metrics)/PANGO_SCALE; ! *maxwidth = pango_font_metrics_get_approximate_char_width(font->metrics)/PANGO_SCALE; ! *leading = 2; /* FIXME */ ! } /* osGetFontMetrics */ ! ! ! void osGetPenFontMetrics(CanvasHandle canvas, int *ascent, int *descent, int *maxwidth, int *leading) ! { ! *ascent = pango_font_metrics_get_ascent(canvas->theFont->metrics)/PANGO_SCALE; ! *descent = pango_font_metrics_get_descent(canvas->theFont->metrics)/PANGO_SCALE; ! *maxwidth = pango_font_metrics_get_approximate_char_width(canvas->theFont->metrics)/PANGO_SCALE; ! *leading = 2; /* FIXME */ ! } /* osGetPenFontMetrics */ ! ! ! int osGetStringWidth(char *string, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(canvas->theFont->layout, string, -1); ! pango_layout_get_pixel_size(canvas->theFont->layout, &width, NULL); ! pango_layout_set_text(canvas->theFont->layout, NULL, 0); ! ! ! return width; ! } /* osGetStringWidth */ ! ! int osGetCharWidth(char ch, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(canvas->theFont->layout, &ch, 1); ! pango_layout_get_pixel_size(canvas->theFont->layout, &width, NULL); ! pango_layout_set_text(canvas->theFont->layout, NULL, 0); ! ! return width; ! } /* osGetCharWidth */ ! ! int osGetFontStringWidth(char *string, FontHandle font, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(font->layout, string, -1); ! pango_layout_get_pixel_size(font->layout, &width, NULL); ! pango_layout_set_text(font->layout, NULL, 0); ! ! return width; ! } /* osGetFontStringWidth */ ! ! int osGetFontCharWidth(char ch, FontHandle font, CanvasHandle canvas) ! { ! int width; ! ! pango_layout_set_text(font->layout, &ch, 1); ! pango_layout_get_pixel_size(font->layout, &width, NULL); ! pango_layout_set_text(font->layout, NULL, 0); ! ! return width; ! } /* osGetFontCharWidth */ ! ! void osDefaultFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 12; ! *weight = 500; ! *style = 0; ! } ! ! void osDialogFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 12; ! *weight = 500; ! *style = 0; ! } ! ! void osSerifFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "times"; ! *size = 10; ! *weight = 400; ! *style = 0; ! }; ! ! void osSansSerifFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 10; ! *weight = 500; ! *style = 0; ! }; ! ! void osSmallFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "helvetica"; ! *size = 7; ! *weight = 500; ! *style = 0; ! }; ! ! void osNonProportionalFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "fixed"; ! *size = 10; ! *weight = 400; ! *style = 0; ! }; ! ! void osSymbolFontDef(char **face, int *size, int *weight, int *style) ! { ! *face = "symbol"; ! *size = 10; ! *weight = 400; ! *style = 0; ! }; |