Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Properly pass font weight, stretch, style, to XamlCompositor#1302

Merged
ms-jihua merged 1 commit into
microsoft:developfrom
ms-jihua:uilabel_traits2
Nov 2, 2016
Merged

Properly pass font weight, stretch, style, to XamlCompositor#1302
ms-jihua merged 1 commit into
microsoft:developfrom
ms-jihua:uilabel_traits2

Conversation

@ms-jihua

@ms-jihua ms-jihua commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

Update from using simplistic mapping using the font's symbolic traits, which ignored stretch,
to getting the weight/stretch/style directly from the font.

UILabel-rendered narrow or condensed fonts were previously clipped at the sides
because the CoreText-calculated width would be for a narrow font, but UILabel would attempt to render a normal font.


This change is Reviewable

Update from using simplistic mapping using the font's symbolic traits, which ignored stretch,
to getting the weight/stretch/style directly from the font.

UILabel-rendered narrow or condensed fonts were previously clipped at the sides
because the CoreText-calculated width would be for a narrow font, but UILabel would attempt to render a normal font.
_isItalic = (mask & UIFontDescriptorTraitItalic) > 0;
_fontWeight = [font _fontWeight];
_fontStretch = [font _fontStretch];
_fontStyle = [font _fontStyle];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of the code you're changing here is gone in the CA refactor, but I suppose this can go in and I'll have to forklift it to our UILabel impl. Seems straightforward enough, but please ping me when this goes in so I can do yet another merge :/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. sorry about this :(


In reply to: 86254978 [](ancestors = 86254978)

@jaredhms

jaredhms commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

:shipit:

CFTypeID CTFontGetTypeID() {
static CFTypeID __kCTFontTypeID = _CFRuntimeRegisterClass(&__CTFontClass);
return __kCTFontTypeID;
}

@rajsesh rajsesh Nov 2, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are adding these private apis for the sake of passing them along to xaml, we should make just one function that gets all this information. #WontFix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline - I pursued this route earlier, but exporting a struct through this many layers ended up being a much more ugly change. Leaving as is.


In reply to: 86256084 [](ancestors = 86256084)

} else {
textControl->FontStyle = Windows::UI::Text::FontStyle::Normal;
}
textControl->FontWeight = Windows::UI::Text::FontWeight{ static_cast<unsigned short>(_fontWeight) };

@aballway aballway Nov 2, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these all 1-1 mappings? #ByDesign

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xaml is built on top of DWrite, so yes.


In reply to: 86258890 [](ancestors = 86258890)

@ms-jihua ms-jihua merged commit e7ae8b7 into microsoft:develop Nov 2, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants