And migrated fontmatch.c back. Let's test.

This commit is contained in:
Pietro Gagliardi 2018-03-11 19:37:30 -04:00
parent 5939c3203d
commit 697c926c92
4 changed files with 25 additions and 24 deletions

View File

@ -225,25 +225,3 @@ 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;
}

View File

@ -14,6 +14,7 @@ extern PangoWeight uiprivWeightToPangoWeight(uiTextWeight w);
extern PangoStyle uiprivItalicToPangoStyle(uiTextItalic i);
extern PangoStretch uiprivStretchToPangoStretch(uiTextStretch s);
extern PangoFontDescription *uiprivFontDescriptorToPangoFontDescription(const uiFontDescriptor *uidesc);
extern void uiprivFontDescriptorFromPangoFontDescription(PangoFontDescription *pdesc, uiDrawFontDescriptor *uidesc);
// attrstr.c
extern PangoAttrList *uiprivAttributedStringToPangoAttrList(uiDrawTextLayoutParams *p, GPtrArray **backgroundParams);

View File

@ -1,5 +1,6 @@
// 14 april 2016
#include "uipriv_unix.h"
#include "attrstr.h"
struct uiFontButton {
uiUnixControl c;
@ -31,8 +32,8 @@ void uiFontButtonFont(uiFontButton *b, uiDrawFontDescriptor *desc)
PangoFontDescription *pdesc;
pdesc = gtk_font_chooser_get_font_desc(b->fc);
fontdescFromPangoFontDescription(pdesc, desc);
// desc is transfer-full and thus is a copy
uiprivFontDescriptorFromPangoFontDescription(pdesc, desc);
// pdesc is transfer-full and thus is a copy
pango_font_description_free(pdesc);
}

View File

@ -53,3 +53,24 @@ PangoFontDescription *uiprivFontDescriptorToPangoFontDescription(const uiFontDes
pango_font_description_set_stretch(desc, uiprivStretchToPangoStretch(uidesc->Stretch));
return desc;
}
void uiprivFontDescriptorFromPangoFontDescription(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;
}