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);
|
||||
}
|
||||
|
||||
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 :(
|
||||
// kode54 got these for me before I had access to El Capitan; thanks to him.
|
||||
#define ourNSFontWeightUltraLight -0.800000
|
||||
|
@ -387,7 +382,6 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
|||
// and finally add the other attributes
|
||||
if (desc->SmallCaps)
|
||||
addFontSmallCapsAttr(attr);
|
||||
addFontGravityAttr(attr, desc->Gravity);
|
||||
|
||||
// and NOW create the final descriptor
|
||||
cfdesc = CTFontDescriptorCreateWithAttributes(attr);
|
||||
|
|
|
@ -96,7 +96,6 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
|
|||
desc.Italic = uiComboboxSelected(textItalic);
|
||||
desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
|
||||
desc.Stretch = uiComboboxSelected(textStretch);
|
||||
desc.Gravity = uiComboboxSelected(textGravity);
|
||||
font = uiDrawLoadClosestFont(&desc);
|
||||
uiFreeText(family);
|
||||
uiDrawTextFontGetMetrics(font, &metrics);
|
||||
|
|
11
test/page9.c
11
test/page9.c
|
@ -10,7 +10,6 @@ static uiCombobox *textWeight;
|
|||
static uiCombobox *textItalic;
|
||||
static uiCheckbox *textSmallCaps;
|
||||
static uiCombobox *textStretch;
|
||||
static uiCombobox *textGravity;
|
||||
static uiEntry *textWidth;
|
||||
static uiButton *textApply;
|
||||
static uiCheckbox *addLeading;
|
||||
|
@ -101,7 +100,6 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
|
|||
desc.Italic = uiComboboxSelected(textItalic);
|
||||
desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
|
||||
desc.Stretch = uiComboboxSelected(textStretch);
|
||||
desc.Gravity = uiComboboxSelected(textGravity);
|
||||
font = uiDrawLoadClosestFont(&desc);
|
||||
uiFreeText(family);
|
||||
uiDrawTextFontGetMetrics(font, &metrics);
|
||||
|
@ -230,15 +228,6 @@ uiBox *makePage9(void)
|
|||
uiComboboxSetSelected(textStretch, uiDrawTextStretchNormal);
|
||||
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();
|
||||
uiEntrySetText(textWidth, "-1");
|
||||
uiBoxAppend(hbox, uiControl(textWidth), 1);
|
||||
|
|
9
ui.h
9
ui.h
|
@ -491,14 +491,6 @@ typedef enum uiDrawTextStretch {
|
|||
uiDrawTextStretchUltraExpanded,
|
||||
} uiDrawTextStretch;
|
||||
|
||||
typedef enum uiDrawTextGravity {
|
||||
uiDrawTextGravitySouth,
|
||||
uiDrawTextGravityEast,
|
||||
uiDrawTextGravityNorth,
|
||||
uiDrawTextGravityWest,
|
||||
uiDrawTextGravityAuto,
|
||||
} uiDrawTextGravity;
|
||||
|
||||
struct uiDrawTextFontDescriptor {
|
||||
const char *Family;
|
||||
double Size;
|
||||
|
@ -506,7 +498,6 @@ struct uiDrawTextFontDescriptor {
|
|||
uiDrawTextItalic Italic;
|
||||
int SmallCaps;
|
||||
uiDrawTextStretch Stretch;
|
||||
uiDrawTextGravity Gravity;
|
||||
};
|
||||
|
||||
struct uiDrawTextFontMetrics {
|
||||
|
|
10
unix/draw.c
10
unix/draw.c
|
@ -519,14 +519,6 @@ static const PangoStretch pangoStretches[] = {
|
|||
[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
|
||||
// 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
|
||||
|
@ -557,8 +549,6 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
|||
pango_font_description_set_variant(pdesc, variant);
|
||||
pango_font_description_set_stretch(pdesc,
|
||||
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
|
||||
context = mkGenericPangoCairoContext();
|
||||
|
|
|
@ -172,7 +172,7 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
|||
if (!found)
|
||||
complain("invalid initial stretch %d passed to uiDrawLoadClosestFont()", desc->Stretch);
|
||||
|
||||
// TODO small caps and gravity
|
||||
// TODO small caps
|
||||
|
||||
hr = family->GetFirstMatchingFont(weight,
|
||||
stretch,
|
||||
|
@ -322,7 +322,6 @@ uiDrawTextLayout *uiDrawNewTextLayout(const char *text, uiDrawTextFont *defaultF
|
|||
if (hr != S_OK)
|
||||
logHRESULT("error creating IDWriteTextFormat in uiDrawNewTextLayout()", hr);
|
||||
// TODO small caps
|
||||
// TODO gravity
|
||||
|
||||
layout->bytesToCharacters = toUTF16Offsets(text, &wtext, &wlen);
|
||||
hr = dwfactory->CreateTextLayout(wtext, wlen,
|
||||
|
|
Loading…
Reference in New Issue