Dropped uiDrawTextGravity. That has to do with vertical text, which we can both abstract into a higher level API and can't do yet because DirectWrite simply does not support vertical text on Windows 7 for reasons that escape logical thought.
This commit is contained in:
parent
8ac3c53e0f
commit
0bc140cd46
|
@ -119,11 +119,6 @@ static void addFontSmallCapsAttr(CFMutableDictionaryRef attr)
|
||||||
CFRelease(outerArray);
|
CFRelease(outerArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addFontGravityAttr(CFMutableDictionaryRef dict, uiDrawTextGravity gravity)
|
|
||||||
{
|
|
||||||
// TODO: matrix setting? kCTFontOrientationAttribute? or is it a kCTVerticalFormsAttributeName of the CFAttributedString attributes and thus not part of the CTFontDescriptor?
|
|
||||||
}
|
|
||||||
|
|
||||||
// Named constants for these were NOT added until 10.11, and even then they were added as external symbols instead of macros, so we can't use them directly :(
|
// Named constants for these were NOT added until 10.11, and even then they were added as external symbols instead of macros, so we can't use them directly :(
|
||||||
// kode54 got these for me before I had access to El Capitan; thanks to him.
|
// kode54 got these for me before I had access to El Capitan; thanks to him.
|
||||||
#define ourNSFontWeightUltraLight -0.800000
|
#define ourNSFontWeightUltraLight -0.800000
|
||||||
|
@ -387,7 +382,6 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
||||||
// and finally add the other attributes
|
// and finally add the other attributes
|
||||||
if (desc->SmallCaps)
|
if (desc->SmallCaps)
|
||||||
addFontSmallCapsAttr(attr);
|
addFontSmallCapsAttr(attr);
|
||||||
addFontGravityAttr(attr, desc->Gravity);
|
|
||||||
|
|
||||||
// and NOW create the final descriptor
|
// and NOW create the final descriptor
|
||||||
cfdesc = CTFontDescriptorCreateWithAttributes(attr);
|
cfdesc = CTFontDescriptorCreateWithAttributes(attr);
|
||||||
|
|
|
@ -96,7 +96,6 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
|
||||||
desc.Italic = uiComboboxSelected(textItalic);
|
desc.Italic = uiComboboxSelected(textItalic);
|
||||||
desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
|
desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
|
||||||
desc.Stretch = uiComboboxSelected(textStretch);
|
desc.Stretch = uiComboboxSelected(textStretch);
|
||||||
desc.Gravity = uiComboboxSelected(textGravity);
|
|
||||||
font = uiDrawLoadClosestFont(&desc);
|
font = uiDrawLoadClosestFont(&desc);
|
||||||
uiFreeText(family);
|
uiFreeText(family);
|
||||||
uiDrawTextFontGetMetrics(font, &metrics);
|
uiDrawTextFontGetMetrics(font, &metrics);
|
||||||
|
|
11
test/page9.c
11
test/page9.c
|
@ -10,7 +10,6 @@ static uiCombobox *textWeight;
|
||||||
static uiCombobox *textItalic;
|
static uiCombobox *textItalic;
|
||||||
static uiCheckbox *textSmallCaps;
|
static uiCheckbox *textSmallCaps;
|
||||||
static uiCombobox *textStretch;
|
static uiCombobox *textStretch;
|
||||||
static uiCombobox *textGravity;
|
|
||||||
static uiEntry *textWidth;
|
static uiEntry *textWidth;
|
||||||
static uiButton *textApply;
|
static uiButton *textApply;
|
||||||
static uiCheckbox *addLeading;
|
static uiCheckbox *addLeading;
|
||||||
|
@ -101,7 +100,6 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
|
||||||
desc.Italic = uiComboboxSelected(textItalic);
|
desc.Italic = uiComboboxSelected(textItalic);
|
||||||
desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
|
desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
|
||||||
desc.Stretch = uiComboboxSelected(textStretch);
|
desc.Stretch = uiComboboxSelected(textStretch);
|
||||||
desc.Gravity = uiComboboxSelected(textGravity);
|
|
||||||
font = uiDrawLoadClosestFont(&desc);
|
font = uiDrawLoadClosestFont(&desc);
|
||||||
uiFreeText(family);
|
uiFreeText(family);
|
||||||
uiDrawTextFontGetMetrics(font, &metrics);
|
uiDrawTextFontGetMetrics(font, &metrics);
|
||||||
|
@ -230,15 +228,6 @@ uiBox *makePage9(void)
|
||||||
uiComboboxSetSelected(textStretch, uiDrawTextStretchNormal);
|
uiComboboxSetSelected(textStretch, uiDrawTextStretchNormal);
|
||||||
uiBoxAppend(hbox, uiControl(textStretch), 1);
|
uiBoxAppend(hbox, uiControl(textStretch), 1);
|
||||||
|
|
||||||
textGravity = uiNewCombobox();
|
|
||||||
uiComboboxAppend(textGravity, "South");
|
|
||||||
uiComboboxAppend(textGravity, "East");
|
|
||||||
uiComboboxAppend(textGravity, "North");
|
|
||||||
uiComboboxAppend(textGravity, "West");
|
|
||||||
uiComboboxAppend(textGravity, "Auto");
|
|
||||||
uiComboboxSetSelected(textGravity, uiDrawTextGravitySouth);
|
|
||||||
uiBoxAppend(hbox, uiControl(textGravity), 1);
|
|
||||||
|
|
||||||
textWidth = uiNewEntry();
|
textWidth = uiNewEntry();
|
||||||
uiEntrySetText(textWidth, "-1");
|
uiEntrySetText(textWidth, "-1");
|
||||||
uiBoxAppend(hbox, uiControl(textWidth), 1);
|
uiBoxAppend(hbox, uiControl(textWidth), 1);
|
||||||
|
|
9
ui.h
9
ui.h
|
@ -491,14 +491,6 @@ typedef enum uiDrawTextStretch {
|
||||||
uiDrawTextStretchUltraExpanded,
|
uiDrawTextStretchUltraExpanded,
|
||||||
} uiDrawTextStretch;
|
} uiDrawTextStretch;
|
||||||
|
|
||||||
typedef enum uiDrawTextGravity {
|
|
||||||
uiDrawTextGravitySouth,
|
|
||||||
uiDrawTextGravityEast,
|
|
||||||
uiDrawTextGravityNorth,
|
|
||||||
uiDrawTextGravityWest,
|
|
||||||
uiDrawTextGravityAuto,
|
|
||||||
} uiDrawTextGravity;
|
|
||||||
|
|
||||||
struct uiDrawTextFontDescriptor {
|
struct uiDrawTextFontDescriptor {
|
||||||
const char *Family;
|
const char *Family;
|
||||||
double Size;
|
double Size;
|
||||||
|
@ -506,7 +498,6 @@ struct uiDrawTextFontDescriptor {
|
||||||
uiDrawTextItalic Italic;
|
uiDrawTextItalic Italic;
|
||||||
int SmallCaps;
|
int SmallCaps;
|
||||||
uiDrawTextStretch Stretch;
|
uiDrawTextStretch Stretch;
|
||||||
uiDrawTextGravity Gravity;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct uiDrawTextFontMetrics {
|
struct uiDrawTextFontMetrics {
|
||||||
|
|
10
unix/draw.c
10
unix/draw.c
|
@ -519,14 +519,6 @@ static const PangoStretch pangoStretches[] = {
|
||||||
[uiDrawTextStretchUltraExpanded] = PANGO_STRETCH_ULTRA_EXPANDED,
|
[uiDrawTextStretchUltraExpanded] = PANGO_STRETCH_ULTRA_EXPANDED,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const PangoGravity pangoGravities[] = {
|
|
||||||
[uiDrawTextGravitySouth] = PANGO_GRAVITY_SOUTH,
|
|
||||||
[uiDrawTextGravityEast] = PANGO_GRAVITY_EAST,
|
|
||||||
[uiDrawTextGravityNorth] = PANGO_GRAVITY_NORTH,
|
|
||||||
[uiDrawTextGravityWest] = PANGO_GRAVITY_WEST,
|
|
||||||
[uiDrawTextGravityAuto] = PANGO_GRAVITY_AUTO,
|
|
||||||
};
|
|
||||||
|
|
||||||
// we need a context for a few things
|
// we need a context for a few things
|
||||||
// the documentation suggests creating cairo_t-specific, GdkScreen-specific, or even GtkWidget-specific contexts, but we can't really do that because we want our uiDrawTextFonts and uiDrawTextLayouts to be context-independent
|
// the documentation suggests creating cairo_t-specific, GdkScreen-specific, or even GtkWidget-specific contexts, but we can't really do that because we want our uiDrawTextFonts and uiDrawTextLayouts to be context-independent
|
||||||
// so this will have to do
|
// so this will have to do
|
||||||
|
@ -557,8 +549,6 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
||||||
pango_font_description_set_variant(pdesc, variant);
|
pango_font_description_set_variant(pdesc, variant);
|
||||||
pango_font_description_set_stretch(pdesc,
|
pango_font_description_set_stretch(pdesc,
|
||||||
pangoStretches[desc->Stretch]);
|
pangoStretches[desc->Stretch]);
|
||||||
pango_font_description_set_gravity(pdesc,
|
|
||||||
pangoGravities[desc->Gravity]);
|
|
||||||
|
|
||||||
// in this case, the context is necessary for the metrics to be correct
|
// in this case, the context is necessary for the metrics to be correct
|
||||||
context = mkGenericPangoCairoContext();
|
context = mkGenericPangoCairoContext();
|
||||||
|
|
|
@ -172,7 +172,7 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
||||||
if (!found)
|
if (!found)
|
||||||
complain("invalid initial stretch %d passed to uiDrawLoadClosestFont()", desc->Stretch);
|
complain("invalid initial stretch %d passed to uiDrawLoadClosestFont()", desc->Stretch);
|
||||||
|
|
||||||
// TODO small caps and gravity
|
// TODO small caps
|
||||||
|
|
||||||
hr = family->GetFirstMatchingFont(weight,
|
hr = family->GetFirstMatchingFont(weight,
|
||||||
stretch,
|
stretch,
|
||||||
|
@ -322,7 +322,6 @@ uiDrawTextLayout *uiDrawNewTextLayout(const char *text, uiDrawTextFont *defaultF
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT("error creating IDWriteTextFormat in uiDrawNewTextLayout()", hr);
|
logHRESULT("error creating IDWriteTextFormat in uiDrawNewTextLayout()", hr);
|
||||||
// TODO small caps
|
// TODO small caps
|
||||||
// TODO gravity
|
|
||||||
|
|
||||||
layout->bytesToCharacters = toUTF16Offsets(text, &wtext, &wlen);
|
layout->bytesToCharacters = toUTF16Offsets(text, &wtext, &wlen);
|
||||||
hr = dwfactory->CreateTextLayout(wtext, wlen,
|
hr = dwfactory->CreateTextLayout(wtext, wlen,
|
||||||
|
|
Loading…
Reference in New Issue