Reimplemented uiFontButton on GTK+.
This commit is contained in:
parent
a014eb27e6
commit
1a8f7ad405
|
@ -22,7 +22,7 @@ list(APPEND _LIBUI_SOURCES
|
|||
unix/drawtext.c
|
||||
unix/editablecombo.c
|
||||
unix/entry.c
|
||||
# unix/fontbutton.c
|
||||
unix/fontbutton.c
|
||||
unix/form.c
|
||||
unix/future.c
|
||||
unix/graphemes.c
|
||||
|
|
|
@ -280,3 +280,25 @@ void caretDrawParams(uiDrawContext *c, double height, struct caretDrawParams *p)
|
|||
p->xoff = xoff;
|
||||
p->width = width;
|
||||
}
|
||||
|
||||
// TODO split this and the other font description stuff into their own file?
|
||||
void fontdescFromPangoFontDescription(PangoFontDescription *pdesc, uiDrawFontDescriptor *uidesc)
|
||||
{
|
||||
PangoStyle pitalic;
|
||||
PangoStretch pstretch;
|
||||
|
||||
uidesc->Family = uiUnixStrdupText(pango_font_description_get_family(pdesc));
|
||||
pitalic = pango_font_description_get_style(pdesc);
|
||||
// TODO reverse the above misalignment if it is corrected
|
||||
uidesc->Weight = pango_font_description_get_weight(pdesc);
|
||||
pstretch = pango_font_description_get_stretch(pdesc);
|
||||
// absolute size does not matter because, as above, 1 device unit == 1 cairo point
|
||||
uidesc->Size = pango_units_to_double(pango_font_description_get_size(pdesc));
|
||||
|
||||
for (uidesc->Italic = uiDrawTextItalicNormal; uidesc->Italic < uiDrawTextItalicItalic; uidesc->Italic++)
|
||||
if (pangoItalics[uidesc->Italic] == pitalic)
|
||||
break;
|
||||
for (uidesc->Stretch = uiDrawTextStretchUltraCondensed; uidesc->Stretch < uiDrawTextStretchUltraExpanded; uidesc->Stretch++)
|
||||
if (pangoStretches[uidesc->Stretch] == pstretch)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,16 +26,14 @@ static void defaultOnChanged(uiFontButton *b, void *data)
|
|||
// do nothing
|
||||
}
|
||||
|
||||
uiDrawTextFont *uiFontButtonFont(uiFontButton *b)
|
||||
void uiFontButtonFont(uiFontButton *b, uiDrawFontDescriptor *desc)
|
||||
{
|
||||
PangoFont *f;
|
||||
PangoFontDescription *desc;
|
||||
PangoFontDescription *pdesc;
|
||||
|
||||
desc = gtk_font_chooser_get_font_desc(b->fc);
|
||||
f = pangoDescToPangoFont(desc);
|
||||
pdesc = gtk_font_chooser_get_font_desc(b->fc);
|
||||
fontdescFromPangoFontDescription(pdesc, desc);
|
||||
// desc is transfer-full and thus is a copy
|
||||
pango_font_description_free(desc);
|
||||
return mkTextFont(f, FALSE); // we hold the initial reference; no need to ref
|
||||
pango_font_description_free(pdesc);
|
||||
}
|
||||
|
||||
void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data)
|
||||
|
|
|
@ -45,12 +45,6 @@ extern void childSetMargined(struct child *c, int margined);
|
|||
extern uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style);
|
||||
extern void freeContext(uiDrawContext *);
|
||||
|
||||
// drawtext.c
|
||||
#if 0 /* TODO */
|
||||
extern uiDrawTextFont *mkTextFont(PangoFont *f, gboolean add);
|
||||
extern PangoFont *pangoDescToPangoFont(PangoFontDescription *pdesc);
|
||||
#endif
|
||||
|
||||
// image.c
|
||||
/*TODO remove this*/typedef struct uiImage uiImage;
|
||||
extern cairo_surface_t *imageAppropriateSurface(uiImage *i, GtkWidget *w);
|
||||
|
@ -62,3 +56,6 @@ extern GtkCellRenderer *newCellRendererButton(void);
|
|||
extern void loadFutures(void);
|
||||
extern PangoAttribute *FUTURE_pango_attr_foreground_alpha_new(guint16 alpha);
|
||||
extern gboolean FUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name);
|
||||
|
||||
// drawtext.c
|
||||
extern void fontdescFromPangoFontDescription(PangoFontDescription *pdesc, uiDrawFontDescriptor *uidesc);
|
||||
|
|
Loading…
Reference in New Issue