Started fixing compile errors. I forgot I renamed uiDrawFontDescriptor to uiFontDescriptor!
This commit is contained in:
parent
9661d14262
commit
e9a62461c2
|
@ -206,7 +206,7 @@ uiAttribute *uiNewUnderlineColorAttribute(uiUnderlineColor u, double r, double g
|
||||||
return at;
|
return at;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiAttributeUnderline(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha)
|
void uiAttributeUnderlineColor(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha)
|
||||||
{
|
{
|
||||||
*u = a->u.color.underlineColor;
|
*u = a->u.color.underlineColor;
|
||||||
uiAttributeColor(a, r, g, b, alpha);
|
uiAttributeColor(a, r, g, b, alpha);
|
||||||
|
|
|
@ -60,16 +60,16 @@ extern void uiprivOpenTypeToAAT(char a, char b, char c, char d, uint32_t value,
|
||||||
- (CFStringRef)familyName;
|
- (CFStringRef)familyName;
|
||||||
- (CFArrayRef)variationAxes;
|
- (CFArrayRef)variationAxes;
|
||||||
@end
|
@end
|
||||||
extern CTFontDescriptorRef uiprivDrawFontDescriptorToCTFontDescriptor(uiDrawFontDescriptor *fd);
|
extern CTFontDescriptorRef uiprivFontDescriptorToCTFontDescriptor(uiFontDescriptor *fd);
|
||||||
extern CTFontDescriptorRef uiprivCTFontDescriptorAppendFeatures(CTFontDescriptorRef desc, const uiOpenTypeFeatures *otf);
|
extern CTFontDescriptorRef uiprivCTFontDescriptorAppendFeatures(CTFontDescriptorRef desc, const uiOpenTypeFeatures *otf);
|
||||||
extern void uiprivDrawFontDescriptorFromCTFontDescriptor(CTFontDescriptorRef ctdesc, uiDrawFontDescriptor *uidesc);
|
extern void uiprivFontDescriptorFromCTFontDescriptor(CTFontDescriptorRef ctdesc, uiFontDescriptor *uidesc);
|
||||||
|
|
||||||
// fonttraits.m
|
// fonttraits.m
|
||||||
extern void uiprivProcessFontTraits(uiprivFontStyleData *d, uiDrawFontDescriptor *out);
|
extern void uiprivProcessFontTraits(uiprivFontStyleData *d, uiFontDescriptor *out);
|
||||||
|
|
||||||
// fontvariation.m
|
// fontvariation.m
|
||||||
extern NSDictionary *uiprivMakeVariationAxisDict(CFArrayRef axes, CFDataRef avarTable);
|
extern NSDictionary *uiprivMakeVariationAxisDict(CFArrayRef axes, CFDataRef avarTable);
|
||||||
extern void uiprivProcessFontVariation(uiprivFontStyleData *d, NSDictionary *axisDict, uiDrawFontDescriptor *out);
|
extern void uiprivProcessFontVariation(uiprivFontStyleData *d, NSDictionary *axisDict, uiFontDescriptor *out);
|
||||||
|
|
||||||
// attrstr.m
|
// attrstr.m
|
||||||
extern void uiprivInitUnderlineColors(void);
|
extern void uiprivInitUnderlineColors(void);
|
||||||
|
|
|
@ -58,7 +58,7 @@ void uiprivUninitUnderlineColors(void)
|
||||||
spellingColor = nil;
|
spellingColor = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO opentype features are lost when using uiDrawFontDescriptor, so a handful of fonts in the font panel ("Titling" variants of some fonts and possibly others but those are the examples I know about) cannot be represented by uiDrawFontDescriptor; what *can* we do about this since this info is NOT part of the font on other platforms?
|
// TODO opentype features are lost when using uiFontDescriptor, so a handful of fonts in the font panel ("Titling" variants of some fonts and possibly others but those are the examples I know about) cannot be represented by uiFontDescriptor; what *can* we do about this since this info is NOT part of the font on other platforms?
|
||||||
// TODO see if we could use NSAttributedString?
|
// TODO see if we could use NSAttributedString?
|
||||||
// TODO consider renaming this struct and the fep variable(s)
|
// TODO consider renaming this struct and the fep variable(s)
|
||||||
// TODO restructure all this so the important details at the top are below with the combined font attributes type?
|
// TODO restructure all this so the important details at the top are below with the combined font attributes type?
|
||||||
|
@ -115,7 +115,7 @@ static uiForEach featuresHash(const uiOpenTypeFeatures *otf, char a, char b, cha
|
||||||
NSUInteger hash;
|
NSUInteger hash;
|
||||||
}
|
}
|
||||||
- (void)addAttribute:(uiAttribute *)attr;
|
- (void)addAttribute:(uiAttribute *)attr;
|
||||||
- (CTFontRef)toCTFontWithDefaultFont:(uiDrawFontDescriptor *)defaultFont;
|
- (CTFontRef)toCTFontWithDefaultFont:(uiFontDescriptor *)defaultFont;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation uiprivCombinedFontAttr
|
@implementation uiprivCombinedFontAttr
|
||||||
|
@ -216,15 +216,15 @@ static uiForEach featuresHash(const uiOpenTypeFeatures *otf, char a, char b, cha
|
||||||
return self->hash;
|
return self->hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CTFontRef)toCTFontWithDefaultFont:(uiDrawFontDescriptor *)defaultFont
|
- (CTFontRef)toCTFontWithDefaultFont:(uiFontDescriptor *)defaultFont
|
||||||
{
|
{
|
||||||
uiDrawFontDescriptor uidesc;
|
uiFontDescriptor uidesc;
|
||||||
CTFontDescriptorRef desc;
|
CTFontDescriptorRef desc;
|
||||||
CTFontRef font;
|
CTFontRef font;
|
||||||
|
|
||||||
uidesc = *defaultFont;
|
uidesc = *defaultFont;
|
||||||
if (self->attrs[cFamily] != NULL)
|
if (self->attrs[cFamily] != NULL)
|
||||||
// TODO const-correct uiDrawFontDescriptor or change this function below
|
// TODO const-correct uiFontDescriptor or change this function below
|
||||||
uidesc.Family = (char *) uiAttributeFamily(self->attrs[cFamily]);
|
uidesc.Family = (char *) uiAttributeFamily(self->attrs[cFamily]);
|
||||||
if (self->attrs[cSize] != NULL)
|
if (self->attrs[cSize] != NULL)
|
||||||
uidesc.Size = uiAttributeSize(self->attrs[cSize]);
|
uidesc.Size = uiAttributeSize(self->attrs[cSize]);
|
||||||
|
@ -234,7 +234,7 @@ static uiForEach featuresHash(const uiOpenTypeFeatures *otf, char a, char b, cha
|
||||||
uidesc.Italic = uiAttributeItalic(self->attrs[cItalic]);
|
uidesc.Italic = uiAttributeItalic(self->attrs[cItalic]);
|
||||||
if (self->attrs[cStretch] != NULL)
|
if (self->attrs[cStretch] != NULL)
|
||||||
uidesc.Stretch = uiAttributeStretch(self->attrs[cStretch]);
|
uidesc.Stretch = uiAttributeStretch(self->attrs[cStretch]);
|
||||||
desc = uiprivDrawFontDescriptorToCTFontDescriptor(&uidesc);
|
desc = uiprivFontDescriptorToCTFontDescriptor(&uidesc);
|
||||||
if (self->attrs[cFeatures] != NULL)
|
if (self->attrs[cFeatures] != NULL)
|
||||||
desc = uiprivCTFontDescriptorAppendFeatures(desc, uiAttributeFeatures(self->attrs[cFeatures]));
|
desc = uiprivCTFontDescriptorAppendFeatures(desc, uiAttributeFeatures(self->attrs[cFeatures]));
|
||||||
font = CTFontCreateWithFontDescriptor(desc, uidesc.Size, NULL);
|
font = CTFontCreateWithFontDescriptor(desc, uidesc.Size, NULL);
|
||||||
|
@ -386,7 +386,7 @@ $$TODO_CONTINUE_HERE
|
||||||
return uiForEachContinue;
|
return uiForEachContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void applyFontAttributes(CFMutableAttributedStringRef mas, uiDrawFontDescriptor *defaultFont)
|
static void applyFontAttributes(CFMutableAttributedStringRef mas, uiFontDescriptor *defaultFont)
|
||||||
{
|
{
|
||||||
uiprivCombinedFontAttr *cfa;
|
uiprivCombinedFontAttr *cfa;
|
||||||
CTFontRef font;
|
CTFontRef font;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
- (void)activateFontButton;
|
- (void)activateFontButton;
|
||||||
- (void)deactivateFontButton:(BOOL)activatingAnother;
|
- (void)deactivateFontButton:(BOOL)activatingAnother;
|
||||||
- (void)deactivateOnClose:(NSNotification *)note;
|
- (void)deactivateOnClose:(NSNotification *)note;
|
||||||
- (void)getfontdesc:(uiDrawFontDescriptor *)uidesc;
|
- (void)getfontdesc:(uiFontDescriptor *)uidesc;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// only one may be active at one time
|
// only one may be active at one time
|
||||||
|
@ -139,14 +139,14 @@ struct uiFontButton {
|
||||||
NSFontPanelCollectionModeMask;
|
NSFontPanelCollectionModeMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)getfontdesc:(uiDrawFontDescriptor *)uidesc
|
- (void)getfontdesc:(uiFontDescriptor *)uidesc
|
||||||
{
|
{
|
||||||
CTFontRef ctfont;
|
CTFontRef ctfont;
|
||||||
CTFontDescriptorRef ctdesc;
|
CTFontDescriptorRef ctdesc;
|
||||||
|
|
||||||
ctfont = (CTFontRef) (self->libui_font);
|
ctfont = (CTFontRef) (self->libui_font);
|
||||||
ctdesc = CTFontCopyFontDescriptor(ctfont);
|
ctdesc = CTFontCopyFontDescriptor(ctfont);
|
||||||
uiprivDrawFontDescriptorFromCTFontDescriptor(ctdesc, uidesc);
|
uiprivFontDescriptorFromCTFontDescriptor(ctdesc, uidesc);
|
||||||
CFRelease(ctdesc);
|
CFRelease(ctdesc);
|
||||||
uidesc->Size = CTFontGetSize(ctfont);
|
uidesc->Size = CTFontGetSize(ctfont);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ static void defaultOnChanged(uiFontButton *b, void *data)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiFontButtonFont(uiFontButton *b, uiDrawFontDescriptor *desc)
|
void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc)
|
||||||
{
|
{
|
||||||
[b->button getfontdesc:desc];
|
[b->button getfontdesc:desc];
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
//
|
//
|
||||||
// To make things easier for us, we'll match by converting Core
|
// To make things easier for us, we'll match by converting Core
|
||||||
// Text's values back into libui values. This allows us to also use the
|
// Text's values back into libui values. This allows us to also use the
|
||||||
// normalization code for filling in uiDrawFontDescriptors from
|
// normalization code for filling in uiFontDescriptors from
|
||||||
// Core Text fonts and font descriptors.
|
// Core Text fonts and font descriptors.
|
||||||
//
|
//
|
||||||
// Style matching needs to be done early in the font loading process;
|
// Style matching needs to be done early in the font loading process;
|
||||||
|
@ -318,14 +318,14 @@ static uiDrawTextItalic guessItalicOblique(uiprivFontStyleData *d)
|
||||||
// However, Core Text does seem to guarantee (from experimentation; see below) that the slant will be nonzero if and only if the italic bit is set, so we don't need to use the slant value.
|
// However, Core Text does seem to guarantee (from experimentation; see below) that the slant will be nonzero if and only if the italic bit is set, so we don't need to use the slant value.
|
||||||
// Core Text also seems to guarantee that if a font lists itself as Italic or Oblique by name (font subfamily name, font style name, whatever), it will also have that bit set, so testing this bit does cover all fonts that name themselves as Italic and Oblique. (Again, this is from the below experimentation.)
|
// Core Text also seems to guarantee that if a font lists itself as Italic or Oblique by name (font subfamily name, font style name, whatever), it will also have that bit set, so testing this bit does cover all fonts that name themselves as Italic and Oblique. (Again, this is from the below experimentation.)
|
||||||
// TODO there is still one catch that might matter from a user's POV: the reverse is not true — the italic bit can be set even if the style of the font face/subfamily/style isn't named as Italic (for example, script typefaces like Adobe's Palace Script MT Std); I don't know what to do about this... I know how to start: find a script font that has an italic form (Adobe's Palace Script MT Std does not; only Regular and Semibold)
|
// TODO there is still one catch that might matter from a user's POV: the reverse is not true — the italic bit can be set even if the style of the font face/subfamily/style isn't named as Italic (for example, script typefaces like Adobe's Palace Script MT Std); I don't know what to do about this... I know how to start: find a script font that has an italic form (Adobe's Palace Script MT Std does not; only Regular and Semibold)
|
||||||
static void setItalic(uiprivFontStyleData *d, uiDrawFontDescriptor *out)
|
static void setItalic(uiprivFontStyleData *d, uiFontDescriptor *out)
|
||||||
{
|
{
|
||||||
out->Italic = uiDrawTextItalicNormal;
|
out->Italic = uiDrawTextItalicNormal;
|
||||||
if (([d symbolicTraits] & kCTFontItalicTrait) != 0)
|
if (([d symbolicTraits] & kCTFontItalicTrait) != 0)
|
||||||
out->Italic = guessItalicOblique(d);
|
out->Italic = guessItalicOblique(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fillDescStyleFields(uiprivFontStyleData *d, NSDictionary *axisDict, uiDrawFontDescriptor *out)
|
static void fillDescStyleFields(uiprivFontStyleData *d, NSDictionary *axisDict, uiFontDescriptor *out)
|
||||||
{
|
{
|
||||||
setItalic(d, out);
|
setItalic(d, out);
|
||||||
if (axisDict != nil)
|
if (axisDict != nil)
|
||||||
|
@ -334,7 +334,7 @@ static void fillDescStyleFields(uiprivFontStyleData *d, NSDictionary *axisDict,
|
||||||
uiprivProcessFontTraits(d, out);
|
uiprivProcessFontTraits(d, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CTFontDescriptorRef matchStyle(CTFontDescriptorRef against, uiDrawFontDescriptor *styles)
|
static CTFontDescriptorRef matchStyle(CTFontDescriptorRef against, uiFontDescriptor *styles)
|
||||||
{
|
{
|
||||||
CFArrayRef matching;
|
CFArrayRef matching;
|
||||||
CFIndex i, n;
|
CFIndex i, n;
|
||||||
|
@ -363,7 +363,7 @@ static CTFontDescriptorRef matchStyle(CTFontDescriptorRef against, uiDrawFontDes
|
||||||
|
|
||||||
closeness = (struct closeness *) uiAlloc(n * sizeof (struct closeness), "struct closeness[]");
|
closeness = (struct closeness *) uiAlloc(n * sizeof (struct closeness), "struct closeness[]");
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
uiDrawFontDescriptor fields;
|
uiFontDescriptor fields;
|
||||||
|
|
||||||
closeness[i].index = i;
|
closeness[i].index = i;
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
|
@ -413,7 +413,7 @@ static CTFontDescriptorRef matchStyle(CTFontDescriptorRef against, uiDrawFontDes
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTFontDescriptorRef uiprivDrawFontDescriptorToCTFontDescriptor(uiDrawFontDescriptor *fd)
|
CTFontDescriptorRef uiprivFontDescriptorToCTFontDescriptor(uiFontDescriptor *fd)
|
||||||
{
|
{
|
||||||
CFMutableDictionaryRef attrs;
|
CFMutableDictionaryRef attrs;
|
||||||
CFStringRef cffamily;
|
CFStringRef cffamily;
|
||||||
|
@ -465,7 +465,7 @@ CTFontDescriptorRef uiprivCTFontDescriptorAppendFeatures(CTFontDescriptorRef des
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiprivDrawFontDescriptorFromCTFontDescriptor(CTFontDescriptorRef ctdesc, uiDrawFontDescriptor *uidesc)
|
void uiprivFontDescriptorFromCTFontDescriptor(CTFontDescriptorRef ctdesc, uiFontDescriptor *uidesc)
|
||||||
{
|
{
|
||||||
CFStringRef cffamily;
|
CFStringRef cffamily;
|
||||||
uiprivFontStyleData *d;
|
uiprivFontStyleData *d;
|
||||||
|
|
|
@ -54,7 +54,7 @@ static const CFStringRef exceptions[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void trySecondaryOS2Values(uiprivFontStyleData *d, uiDrawFontDescriptor *out, BOOL *hasWeight, BOOL *hasWidth)
|
static void trySecondaryOS2Values(uiprivFontStyleData *d, uiFontDescriptor *out, BOOL *hasWeight, BOOL *hasWidth)
|
||||||
{
|
{
|
||||||
CFDataRef os2;
|
CFDataRef os2;
|
||||||
uint16_t usWeightClass, usWidthClass;
|
uint16_t usWeightClass, usWidthClass;
|
||||||
|
@ -159,7 +159,7 @@ static BOOL shouldReallyBeSemiCondensed(uiprivFontStyleData *d)
|
||||||
return testTTFOTFSubfamilyNames(d, CFSTR("Semi Condensed"));
|
return testTTFOTFSubfamilyNames(d, CFSTR("Semi Condensed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiprivProcessFontTraits(uiprivFontStyleData *d, uiDrawFontDescriptor *out)
|
void uiprivProcessFontTraits(uiprivFontStyleData *d, uiFontDescriptor *out)
|
||||||
{
|
{
|
||||||
double weight, width;
|
double weight, width;
|
||||||
BOOL hasWeight, hasWidth;
|
BOOL hasWeight, hasWidth;
|
||||||
|
|
|
@ -305,7 +305,7 @@ static BOOL tryAxis(NSDictionary *axisDict, CFDictionaryRef var, NSNumber *key,
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiprivProcessFontVariation(uiprivFontStyleData *d, NSDictionary *axisDict, uiDrawFontDescriptor *out)
|
void uiprivProcessFontVariation(uiprivFontStyleData *d, NSDictionary *axisDict, uiFontDescriptor *out)
|
||||||
{
|
{
|
||||||
CFDictionaryRef var;
|
CFDictionaryRef var;
|
||||||
double v;
|
double v;
|
||||||
|
|
|
@ -214,7 +214,7 @@ _UI_EXTERN uiAttribute *uiNewUnderlineColorAttribute(uiUnderlineColor u, double
|
||||||
// uiAttributeUnderlineColor() returns the underline color stored in
|
// uiAttributeUnderlineColor() returns the underline color stored in
|
||||||
// a. It is an error to call this on a uiAttribute that does not hold an
|
// a. It is an error to call this on a uiAttribute that does not hold an
|
||||||
// underline color.
|
// underline color.
|
||||||
_UI_EXTERN void uiAttributeUnderline(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha);
|
_UI_EXTERN void uiAttributeUnderlineColor(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha);
|
||||||
|
|
||||||
// uiOpenTypeFeatures represents a set of OpenType feature
|
// uiOpenTypeFeatures represents a set of OpenType feature
|
||||||
// tag-value pairs, for applying OpenType features to text.
|
// tag-value pairs, for applying OpenType features to text.
|
||||||
|
@ -409,7 +409,7 @@ _UI_EXTERN size_t uiAttributedStringGraphemeToByteIndex(uiAttributedString *s, s
|
||||||
// All the members operate like the respective uiAttributes.
|
// All the members operate like the respective uiAttributes.
|
||||||
typedef struct uiFontDescriptor uiFontDescriptor;
|
typedef struct uiFontDescriptor uiFontDescriptor;
|
||||||
|
|
||||||
struct uiDrawFontDescriptor {
|
struct uiFontDescriptor {
|
||||||
// TODO const-correct this or figure out how to deal with this when getting a value
|
// TODO const-correct this or figure out how to deal with this when getting a value
|
||||||
char *Family;
|
char *Family;
|
||||||
double Size;
|
double Size;
|
||||||
|
@ -448,7 +448,7 @@ typedef struct uiDrawTextLayoutParams uiDrawTextLayoutParams;
|
||||||
// TODO const-correct this somehow
|
// TODO const-correct this somehow
|
||||||
struct uiDrawTextLayoutParams {
|
struct uiDrawTextLayoutParams {
|
||||||
uiAttributedString *String;
|
uiAttributedString *String;
|
||||||
uiDrawFontDescriptor *DefaultFont;
|
uiFontDescriptor *DefaultFont;
|
||||||
double Width;
|
double Width;
|
||||||
uiDrawTextAlign Align;
|
uiDrawTextAlign Align;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue